Cordova-CLI & PhoneGap-CLI do not see android sdk - android

I've created app with "phonegap create" command. Then I switch to project dir and try to run it with "phonegap local run android" and I have next error message:
Please install Android target 17 <...>
Android SDK is placed to C:\dev\sdk
My PATH variable contains C:\dev\sdk; C:\div\sdk\platforms\;C:\dev\sdk\platform-tools
I run "android" command from cmd and SDK Manager shows no updates or no missed sdk files.
I tried create and run project with cordova cli but had same problem.
What can it be?

It seems that for latest Cordova (3.0.6),
cordova platform add android
command only recognize Android 4.2.2(API17) SDK. After I install the API17 SDK, the error was gone.
Not sure if there is a cordova command option that can specify SDK version.

I had just the same problem (error message) with os x (10.8).
After executing the command android in the Terminal some android-packet-management-UI popped up. There i could install stuff that made it run ..

I had API17 installed but was still getting this error.
I needed to install apache-ant, set ANT_HOME=C:\Program Files\Java\apache-ant\, JAVA_HOME=C:\Program Files\Java\jdk1.7.0_21\ and add both bin's to my PATH += C:\Program Files\Java\jdk1.7.0_21\bin;C:\Program Files\Java\apache-ant\bin
See https://stackoverflow.com/a/13986997/956397

I had the same problem and the very most simple way to resolve it is changing the target in project.properties to 16 and try.

it seems if you type "android" at the same command prompt you type your cordova commands, you get a separate Android SDK manager then the one launched via Eclipse and so then there you select the appropriate packages and updates to achieve the version number of the Adroid SDK required. For me I'm guessing it's from an adt-bundle I installed with _? (I don't know actually no clue) that runs instead.
My best guess is the installer when updating doesn't doesn't update the path correctly.
Ya you need to manually correct duplicates and anomalies in the path.
Point to the "sdk" folder and tools of a valid most current adt-bundle-windows folder.
Maybe it was NetBeans that did this?
No it seems plausible when I put an update of Eclipse (C:\Library\Dev\Android\adt-bundle-windows-*) I must have not realized I needed to update the path too having done it manually the first time to get it to work.
It seems I needed plateform-tools added as well for adb to run the emulate command...
C:\Library\Dev\Android\adt-bundle-windows-x86_64-20131030\sdk;C:\Library\Dev\Android\adt-bundle-windows-x86_64-20131030\sdk\tools;C:\Library\Dev\Android\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;

Related

Cordova fails to find ANDROID_HOME environment variable

I looked all over Google and Stack Overflow for an answer, but I couldn't find the right one for me. I am learning Cordova and I'm trying to run the android emulator through terminal, and when I run 'sudo cordova emulate android' I get this message:
''Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Detected 'avdmanager' command at /Users/username/Library/Android/sdk/cmdline-tools/latest/bin but no 'tools/bin' directory found near.
Try reinstall Android SDK or update your PATH to include valid path to SDK/tools/bin directory.''
But I set the variables in the ~./bash_profile file and it looks like this:
export ANDROID_HOME="/Users/username/Library/Android/sdk"
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=${PATH}:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
export PATH=${PATH}:$ANDROID_HOME/tools/bin
export PATH="$PATH:$ANDROID_HOME/build-tools/30.0.0-rc2"
I am using a MacOS Mojave, does anyone know what the issue is?
Thanks in advance
Apparently, in the latest version of Android Studio, the old SDK tools (under /tools, which Cordova seems to expect) are already considered obsolete. There is a solution documented here on how to install the old version of SDK tools.
Open Android Studio
Open Tools -> Sdk Manager
Click on the Sdk Tools Tab
Uncheck Hide Obsolete Packages
Check Android Sdk Tools (Obsolete)
Click Apply
This should download the old SDK tools under the correct folder.
However, I think Cordova also needs to keep up with the newest Android development tools. There's another change I needed to make after this:
I had to delete the tools/emulator and tools/emulator-check binaries, and add $ANDROID_HOME/emulator to my $PATH, since the current emulator binary lives under emulator/emulator instead of path/emulator. See this post.
Then I was finally able to launch the app directly via Cordova.

sdkmanager updatesdk on Windows not work

I need to use the command line sdkmanager to update android tools. I must not use Android studio to do this.
However, if it works on Linux & Mac, it failed on Windows.
I received
"Warning: An error occurred during installation: Failed to move away or delete existing target file: C:\android-sdk\tools"
Why it doesn't work ?
Is there a way to perform this ?
See this other question: Can't update \tools - Android SDK Command Line Tools for Windows
Yeah that's quite funny. A way to do that is to copy the tools folder to another place (let's say C:\temp\). Then direct into the C:\temp\tools\bin\, open the cmd prompt there and run your update commands as such:
sdkmanager.bat --sdk_root=sdkRootPath --command
Where sdkRootPath is path to your original SDK folder (C:\testinstall\sdk\). Once that is done, delete the C:\temp\tools\ copied folder.

