I had built an angular application and wanted to turn it into a native android app using cordova.
I had previously installed android-sdk using apt-get which was added to by /usr/lib folder. I also had installed Android Studio separately who's sdk-tools were located in ~/Android/Sdk.
Previously, my $ANDROID_HOME variable contained path /usr/lib but after installation of Android Studio I had changed it to <myhomedirectory>/Android/Sdk
Previously, the android-sdk tools installed had version 23, which was incompatible with the newer version of gradle, and gave me the following error upon running cordova run android (with sudo) in my project:
WARNING: The specified Android SDK Build Tools version (23.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.0.
Android SDK Build Tools 28.0.3 will be used.
Followed by the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /usr/lib/android-sdk
The Android Studio I installed had tools installed for both API 28 and API 29, but I did not know why it was still giving me this error, until I noticed the last line of this error, which stated that my Android SDK is being fetched from /usr/lib (the old directory). I tried checking the environment variables again, sourcing the ~/.bashrc, as well as logging out but nothing really worked.
I decided to remove the previously installed android-sdk and purge the files using apt but even then nothing happened.
I even removed the mobile folder (the project folder for cordova I created) and even restarted from scratch, but it still gave me the same error.
I am unsure why it is still picking up the wrong path from environment variable, I've even echo-ed the variable and the path is the one I set just recently, but cordova for some reason seems to disagree.
There was an issue with the permissions in the cordova project. Had to sudo chown -R <myproject>. I first noticed when I tried sudo cordova requirements instead of cordova requirements (which said I had all requirements installed). I noticed these installations were on user level not on root level, which is why upon sudo it was giving me an error. After chown-ing simply run cordova run android. You'll no longer have issues.
I'm struggling to get my development environment set up for Apache Cordova. I'd like to target an Amazon Fire HD 7 running Fire OS 5.3.6.4 (626532920).
Wikipedia tells me that:
The releases are chronologically sorted and categorized based on the underlying version of their Android codebase.
So I'm assuming that this is built on Android 5.1.1 Lollipop?
Project setup
I first installed Cordova using
yarn global add cordova
I then generated a new project using
cordova create hello_world com.mycompany.hello_world HelloWorld
I added Android as the intended platform using
cordova platform add android
(which installed cordova-android#~7.1.1)
Requirements
After running cordova requirements I received the following:
Requirements check results for android:
Java JDK: not installed
Failed to find 'JAVA_HOME' environment variable. Try setting it manually.
Android SDK: not installed
Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
Android target: not installed
android: Command failed with exit code ENOENT
Gradle: not installed
Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.
Might need to install Android SDK or set up 'ANDROID_HOME' env variable.
Some of requirements check failed
I resolved (most of) these issues as follows:
Java JDK
I installed Java 8 using brew cask (as later versions of Java don't seem to be compatible)
brew tap caskroom/versions
brew cask install java8
Android SDK
You first need to create the empty repositories config, otherwise the later steps will fail
touch ~/.android/repositories.cfg
This then left things looking a lot healthier as far as cordova requirements is concerned:
Android Studio project detected
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
No android targets (SDKs) installed!
Gradle: installed /usr/local/Cellar/gradle/4.10.2/bin/gradle
Some of requirements check failed
However I'm struggling with how to set up an Android target for this device.
I think I need to run something like
sdkmanager "platforms;android-27"
But I'm not sure which version of Android I should be using. There is a handy table on the Cordova site but it doesn't make a whole lot of sense to me...
Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
This is the problem
Cordova cant acces to the SDK even it is installed , i dont know how to change the default location but i have tried to create the android_home variable but it didnt work .
This problem is connected with actualization of Android. Android depreciated his tool: android, you can check it typing android in command line. You should see:
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Invalid or unsupported command ""
Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk
You can solve it updating cordova
npm install -g cordova
and android platform in cordova
cordova platform rm android; cordova platform add android#6.2.3
Source
Cordova: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable
Hi Guys I have been having trouble on setting up my android sdk on my Fedora23 OS this is for a Cordova development. I have checked my Environment Variables on my terminal using echo $ANDROID_HOME and verifying whats installed correctly using cordova requirements command and this is the result it gave me
Requirements check results for android:
Java JDK: installed .
Android SDK: installed
Android target: not installed
Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
Gradle: installed
Requirements check results for ios:
Apple OS X: not installed
Cordova tooling for iOS requires Apple OS X
Error: Some of requirements check failed
How come that the Android Target was not installed while Gradle was installed?
and also how come whenever I tried to use android commands its not working
have I did something incorrect? this is how I setup my android sdk
I downloaded the android-sdk from Android Studio's site
I extracted it using tar command
Moved it to /opt/
Added the android sdk home to my environment at /etc/bashrc
its been two days now and I still dont have it running someone help please
UPDATE
inside my bashrc are the ff:
ANDROID_HOME=/opt/android-sdk-linux/
export PATH="$HOME/opt/android-sdk-linux/android-sdk/tools:$PATH"
export PATH="$HOME/opt/android-sdk-linux/platform-tools:$PATH"
export ANDROID_HOME
I think your bashrc should be
ANDROID_HOME=/opt/android-sdk-linux/
export PATH="/opt/android-sdk-linux/android-sdk/tools:$PATH"
export PATH="/opt/android-sdk-linux/platform-tools:$PATH"
export ANDROID_HOME
I am following an official NativeScript tutorial and having a problem configuring my OS X environment for android development.
When running tns platform add android I receive the following error:
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 21 or later.
The tns doctor command also returns warnings on android-sdk issues:
Cannot find a compatible Android SDK for compilation. To be able to
build for Android, install Android SDK 21 or later. Run $ android to
manage your Android SDK versions. You need to have the Android SDK
Build-tools installed on your system. You have to install version 22.
Run "android" from your command-line to install required Android Build
Tools. You need to have the latest Android Support Repository
installed on your system. Run $ android to manage the Android
Support Repository.
My android-sdk installation looks like this:
My .bash_profile also includes the followings:
export ANDROID_HOME="/usr/local/Cellar/android-sdk/24.3.4/"
export PATH="$PATH:~/npm-global/bin:/usr/local/Cellar/android-sdk/24.3.4/tools:/usr/local/Cellar/android-sdk/24.3.4/platform-tools"
Should I go further and try setting system-wide environment variables - not just for the .bash_profile? Also, it is possible that I missed something from the setup process...
Any tip on how I could debug this situation (commands, config files etc.) would be great, thank you!
Alright, so you need to make sure of following:
Make sure you have API 22 installed.
Make sure you you have Android SDK Build Tools 22.x.x installed. (Yes,
specifically 22.x.x)
Make sure you have Android support repository installed. (You can
find it under Extras section in Android SDK Manager)
Once you have performed steps mentioned above, run tns doctor again and you should see No issues were detected message.
This is because of sudo. The root user has no ANDROID_HOME set.
For Windows User:
Run 'android update sdk' from command line
Select Android 5.1.1(API22)
Select Tools folder
Select Extras and click on Install.
ps:- adding this answer, so that if any one land on this page can see it.
Check the ANDROID_HOME is ok
Install the API 22 + ion the Extras > Android Support Repository
Run the following
tns platform remove android
tns platform add android#next
Run
tns run android
then it should be OK
I solve this problem installing Android Support Repository from Extras.
updating SDK in AndroidStudio >> Preferenceswould help
on my windows 10 machine I had to open file explorer right click on this pc and go to properties on the left hand side I had to go to advanced settings. At the bottom I click environment variables then on the android_home variable I clicked edit then pointed it to this path on my machine where the sdk was installed
C:\Program Files (x86)\Android\android-sdk
This answer is on a Linux, not OSX, platform. However, since this is the SO that appears most often for the listed error, I'll share a recent fix that worked for me.
If you have done all of the above and are still getting the error, try this solution.
I am using NativeScript 8.0.2.
You will know that ANDROID_HOME and Java are configured correctly if you can run the command $ANDROID_HOME/tools/bin/sdkmanager --list. If that fails, then first check that your Java is compatible (I had to add OpenJDK 8 and change my PATH with export JAVA_HOME="/usr/lib64/jvm/java-1.8.0/")
In Android Studio, add a previous build tool version. Go to your SDK Manager > SDK Tools, tick the bottom box "Show package details", and add a previous version. In my case, 31.0.0 was the latest, and I added 30.0.3. Now run ns doctor android again and everything should pass.
Seems 31.0.0 is not yet properly recognised by Native Script.
I always got the error "✖ Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 28 or later. "
I actually had to go to the android studio settings and install the exact SDK 28 before this error went away.
Android Settings Pic
This is an updated answer, I also had the same issue:
Like all the previous pictures above, I had to install the SDK platforms, using the SDK Manager. From the main screen of Android Studio, click More Actions and choose SDK Manager. Before that I had to add the platform-tools to my PATH in Windows
%LOCALAPPDATA%\Android\Sdk\platform-tools
That fixed my issue and the docs for setup are here.