【发布时间】: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
【问题讨论】:
标签: ionic4