Can't update \tools - Android SDK Command Line Tools for Windows

I have just downloaded the Android SDK Command Line tools for Windows (26.0.2). I am attempting to download selected SDK components using \tools\bin\sdkmanager.bat, as well as updating \tools. The installation fails with the following message:
Warning: An error occurred during installation: Failed to move away or delete existing target file: C:\testinstall\sdk\tools
Move it away manually and try again..
I don't see how I can remove \tools manually because it contains \bin\sdkmanager.bat.
Screenshot of the sdkmanager command:
All other components appear to install without error. See below for the components specified in my package file:
Yeah that's quite funny. A way to do that is to copy the tools folder to another place (let's say C:\temp\). Then direct into the C:\temp\tools\bin\, open the cmd prompt there and run your update commands as such:
sdkmanager.bat --sdk_root=sdkRootPath --command
Where sdkRootPath is path to your original SDK folder (C:\testinstall\sdk\). Once that is done, delete the C:\temp\tools\ copied folder.
You could temporarily rename to tools.old, run it to install new version in tools and then remove the old one.
cd YOUR-ANDROID-SDK-LOCATION
ren tools tools.old
tools.old\bin\sdkmanager.bat "tools"
dir tools*
del tools.old /q /s
tools\bin\sdkmanager.bat --list
it might be permission issue.Can you try doing sudo or if you on windows try to run terminal as administrator.
I have seen issues where the program is not able to delete the folder either due to lock or some weird reason.
Run cmd in root c:.
c:\>testinstall\sdk\tools\bin\sdkmanager --package_file=c:\testinstall\packx.txt
I've had the same issue on windows, I couldn't even rename the directory that is causing the issue.
I found out that adb was still running and ended the process and update/install worked fine without workarounds.
The below command helped me to extract the SDK
sdkmanager "platform-tools" "platforms;android-28" --sdk_root=C:\AndroidSDK_RootLocation
It may not be the answer to your question but now, i can't exactly remeber the version, you can't update SDK tools directly or using Eclipse, sdk Manager, sdk.bat or android.bat, only way is to update them using Android Studio. It's Google's new policy, i read it somewhere, if i find the link i will share it
My solution was as following:
Delete the Android SDK Tools via Android Studio (although it might complain it failed).
Close Android Studio
Manually delete tools folder from C:\Users\<MyUsername>\AppData\Local\Android\sdk folder
Start Android Studio and then do the install of the Android SDK Tools via Android Studio.

The command 'android' failed

I've read this: Cordova and setting Android using command line
and that How to add android to cordova platform? PATH error? and generally speaking whole documentation. I've added both 'platform-tool' and 'tool' paths, installed android 4.4 and I'm still getting the error from the tittle when I'm trying cordova platform add android to my current project ( in cmd and in netbeans ).
The only thing I haven't done is adding java and ant to path. I was trying with ;%JAVA_HOME%\bin;%ANT_HOME%\bin but still those commands aren't recognizable.
What else can I do?
EDIT:
I've added java and ant to PATH. This is what I get in cmd:
C:\xampp\htdocs\mobile_maps>cordova platform add android
[Error: The command `android` failed. Make sure you have the latest Android SDK
installed, and the `android` command (inside the tools/ folder) added to your pa
th. Output: ]
Second EDIT:
i also get 'xcopy' is not recognized as an internal or external command even though I've added %SystemRoot%\System32; %SystemRoot%; %SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0 . I really don't know what else I can do..
usually this happens when:
1. Java is not installed
2. Java is not exported (no JAVA_HOME env variable) or paths are wrong
3. only 64bit version of Java is installed
to fix install 32bit support on your system.
and (as comments below) relog in Windows to environment changes take effect.

phonegap platform not working android

You can see I have SDK tools installed and the SDK platform installed.
I have no clue why I am getting the error below in the CLI?
I have already created the app, I following http://cordova.apache.org/docs/en/3.1.0/guide_cli_index.md.html#The%20Command-line%20Interface getting to the platform add step I am failing miserably. Maybe I don't have the android command ? If so how do I do that?
Is it because of administrator access(if so, how do I fix that), is it a path issue(again how do I fix it)?
I installed ant then I went into C:\Users\visum_000\.cordova\lib inside there I deleted the android folder, then tried the command again, here is what happened.
You see it downloaded but still gives the error.
It actually looks like you have installed the Android SDK properly on your box.
Have you adjusted your Path settings and added the Android tools path accordingly ?

Categories

Resources