SDK Location not found although ANDROID_HOME is set - android

I am trying to build an Android app using Gradle on Ubuntu 18.04. Android Studio is not installed o the machine (I use Eclipse for development but maintain a gradle toolchain).
The toolchain has worked on a different machine running Ubuntu 16.04. However, it does not work with gradle 3.4.1, which ships with 18.04, so I had to upgrade my build config. On the 18.04 machine, I changed the dependency
classpath 'com.android.tools.build:gradle:2.1.2'
to
classpath 'com.android.tools.build:gradle:2.3.0'
and changed
buildToolsVersion "23.0.3"
to
buildToolsVersion "25.0.3"
Now when I run gradle build, I get the following error message:
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
However, I have ANDROID_HOME set and pointing to ~/bin/android-sdk-linux, which is the root dir of my Android SDK setup. Also, I have Android SDK build tools 25.0.3 installed locally.
What gives?

Apparently Gradle does not honor ANDROID_HOME, despite the error message saying otherwise.
As a workaround,
echo sdk.dir=$ANDROID_HOME >> local.properties
in the project root dir has fixed this (after also ensuring I was using the correct JDK version and had all submodules checked out).
Oddly, however, on a different computer (also running Ubuntu 18.04) the same app builds without local.properties being present.

If there is no local.properties, just go ahead and create one in parallel to gradle directory.
Then add this line,
sdk.dir=/Users/YOUR_USERNAME/Library/Android/sdk

Related

cordova: "Android SDK: not installed"

I know there are many threads like this but none of them helped.
I am using Windows 10, Cordova 7.1.0 (latest version) and I have installed Android Studio with SDK Platform 7.1.1 - API level 25 (also tried downgrading to 7.0 - API level 24). Also, I installed SDK build-tools using Android Studio SDK Manager.
Running:
cordova info
I get this message:
Android SDK is not set up properly. Make sure that the Android SDK
'tools' and 'platform-tools' directories are in the PATH variable.
'android' is not recognized as an internal or external command,
operable program or batch file.
Running
cordova requirements
I get this message:
Android SDK: not installed
Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually. Detected 'adb' command at
C:\Windows but no 'platform-tools' directory found near. Try reinstall
Android SDK or update your PATH to include valid path to
SDK\platform-tools directory. Android target: not installed cmd:
Command failed with exit code 1 Error output: 'android' is not
recognized as an internal or external command, operable program or
batch file. 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.
I also tried to install manually the SDK, without Android Studio, but it did not help. I am not used to working with CLI's so I may be missing something.
However, I tried upgrading Cordova, downgrading SDK and installing the latter manually. I was also confused with environment variables, I tried some things I read but none worked. Any help, appreciated.
I figured it out.
Seems that in my case, Java JDK 9 was causing the problem. Downgrading to JDK 8 gave me the solution.
In addition, I hadn't set the ANDROID_HOME variable correctly but even when I did, it did not work until downgrading to JDK 8.

Failed to find Build Tools revision 23.0.1

