【问题标题】:Error gradle on mfp cordova run -p androidmfp cordova run -p android 上的错误 gradle
【发布时间】:2016-06-29 13:43:33
【问题描述】:

当我想使用以下命令在我的设备上运行我的应用程序时,MobileFirst Foundation 7.1 出现错误:mfp cordova run -p android:

ERROR running one or more of the platforms: Error: C:\projects\profondeur\trunk\platforms\android\cordova\run.bat: Command failed with exit code 8
You may not have the required environment or OS to run this project
mobilefirst-cli verb cordova_run error stack: "Error: FAILURE: Build failed with an exception.\r\n\r\n* Where:\r\nBuild file 'C:\\projects\\profondeur\\trunk\\platforms\\android\\build.gradle' line: 3\r\n\r\n* What went wrong:\r\nA problem occurred evaluating root project 'android'.\r\n> Gradle version 2.2 is required.
Current version is 1.12. If using the gradle wrapper, try editing the distributionUrl in C:\\projects\\profondeur\\trunk\\gradle\\wrapper\\gradle-wrapper.properties to gradle-2.2-all.zip\r\n\r\n* Try:\r\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\r\n\r\nC:\\projects\\profondeur\\trunk\\platforms\\android\\cordova\\node_modules\\q\\q.js:126\r\n                    throw e;\r\n                          ^\r\nError code 1 for command: cmd with args: /s,/c,C:\\projects\\profondeur\\trunk\\platforms\\android\\gradlew,build,-b,C:\\projects\\profondeur\\trunk\\platforms\\android\\build.gradle,-Dorg.gradle.daemon=true,-x,lint,-x,lintVitalRelease,-x,compileLint,-x,copyReleaseLint,-x,copyDebugLint\n    at ChildProcess.<anonymous> (C:\\Program Files\\IBM\\MobileFirst-CLI\\mobilefirst-cli\\node_modules\\cordovacmd\\lib\\cordova-cli.js:253:41)\n    at ChildProcess.emit (events.js:117:20)\nat maybeClose (child_process.js:766:16)\n    at Socket.<anonymous> (child_process.js:979:11)\n    at Socket.emit (events.js:95:17)\n    at Pipe.close (net.js:466:12)"
mobilefirst-cli verb cordova_run error message: "FAILURE: Build failed with an exception.\r\n\r\n* Where:\r\nBuild file 'C:\\projects\\profondeur\\trunk\\platforms\\android\\build.gradle' line: 3\r\n\r\n* What went wrong:\r\nA problem occurred evaluating root project 'android'.\r\n> Gradle version 2.2 is required. Current version is 1.12. If using the gradle wrapper, try editing the distributionUrl in C:\\projects\\profondeur\\trunk\\gradle\\wrapper\\gradle-wrapper.properties to gradle-2.2-all.zip\r\n\r\n* Try:\r\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\r\n\r\nC:\\projects\\profondeur\\trunk\\platforms\\android\\cordova\\node_modules\\q\\q.js:126\r\n                    throw e;\r\n                          ^\r\nError code 1 for command: cmd with args: /s,/c,C:\\projects\\profondeur\\trunk\\platforms\\android\\gradlew,build,-b,C:\\projects\\profondeur\\trunk\\platforms\\android\\build.gradle,-Dorg.gradle.daemon=true,-x,lint,-x,lintVitalRelease,-x,compileLint,-x,copyReleaseLint,-x,copyDebugLint"
mobilefirst-cli verb cordova_run error code: 0
Error: FAILURE: Build failed with an exception.

* Where:
Build file 'C:\projects\profondeur\trunk\platforms\android\build.gradle' line: 3

* What went wrong:
A problem occurred evaluating root project 'android'.
> Gradle version 2.2 is required. Current version is 1.12. If using the gradle wrapper, try editing the distributionUrl in C:\projects\profondeur\trunk\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip

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

C:\projects\profondeur\trunk\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s,/c,C:\projects\profondeur\trunk\platforms\android\gradlew,build,-b,C:\projects\profondeur\trunk\platforms\android\build.gradle,-Dorg.gradle.daemon=true,-x,lint,-x,lintVitalRelease,-x,compileLint,-x,copyReleaseLint,-x,copyDebugLint
mobilefirst-cli verb cli error, finish with mobilefirst cordova

不明白 gradle 有什么问题?

【问题讨论】:

    标签: cordova ibm-mobilefirst cordova-cli mobilefirst-cli


    【解决方案1】:

    在 build.gradle 文件中,确保您使用的是最新的 gradle 插件版本。目前为 1.5.0

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'
        }
    }
    

    然后转到platforms/android/gradle/wrapper/gradle-wrapper.properties 并确保distributionUrl 值使用的是最新的。

    distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
    

    我还建议添加此环境变量,以便它会提取您想要的 gradle 包装器分发 url 版本。除非您添加此环境变量,否则 Cordova 倾向于添加旧版本。

    CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=http://services.gradle.org/distributions/gradle-2.8-all.zip

    【讨论】:

    • 所以我在 build.gralde 中有很好的价值,但在我有这个代码的 gradle-wrapper.properties 中没有:distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip 即使我添加了这个环境变量:CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=services.gradle.org/distributions/gradle-2.8-all.zip
    • 在 gradle-wrapper.properties 中手动将distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip 更改为正确的版本,以正确的值。此外,查看项目的父目录并删除任何 build.gradle 和 gradle 文件夹(其中包含 gradle 包装文件)。有时会生成这些。前任。 C:/User/workspace/myproject/,可以在用户目录或工作空间目录中生成gradle文件。您将需要删除这些。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 2016-03-01
    • 2019-12-03
    • 1970-01-01
    相关资源
    最近更新 更多