问题描述
我正在更新一个较旧的cordova 项目.作为这个过程的一部分,我删除了 android 平台并阅读了它.
I have an older cordova project that I am updating. As a part of this process, I removed the android platform and readded it.
现在,当我尝试构建项目时,出现以下错误:
Now when I try to build the project I get the following error:
C:App>cordova build android --verbose
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
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 C:Appplatformsandroid
esxmlconfig.xml
Merging project's config.xml into platform-specific android config.xml
Found "merges/android" folder. Copying its contents into the android project.
Merging and updating files from [www, platformsandroidplatform_www, mergesandroid] to platformsandroidassetswww
Wrote out android application name "App" to C:Appplatformsandroid
esvaluesstrings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.20): 10020
Wrote out Android package name "com.nge.app" to C:Appplatformsandroidsrccom
gecaMainActivity.java
Updating icons at platformsandroid
es
Updating splash screens at platformsandroid
es
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=C:Androidsdk
JAVA_HOME=C:Program FilesJavajdk1.8.0_40
Error: Cannot read property 'length' of undefined
在我删除平台之前这确实有效,所以我猜这是一个错误或配置文件发生了变化.
This did work before I removed the platform so I am guessing it is a bug or a config file that changed.
There is a similar issue here: https://pt.stackoverflow.com/questions/219442/cordova-build-android-error-cannot-read-property-length-of-undefined
推荐答案
问题是我的 gradle 版本是 2.1,而 Cordova 想要 3.2.更新 Android Studio(它是 2.1)并确保环境变量是最新的是让它再次工作的主要技巧.
The problem was that my gradle version was 2.1 where Cordova wanted 3.2. Updating Android Studio (It was at 2.1) and making sure the environment variables are upto date was the main trick to get it to work again.
这篇关于Cordova Android 构建错误“无法读取未定义的属性‘长度’"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!