I am trying to build my first app with react-native.
I am following these 2 tutorial:
https://facebook.github.io/react-native/docs/getting-started.html#content
https://facebook.github.io/react-native/docs/android-setup.html
I am sure that I installed all the requirements from the second link but when I try running my app with react-native run-android, I get the following error:
I executed this command while running genymotion.
This is all that I have installed in Android SDK:
I tried to install Android build tools 23.0.1 but I get this error:
What should I do?
You should install Android SDK Build Tools 23.0.1 via Android SDK. Don't forget to check Show Packages Details.
I faced the same problem and I solved it doing the following:
Go to /home/[USER]/Android/Sdk/tools
and execute:
$android list sdk -a
Which will show a list like:
Android SDK Tools, revision 24.0.2
Android SDK Platform-tools, revision 23.0.2
Android SDK Platform-tools, revision 23.0.1
... and many more
Then, execute the command (attention! at your computer the third option may be different):
$android update sdk -a -u -t 3
It will install the 23.0.1 SDK Platform-tools components.
Try to build your project again.
Either install v23.0.1 of the build tools (the fifth row in your screenshot), or change your code to use the build tools version you already have installed (v23.0.3). This can be specified in your app's build.gradle file:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
...
}
}
As per duncanc4's comment below,
The build.gradle file you want to edit is in the android/app folder
within your project directory.
The error you're getting seems to be related to system's permissions, since it's not able to create a folder.
Try running the sdk-manager using root (with su or sudo commands).
I had this error:
Failed to find Build Tools revision 23.0.2
When you got updated/installed:
Android SDK Build Tools
Android SDK Tools
Change version number in build.gradle
FROM
buildToolsVersion "23.0.2"
TO
buildToolsVersion "25.0.2"
How to find what Build Tools version you have
Check your $ANDROID_HOME, sometimes is /usr/local/opt/android, but it's not your install sdk path, change it and fix this problem
Nothing helped until I found this solution : https://stackoverflow.com/a/39068538/3995091
In Android SDK, the build tools with the correct version where shown as installed, but still I got the same error saying they couldn't be found. When I used the above solution, I found out they were indeed not installed, although Android SDK thought they were. Installing them solved it for me.
While running react-native In case you have installed 23.0.3 and it is asking for 23.0.1 simply in your application project directory. Open anroid/app/build.gradle and change buildToolsVersion "23.0.3"
In the Gradle Console (link available in the window bottom right), you have two tabs: the error is shown in Gradle Build tab. Click on the Gradle Sync tab, then click on the Install Build Tools XX.X.X and sync project link. This will download the build version required by your project.
You may also change your project SDK version but you don't always have this option if it is imposed.
If you already install the correct Android SDK Platform-Tools (Build Tool) and you still get an error, try to invalidate the cache; File -> Invalidate caches / Restart....
On my system, Android SDK Manager showed /usr/local/Cellar/android-sdk as the SDK path, when $ANDROID_HOME was /Users/james/Library/Android/sdk. I just added a symlink for the correct build tools version.
Two solutions: You have to instal the required buildToolVersion or set it as described above.
Notice that if you are trying to set the buildToolsVersion "23.0.3" using Android Studio 3.0 or more it won't work until you remove all builversion you have keeping just one last version you use.
I read this somewhere else and this works for me.
Hope this helps.
As the error says
Failed to find build Tools revision 23.0.1
This means that in your project you have used
buildToolsVersion "23.0.3"
So,You need to download the exact same version this makes the error disappear
**Step 1:**
GO to Tools and click SDK Manager
**Step 2:**
you can see SDK Platforms ,SDK Tools and SDK update Sites
**Step3:**
Click SDK Tools and click show package details
**Step 4:**
Select the version that you have mentioned in your Project
These Steps has solved my issue.
If anyone can't build their downloaded source code (probably google codelabs source code) with Android Studio, try simply remove the buildToolsVersion from the build.gradle file, and Android Studio will build the project with it's default latest buildToolVersion
¯_(ツ)_/¯
Each version of the Android Gradle Plugin now has a default version of the build tools.
So, probably you specified build tool version explicitly in the build file.
Just remove buildToolsVersion = "x.y.z" from your build.gradle script.
If, for some reason, you need that specific revision, follow the other answer.
Just install it from Android Studio ;)

Android Studio update 0.5.3 - platform 'android-19' not found

