Wex5打包报错的解决办法

以前使用Wex5 3.6打包没有任何问题,这次生成Android安装包时,报错如下:

Running command: cmd "/s /c "D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\cordova\build.bat --debug --gradleArg=--offline""
      ANDROID_HOME=D:\Java\WeX5_V3.6\tools\adt-sdk
      JAVA_HOME=D:\Java\WeX5_V3.6\java\jre1.8
      Running: D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\gradlew cdvBuildDebug -b D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\build.gradle -Dorg.gradle.daemon=true --offline

      FAILURE: Build failed with an exception.

      * What went wrong:
      A problem occurred configuring root project 'android'.
      > Could not resolve all dependencies for configuration ':classpath'.
         > Could not resolve com.android.tools.build:gradle:2.0.0+.
           Required by:
               :android:unspecified
            > No cached version listing for com.android.tools.build:gradle:2.0.0+ available for offline mode.

      * Try:
      Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

      BUILD FAILED

      Total time: 1.536 secs
      ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
      You may not have the required environment or OS to build this project

      D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\cordova\node_modules\q\q.js:126
                          throw e;
                          ^
      Error code 1 for command: cmd with args: /s /c "D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\gradlew cdvBuildDebug -b D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\build.gradle -Dorg.gradle.daemon=true --offline"
      Error: cmd: Command failed with exit code 1
   ****ERROR****: 子任务 "exec" 执行失败。
   ****ERROR****: 任务 "buildAndroid" 执行失败。
   ****ERROR****: 执行出错:
   ****ERROR****: 错误信息: exec returned: 1
   ****ERROR****: 如不能确定具体问题,可参考常见问题: http://bbs.wex5.com/thread-82002-1-1.html
   C:\Users\gaoqing\AppData\Local\Temp\13403ae0-ddc9-4956-8938-302058198b22\pack.xml:88: exec returned: 1
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:643)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:669)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:495)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    at com.justep.deploy.app.utils.BuildHelper.execTask(Unknown Source)
    at com.justep.deploy.app.utils.Builder.main(Unknown Source)
****ERROR****: 子任务 "java" 执行失败。
****ERROR****: 任务 "pack" 执行失败。
****ERROR****: 执行出错:
****ERROR****: 错误信息: Java returned: -3
****ERROR****: 如不能确定具体问题,可参考常见问题: http://bbs.wex5.com/thread-82002-1-1.html

这里真正出错的代码是这段:

D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\gradlew cdvBuildDebug -b D:\Java\WeX5_V3.6\model\Native\ztest\build\src\platforms\android\build.gradle -Dorg.gradle.daemon=true --offline

产生的错误是这个:

> Could not resolve all dependencies for configuration ':classpath'.
         > Could not resolve com.android.tools.build:gradle:2.0.0+.

找不到classpath指向的gradle文件。

我把上面的命令在命令行执行,并启动–debug,结果发现该命令执行的时候是到maven的库文件里去找,maven库里没有gradle。以前没有安装maven的时候打包不报错,现在安装了maven,打包的时候会到maven的库里去找。所以在maven的pom里把gradle添加进去,下载到本地资源库,再打包就没问题了。如果你安装了maven并且错误提示里也是缺少了gradle或者别的什么包,可以用这种方法解决。

你可能感兴趣的:(Wex5打包报错的解决办法)