运行子流程cordova时发生错误。科尔多瓦建立Android退出退出代码1

时间:2019-08-11 05:01:08

标签: ionic4

每当我构建或运行应用程序时,我都在为我的应用程序使用ionic 4,我收到一条错误消息,提示“运行子进程cordova时发生错误。cordova build android --verbose退出代码为1。”和我使用ionic cordova用冗长的命令构建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

1 个答案:

答案 0 :(得分:0)

似乎实际错误是:

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)并确保环境变量是最新的,这是使其再次运行的主要技巧。

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

文档在这里:

但是安装中有很多文章,请逐步解决所有问题。