Yesterday I opened Android Studio and it asked me to be updated. I now have v0.5.3, SDK 19 fully installed and gradle 0.9.+. I think this information is correct but I'm not fully aware how the gradle strategy works.
The problem is that my gradle apps stopped syncing and even when I create a brand new project it does not sync.
Here are the details:
Project's build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
App's build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
In SDK Manager I have all the builds installed including 19.+.
The error I get when syncing:
Failed to set up SDK
Error:Module 'app': platform 'android-19' not found.
Information:Double-click here to open Android SDK Manager and install all missing platforms.
I know that if I change
compileSdkVersion 19
to
compileSdkVersion 18
in the app's build.gradle it works... but I don't think that's the solution.
Thanks!
I had the same problem.
Deleting ~/.AndroidStudioPreview (on Debian GNU/Linux 'sid') fixed the problem. This directory was from an older version of AS (0.3.x). I don't know what the equivalent of the GNU/Linux ~/.AndroidStudioPreview is on Windows/Mac OS X/... (for Windows it's under C:\Users\<user>\.AndroidStudioPreview\).
Deleting the following fixed my problem -
~/Library/Caches/AndroidStudioPreview
~/Library/Logs/AndroidStudioPreview
~/Library/Preferences/AndroidStudioPreview
Update your Android SDK tools to version 22.6.2, and install android-19. It worked for me!
Go to your Module Settings and set project SDK.
Had this problem too in 0.5.3 and the only way I could fix it was to downgrade to 0.5.2.
Even though I added the SDK manually in the project structure window, it would not import android class files properly.
0.5.2 is available here: http://tools.android.com/download/studio/canary/0-5-2
Delete your .AndroidStudioPreview folder and run Android Studio again.
Unfortunately you will lose your settings.
I was able to just open the SDK Manager and install the updates it found. I had installed new things recently, yet it found six new packages to install. My guess is the new version of the SDK tools is what fixed the gradle problem. Works fine now. No downgrade, no hidden file deletions.
Wait, I was installing 0.5.4 not 3.
Just found out that updating the SDK platform 19 to revision 3 solved this problem for me.
For instance I'm using Android Studio 0.5.4 as well.
Go to the SDK manager and install Extras -> Android Support Repository
I had the same problem but my reason was because I had two SDK Managers and my Android Studio had the wrong SDK Manager directory.
The first SDK Manager was from my Eclipse-Android SDK that I installed a few years back. The directory it is located in is C:\Program Files (x86)\Android\android-studio\sdk
The 2nd SDK Manager was for my Android Studio. The directory it is located in is C:\Users\Gene\Android SDK\sdk
In Android Studio, go to File -> Project Structure. On the left tabs, choose “SDK Location”. Make sure you’re pointing the project at the right SDK Location.
If you need to access the SDK Manager for Android Studio in order to download more APIs, you might need to right click on “SDK Manager.exe” and then click “Run as administrator” in order for you to get it to work.
Whatever SDK Manager you are using, make sure you downloaded the API for it before you set "compileSdkVersion" (in gradle) to that API version.
I have the same issue just that i cannot change form version 19 to 18. Even though I have both versions installed. I use Android Studio version 0.5.4. One person at the office has the same setup without any problems on the same project. The fix with deleting the folder .AndroidStudioPreview works for one project, but then another I work on breaks.
Had the same problem after clean install of Android Studio 1.1.0 on OSX Yosemite. Deleting folders did not work. What did work was simply run sudo android, from terminal.
Easiest solution is to follow this.
After updating android studio create a brand new project. Then after successfully creating it open the graddle file(Module App).
Then check the Compile SDK version and Build Tools Version.
Then copy the same version numbers to your existing project and sync.
Click File - > Invalidate cash from the menu. It should upgrade your Android project in to the latest version resolving all the conflicts.
Build tools and Android SDK platform are two different things. When Gradle tells you that you miss android-19, it means that you did not get the latest version of the Android SDK (level 19)
You need to install this version.

Import of Eclipse project into Android Studio using build.gradle file fails

I'm trying to import my Eclipse based Android project using the build.gradle file. I get the following message: "failed to find Build Tools revision 18.0.0". However, according to the Android SDK Manager, I have Android SDK Build-tools 18.0.1 installed.
I am doing all this on a 64-bit Windows 7 machine, if that's relevant.
How do I fix this?
UPDATE: I actually only updated to Build-tools 18.0.1 this morning. I then noticed that, when making a new project in Android Studio, it wouldn't allow me to create a project using Android 4.3 (4.2.2 was the latest allowable version). I tried dropping the target version of my project to Android 4.2.2, and re-exporting it. Now Android Studio complains about not being able to find Build-tools 18.0.1 when I try to import this project.
I was an Android Studio virgin too up until 10 minutes ago. I ran into the same problem. If you check your SDK Manager in Android Studio (or Eclipse I believe) it will show which tools you have installed. I am/was missing build tools 18.0.1 too and getting the error....but it was because I hadn't installed them.
So without modifying the Gradle build files, I was able to install the build tools using the SDK Manager and get everything up and running.
See this image:
As an aside, I also had to update the API version as well because it selected an API version that wasn't installed (which I don't get because it was when I compiled with Eclipse).
Hope this helps.
This did the trick for me.
In build.gradle file inside the main module modify the line
buildToolsVersion "18.0.0"
to
buildToolsVersion "18.0.1"
I'm very new to Android Studio (as of last night). I encountered the same problem. I opened up the 'build.gradle' file and modified the lines with: "compileSdkVersion 18" and "buildToolsVersion 18.0.1" to 17 and 17.0.0 respectively. It seems to do the trick!
you must make sure the build.gradle file contains the same version of the installed build tools.
you can find this out by looking in the /sdk/build-tools/android-X.Y.Z/source.properties file under the Android Studio installation
e.g.
Pkg.UserSrc=false
Pkg.Revision=18.1.1
then plug that revision number into the gradle build file:
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
...
}
I had issues with Gradle too. A full delete and install the latest version fixed it.
I also had the same problem then I have checked my Enviornment Variable and it is pointing to my old sdk which does not have Build tool 18.0.x After pointing it to new sdk everything goes well.

