cordova ubuntu: An error occurred while listing Android targets

前端 未结 4 798
深忆病人
深忆病人 2020-12-05 18:47

I\'m trying add the android platform to my cordova project, though I get the error:

$ cordova platform add android -d
cordova library for \"android\" already         


        
相关标签:
4条回答
  • 2020-12-05 19:04

    Please Refer the Question

    An error occurred while listing Android targets

    and the Link developer.android.com/tools/devices/managing-avds-cmdline.html

    Most probably the path variable pointing to this android was wrong. I had used %ANDROID_HOME% as variable and scaled the same to path variables %ANDROID_HOME%\SDK\TOOLS. This method doesn't work. Experimentally resolved by directly pointing to the Tools and Platform Tools.

    Just based on what I did and it worked for me. Hope You get the Issue resolved

    I had faced the Issue even after the Cordova check_reqs was working correctly without providing any error.But on adding a new platform this error was still being raised. The above method personaly resolved my issue.

    0 讨论(0)
  • 2020-12-05 19:06

    in .bashrc try adding

    export ANT_HOME="/usr/bin/ant"
    export PATH="$PATH:$ANT_HOME/bin"
    export HOME="/home/username"
    export ANDROID_HOME="$HOME/android-bundle/sdk/tools"
    export ANDROID_PLATFORM_TOOLS="$HOME/android-bundle/sdk/platform-tools"
    export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
    

    or try explicitly define the paths globally.

    from the terminal I type:

    export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/tools
    export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/platform-tools
    

    (rememebr to replace with your own sdk path)

    If this doesn't work, try updating the sdk

    0 讨论(0)
  • 2020-12-05 19:13

    Cordova has a script to check if all dependencies are present. Is is called when you run cordova platform add android but unfortunatly it's output is not displayed when it fails.

    You can try to run it manually, it should be $home/.cordova/lib/android/cordova/3.5.0/bin/check_reqs

    The normal output when everything's fine is "Looks like your environment fully supports cordova-android development!", oterwise it should display a clear message about what's missing.

    Maybe your issue is that you havent't installed SDK platform for API 19 in android sdk manager (cordova 3.3 or 3.5 uses target sdk 19).

    Update: Cordova 3.3 or 3.5 works on SDK 19 only (Android 4.4.2). The error logs does not mention clearly what platform version it is looking for. Typically error messages are:

    Unable to add platform android. Please see console for more info.
    

    or

    [Error: An error occurred while listing Android targets]
    

    This can also happen when android (sdk/tools) is not in path. I would have loved if the check-script have printed correct error message. BTW, created a PR for them.

    0 讨论(0)
  • 2020-12-05 19:20

    I solved the problem giving full permission for my app folder

    $ sudo chmod -R 777 myApp
    

    After that, try again

    $ cd myApp
    $ ionic platform android
    
    0 讨论(0)
提交回复
热议问题