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

后端 未结 4 1927
误落风尘
误落风尘 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 03:52

    Resolved an error by following: Hi all, Resolved problem to run cordova run android via command prompt for cordova project attached problem screenshot. To resolve this problem removed all environment variables under Advanced System settings. Uninstalled java and installed again, downloaded old sdk tools to avoid prompt for eclipse now.

    Under user variable added JAVA_HOME = C:\Program Files\Java\jdk1.8.0_131

    Under System variable ANDROD_HOME = C:\cordova\android-sdk Path = C:\Program Files\Android\Android Studio2\gradle\gradle-3.2\bin\;%JAVA_HOME%\bin to avoid error: No installed build tools found. Install the Android build tools version 19.1.0 or higher. Problem resolved now

    0 讨论(0)
  • 2021-01-14 03:54

    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.

    0 讨论(0)
  • 2021-01-14 04:00

    You can downgrade cordova cli using

    npm install -g cordova@6.4.0
    

    and build the project with give command

    ionic cordova build android
    

    no need to add platform, it'll automatically add. If it ask to update cordova cli, then choose no

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题