Cordova Android build error “Cannot read property 'length' of undefined”

后端 未结 4 1965
误落风尘
误落风尘 2021-01-14 03:46

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 g

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 04:10

    I found another solution by downgrading Android to version 6.1.2, since the suggestions here (and many other suggestions on various forums, like reinstalling plugins, etc.) didn't work for me:

    cordova platform update android@6.1.2 --save
    

    If that doesn't work at first hand, try the following:

    1. First remove android platform:

      cordova platform remove android
      
    2. Add Android version 6.1.2:

      cordova platform add android@6.1.2
      
    3. Build Android:

      cordova build android
      

    Here are some additional steps I took prior to above (on Mac), just to make sure:

    1. Download the latest JDK and install.

    2. Add JAVA_HOME this way:

      echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
      
    3. Restart shell (CMD+Q and open again)

    4. Make sure echo $JAVA_HOME equals to Android Studio -> File -> Project Structure -> JDK Location

    For me, this is the following path and version:

    /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

    1. Update Android Studio and all of the SDK packages

    2. Update npm

      npm update -g
      

    Note: On OS X 10.11 El Capitan or greater, run:

    sudo npm update -g --unsafe-perm=true
    
    1. Update Cordova

      npm update -g cordova
      

    If all of this didn't work for you and you are left with no other choice, I suggest you try downgrading Cordova to version 6.4.0:

    npm update -g cordova@6.4.0
    

提交回复
热议问题