What Type of error is it? [duplicate]

When I boot up Android Studio and select "New Project..." and go through creating a new project, I get this popup error:
Failed to import new Gradle project: failed to find Build Tools revision 17.0.0
Consult IDE log for more details (Help | Show Log)
I would love to consult the IDE log, but I haven't even managed to get into the application to do much of anything. I've went through the preferences multiple times to see if I can set a path for the Build Tools, but I can't find much of anything. How do I fix this, or how do I get into the application without opening a project so I can at least see the logs?
After spending a few hours: I restarted the Android SDK Manager and at this time I noticed that I got Android SDK Platform-tools (upgrade) and Android SDK Build-tools (new).
After installing those, I was finally able to fully compile my project.
Note: The latest ADT (Version 22) should be installed.
As of May 2020, A really straightforward solution using Android Studio:
Open Android Studio
From the top, choose File > Settings > Appearance & Behavior > System Settings > Android SDK
click on the tab SDK Tools at the top. Then highlight Android SDK Build Tools from the list.
Check "Show Package Details" check box, choose the build tools version you need and then click Apply.
Look in the SDK Manager what is your highest Android SDK Build-tools version, and copy this version number in your project build.gradle file, in the android/buildToolsVersion property (for me, version was "18.1.1").
Hope it help!
This is what I had to do:
Install the latest Android SDK Manager (22.0.1)
Install Gradle (1.6)
Update my environment variables:
ANDROID_HOME=C:\...\android-sdk
GRADLE_HOME=C:\...\gradle-1.6
Update/dobblecheck my PATH variable:
PATH=...;%GRADLE_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Start Android SDK Manager and download necessary SDK API's
It happens because Build Tools revision x doesn't exist.
Today, the latest version is 23.0.2 (subject to change all the time).
The buildToolsVersions you want are included in the Android SDK, normally installed in the <sdk>/build-tools/<buildToolsVersion> directory.
Don't confuse the Android SDK Tools with SDK Build Tools.
Change in your build.gradle's buildToolsVersion to some version installed in <sdk>/build-tools
android {
buildToolsVersion "23.0.2"
// ...
}
Whenever you will try to run a project with build tool version not present in studio, You will face this error.
As of now in 2017, It has been made really simple by Android Studio.
It will prompt you about this issue, along with something like this
You just have to click on it and the system will download to the build version required to run the project.
I had the API 17 installed but that was not enough. What I really need installed is the "Android SDK Build-Tools 17".
You can locate your "Android SDK Build-Tools X" inside the first child, named "Tools", in the "Android SDK Manager".
in your Project perspective, look for Application --> build.gradle and edit this lines
android {
compileSdkVersion "android-N"
buildToolsVersion "24.0.0 rc1"
like this:
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
I had this problem recently, my project didn't include local.properties file.
Check local.properties file if it includes sdk.dir with correct path to sdk
i think you can download the latest android SDK and use it.i do this and fixed the problem and work well.
here is the link:
http://developer.android.com/sdk/index.html#download
Try to run gradle at the command line first. It might prompt you to setup and environment variable:
export _JAVA_OPTIONS="-Xms256m -Xmx1024m"
Read more here: 1, 2
Further make sure that the Android SDK build tools (adb, aapt, dx, dx.jar) are available in the PATH. If not you can create symlinks at the appropriate locations. They changed with the release of new SDK versions. Here is a shell script which creates the symlinks within the $ANDROID_HOME folder for you.
Basically error saying your are missing "Android SDK Build-tools" installed.
This worked for me after I tried many solutions:
For some reason the adb process didn't restart itself after installing new packages. Manually killing adb.exe and attempting to import the project another time solved this problem for me.
Uninstall the Android SDK Tools and then reinstall them from Tools > SDK Manager.

Categories

Resources