【问题标题】:An error occurred while running subprocess cordova. cordova build android exited with exit code 1运行子进程cordova 时出错。 cordova build android 退出,退出代码为 1
【发布时间】:2019-08-11 05:01:08
【问题描述】:

每当我构建或运行应用程序时,我都会在我的应用程序中使用 ionic 4,我收到错误消息:“运行子进程 cordova 时发生错误。cordova build android --verbose exited with exit code 1。”和我使用 ionic cordova build android 的相同命令,我无法理解如何解决这个问题。

我已经rm并添加了android平台和降级的cordova版本到7。

这是我在运行代码后遇到的错误:ionic cordova build android

>Android Studio project detected
    ANDROID_HOME=C:\Users\User\AppData\Local\Android\android-sdk
    JAVA_HOME=C:\Program Files\Java\jdk1.8
    studio
    Cannot read property 'length' of undefined
    [ERROR] An error occurred while running subprocess cordova.

>cordova build android exited with exit code 1.

>Re-running this command with the --verbose flag may provide more information.

After I tried same with verbose: `ionic cordova build android --verbose`

Wrote out android application name "MyApp" to E:\ionic4\notification\platforms\android\app\src\main\res\values\strings.xml
>android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1
Wrote out Android package name "io.ionic.starterapp" to E:\ionic4\notification\platforms\android\app\src\main\java\io\ionic\starterapp\MainActivity.java
Updating icons at platforms\android\app\src\main\res
Updating splash screens at platforms\android\app\src\main\res
Updating resource files at platforms\android
Prepared android project successfully
Executing script found in plugin cordova-plugin-fcm-with-dependecy-updated for hook "after_prepare": plugins\cordova-plugin-fcm-with-dependecy-updated\scripts\fcm_config_files_process.js
No scripts found for hook "before_compile".
ANDROID_HOME=C:\Users\User\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8
studio
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.module.exports.check_gradle (E:\ionic4\notification\platforms\android\cordova\lib\check_reqs.js:138:20)
    at StudioBuilder.prepEnv (E:\ionic4\notification\platforms\android\cordova\lib\builders\StudioBuilder.js:217:23)
    at Api.module.exports.run (E:\ionic4\notification\platforms\android\cordova\lib\build.js:154:20)
    at E:\ionic4\notification\platforms\android\cordova\Api.js:342:43
    at _fulfilled (E:\ionic4\notification\platforms\android\cordova\node_modules\q\q.js:834:54)
    at E:\ionic4\notification\platforms\android\cordova\node_modules\q\q.js:863:30
    at Promise.promise.promiseDispatch (E:\ionic4\notification\platforms\android\cordova\node_modules\q\q.js:796:13)
    at  (E:\ionic4\notification\platforms\android\cordova\node_modules\q\q.js:137:13)
    at flush (E:\ionic4\notification\platforms\android\cordova\node_modules\q\q.js:125:13)
E:\ionic4\notification\platforms\android\cordova\node_modules\q\q.js:604:44
    at runSingle

No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Android Studio project detected
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at E:\ionic4\notification\platforms\android\app\src\main\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\app\src\main\assets\www

image.

【问题讨论】:

    标签: ionic4


    【解决方案1】:

    似乎实际的错误是:

    Cannot read property 'length' of undefined
    

    我用关键字ionic cordova check_gradle Cannot read property 'length' of undefined 进行了搜索,我发现很多人都遇到了这个问题。

    One of them 说:

    问题是我的 gradle 版本是 2.1,而 Cordova 想要 3.2。更新 Android Studio(它是 2.1)并确保环境变量是最新的是让它再次工作的主要技巧。

    因此,我将开始调查您的设置是否以正确的版本运行。

    文档在这里:

    但是安装中有一堆文章,你自己去看看吧。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      • 2017-11-09
      • 2014-08-16
      相关资源
      最近更新 更多