After updating to Android Gradle plugin 3.6.0 (released Feb 24, 2020), several project independently started failing with:
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669
It's quite simple to "fix" this locally by installing the older expected ndk version:
sdkmanager 'ndk;20.0.5594570'
However, my question is: Where and how is this older version specified? And how do I update it so it matches the latest version 21.0.6113669?
The following solutions assume that the machine you are using currently has NDK installed and was previously able to build your project but started failing with the error "No version of NDK matched the requested version" after updating to Android Gradle plugin 3.6.0. Before proceeding make sure to have NDK installed.
Option 1:
You can simply select your locally installed NDK in the Project Structure Dialog
You can open the Project Structure Dialog by clicking File > Project Structure... or by pressing the hotkeys CTRL + ALT + SHIFT + S (on windows)
Once the Project Structure Dialog is open, go to SDK Location and select your locally installed version of NDK under Android NDK Location. Typically this is installed somewhere in your user folder then \AppData\Local\Android\Sdk\ndk\%ndk version% at least for Windows.
- from Android Studio 3.6 Build #AI-192.7142.36.36.6200805, built on February 12, 2020
Option 2:
Doing option 1 will edit your local.properties file for you and will work in most cases. But if you want to use a consistent NDK version on all machines you build the project with, according to this official guide, you can configure it from your module gradle script. Simply add the ndkVersion in your module gradle script's android{} block like so.
android {
ndkVersion "major.minor.build"
}
replacing the string between the doublequotes with the NDK version you want to use
Option 3:
If you want all projects built on a particular machine to use the same NDK version, you can also set ANDROID_NDK_HOME environment variable with the path to the NDK folder.
I have the same issue. I resolved it through the SDK manager under SDK Tools, click Show Package Details and then scroll under NDK (Side by side) and tick and apply the version you need. See image below:
My question for anyone is, why do we need this now for projects that do not require the NDK? As it turns out the NDK is a pre-existing requirement in the project I work on for a dependency!
It isn't necessary with Android gradle plugin > 4.1.0 (see also https://issuetracker.google.com/issues/144111441)
With < 4.1.0 I run into this too
No version of NDK matched the requested version 20.0.5594570. Versions
available locally: 21.0.6113669
Option 1:
You can simply select your locally installed NDK in the Project Structure Dialog works !
But is only valid for local builds, an I need a solution for CI
Option 2:
It's only works, when you specify it in every used module
android {
compileSdkVersion 28
ndkVersion "21.0.6113669"
...
}
Here it seems not to work https://github.com/hannesa2/panoramagl/pull/17/checks with this change https://github.com/hannesa2/panoramagl/pull/17/files#diff-cff4e8c294a5dc5e76308662ae1ddcacR6-R7
Option 3:
export ANDROID_NDK_HOME=/Users/{my-user}/Development/adt/sdk/ndk/21.0.6113669
works too as well !
To answer the part of your question not answered by others, "Where and how is this older version specified? And how do I update it so it matches the latest version 21.0.6113669?":
The default version is set by the Android Gradle plugin. Each version will default to whatever version of the NDK that we used during testing to guarantee the best possible compatibility.
The difference between this and earlier plugin versions is that it used to happily use any NDK that you happened to have installed. This caused a ton of "works on my machine" issues for users where their co-workers couldn't build the project, it wouldn't work on CI but would locally, etc. It wasn't a good situation.
You can pick a specific version of the NDK to use in your project by setting android.ndkVersion in your build.gradle. if you don't, it'll try to use the default version for the Gradle plugin that you're using.
The annoying bit is that most versions (until 4.1) will not automatically download the default version, which gives you the error you're seeing. If you explicitly pick a version in your build.gradle it actually will download automatically, and with 4.1 it will automatically download the default version too.
A thing that often confuses people is why this hits them when they're not using the NDK, or at least believe they are not. The answer in that case is that one of your dependencies includes native libraries and these need to be stripped before they are packed into the APK to keep size down, and strip comes from the NDK.
This worked for MacOS, check via Terminal:
cd ~/Library/Android/sdk
ls
If you see "ndk" and/or "ndk-bundle", delete them:
sudo rm -r ndk/
sudo rm -r ndk-bundle/
After deleting those folders, everything worked for me.
This is copied from GitHub
In the last version of Gradle there is no need to define the NDK versión inside the build.grade :
android {
...
ndkVersion "21.0.6352462"
...
}
We must install the suggested versión
or define the current available version into the Android NDK Location:
replace gradle classpath with this in Project level build.gradle
classpath 'com.android.tools.build:gradle:4.1.0'
in gradle-wrapper.properties add this line
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
I faced the same problem. Then i found the developer references here
So, the problem start with gradle version 3.6. Before 3.6 there was no default ndk specified. So, any version of ndk worked without any problem. But after adding default version, if we not add any ndkVersion in build.gradle then it search for the default version of ndk.
In my case, my gradle version was 3.6.3 and ndk installed 21.0.6113669 and i did not defined ndkVersion in my build.gradle. So, it search for default ndkVersion "20.0.5594570" according to my gradle version and gave me the same error. So, i simply add ndkVersion "21.0.6113669" in my build.gradle file and error gone.
In order to solve this problem, you must indicate to your IDE the version of your NDK in build.gradle. In this case, it should be version 21.0.6113669. For example:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.remed_mobile"
minSdkVersion 16
targetSdkVersion 28
ndkVersion '21.1.6352462'
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
If you do not indicate your version number, then the IDE takes a default version. If you've upgraded gradle, then it might not find the right version.
Add this line in build.gradle(app)
android {
ndkVersion "21.0.6113669"
}
This will solve the problem
https://github.com/gradle/gradle/issues/12440#issuecomment-606188282
This workes for me
edit local.properties file to add this
ndk.dir=/xxxxx/Android/sdk/ndk-bundle
Android Studio -> Preferences -> System settings -> Android SDK -> Got to SDK tools and remove NDK(Side by Side) and apply.
ndkVersion "21.0.6113669" /// <<---Add this in your android -> app -> build.gradle file.
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
ndkVersion "21.0.6113669"
i had same problem, after a while i found a temporary solution.
rename ndk folder to ndk-bundle.
in your projects go to local.properties file and add this line before sdk.dir:
ndk.dir=<path to your ndk folder>
its mine:
ndk.dir=G\:\\SDK\\ndk-bundle
sdk.dir=G\:\\SDK
i hope it help you
I also got below error
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.3.6113669
I just added my local NDK version to App level build.gradle file its solved.
android {
ndkVersion "My Available version here" (my case it 21.3.6113669)
}
flutter clean
flutter pub get
After upgrading to gradle:3.6.0 (or later). Try renaming or deleting the ndk and ndk-bundle folders located in C:\Users\<user>\AppData\Local\Android\Sdk
Credit goes to:
https://github.com/gradle/gradle/issues/12440#issuecomment-601214647
Change your classpath version to 3.5.0 inside your build.gradle, project level.
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
I have the same issue and it solved.
Open your module's build.gradle file and edit :
android {
**ndkVersion** "version number of you NDK"
}
No version of NDK matched the requested version 20.0.5594570
Here I got solution
1====>first download NDK if you don't have
2====>Rename your NDK as your Project need (like here I need 20.0.5594570)
3====>After that in android folder open gradle.properties file
here you put your ndk location like this
then do react-native run-android... that's it
NDK issues resolved
thanks you!
If you have trouble finding an exact version of NDK you can download it from here, it was the case for me my IDE required version 21.1.6352462 while this version no longer exists on the official site (https://developer.android.com/ndk/downloads)
All Android NDK Native Development Kit by API,Version and OSes
go to your app's build.gradle file;
in android{ } add your ndk version available, this shows in your error info you post. In this case, your version is "21.0.6113669"
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669
android {
ndkVersion "21.0.6113669"
}
I found this problem in as fox or 4 In X.
In the root directory of OS, open and hide Gradle folder
add file gradle.properties
add code
ndk.dir=/Users/your os name/Library/Android/sdk/ndk
doen~
first install NDk from android studio and Tools>sdk manager>sdk tools than download ndk version and
than in your local.properties set ndk path
like this:
ndk.dir=/Users/{yourUserName}/Library/Android/sdk/ndk/21.4.7075529
I couldn't install the specified version (a weird error from android studio, it might be related to the Silicon chip), so I specified a newer version of ndk in my build.gradle and everything worked.
[My Error: requested ndk version 22.0.7026061 did not match the version 20.0.5594570 requested by ndk.dir]
MySolution: There seems to be different ndk versions pointing out in different places
Please find below details for the same: Please go to
Project Structure=> SDK Location=> NDK Location(make sure to check one proper ndk version)
2)Project Structure=>Modules=> under NDK Version(check the same version you have added in first step)
PFA image forStep2
3)Gotoyour Android studio project=> go to local.properties file=> check your ndk version number
If all 3 steps are proper with one current proper NDK version your error would have solved.
Note: make sure to sync the project files, clean project, rebuild the project.
Hope this would solve your problem!! Happy Coding:)
Related
I am upgrading Android studio and Android gradle plugin to 4.1.3 and gradle to 6.8.3. I am using some protection for my code, which has its own special NDK 16b, which works with it without problems.
But that means, that I need to put this "security NDK 16b" to specific location and then tell the path to Android studio.
I have ndk.dir=myPath\android-ndk-r16b in my local.properties file. With the upgrade I can still build successfully, but there is new warning:
WARNING: NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please use android.ndkVersion or android.ndkPath in build.gradle to specify the NDK to use. https://developer.android.com/r/studio-ui/ndk-dir
So I tried to use android.ndkVersion or android.ndkPath to point to ndk like this according to android docs (in my app build.gradle):
android {
ndkPath 'myPath/android-ndk-r16b' // Point to your own NDK
ndkVersion '16.1.4479499'
/// other stuff
}
but then it shows this error:
NDK at "pathToSDK\sdk\ndk-bundle" did not have a source.properties file
It searches for ndk in default Android studio path, so it seems, it does not use ndkPath property at all...
Should I use the ndkPath property in a different way? Does it work for someone?
I have updated Android Studio to 4.1 in Macbook but not able to run app after updating. It is giving following error
Execution failed for task ':app:stripDebugDebugSymbols'.
NDK at ~/Library/Android/sdk/ndk-bundle did not have a source.properties file
and don't forget to mention latest ndk version if you seleted
android{
ndkVersion: '25.1.8937393'
}
After specifying ndk version in build.gradle file it is working
android {
ndkVersion '21.3.6528147'
}
And inside local.properties remove the following since it's deprecated and also conflicts with path:
ndk.dir=~/Library/Android/sdk/ndk-bundle
I had the same issue and solve it :
Go to SDK location find NDK folder and check the folders if one of them is empty or corrupted delete it and let the android studio use the latest version you have.
I had this error in Flutter.
my solution:
copy file C:\Users\username\AppData\Local\Android\Sdk\ndk\22.1.7171670\source.properties
to
C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle
Ready!
For Android studio 4.1.1+ (gradle-plugin: 4.1.1 or above) use ndkVersion
No ndk.dir at local.properties. If there is, remove it
build.gradle (module)
android {
defaultConfig {
// ...
ndkVersion = "21.1.6352462"
}
}
Note: The specified version must exist at $SDK/ndk folder.
File -> Project Structure -> SDK Location -> "Android NDK Location"And click "Download" Android NDK. The problem will be solved after downloaded.
For me, this issue occurred after I upgraded to Android Studio 4.1. To fix this, I had to explicitly pass the path of my NDK directory in my project's local.properties file. It can be done by adding this line in local.properties.
ndk.dir={Path to Android NDK directory}
In my case I don't have ndk dir in the local.properties file and also didn't add ndk version in the build.gradle. I just simply deleted the ndk-bundle folder in the android sdk folder. and it worked.
add ndkversion
ndk.dir=C:\\Users\\Hasif\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670
download NDK in setting, fix that issue.
If you cant click Download. manually add this path to your local.properties file
ndk.dir=/Users/yourusername/Library/Android/sdk/ndk/21.3.6528147
21.3.6528147 --> version your NDK folder
This is random error from AS, which is encountered by few developers.
Most likely, you don't have NDK linked in your Android Studio.
I would suggest,
In your Android Studio, Go to File -> Project Structure -> SDK Location -> Under "Android NDK Location", click on "Download" Android NDK
Wait for download and re-build the project. Cheers.
Go to project structure then
Download the the NDK and rebuild the app.
This solution works for me.
I am not sure about other cases but in my case, i facing the same issue
NDK at D:\Android\sdk\ndk-bundle did not have a source.properties file
And by deleting ndk-bundle folder and then rebuilding the project solved my issue
Hope anyone else gets this helpful
Android studio 4.1.1 can not set Android NDK Location on Project Structure,
you need edit local.properties file and add
ndk.dir=/Users/yourname/Library/Android/sdk/ndk/21.3.6528147
on build.gradle file ndk version is:21.3.6528147
ext.versions = [
'minSdk': 19,
'targetSdk': 30,
'compileSdk': 30,
'kotlin': '1.4.10',
'buildTools': '30.0.2',
'ndk': '21.3.6528147'
]
Make sure you have downloaded and installed NDK bundle under Sdk directory. If not open SDK Manager. Install it by checking NDK(Side
by side)
Restart the IDE and try it again. If further any problem, pls add this code in build.gradle file
android {
........
defaultConfig {
.........
ndkVersion '22.1.7171670' // Your downloaded NDK version
}
}
Note: Keep your local.properties file like bellow:
sdk.dir=C:\\Users\\User\\AppData\\Local\\Android\\sdk # My installed SDK location
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
I was also facing the same problem from a few weeks and I had tried my best but didn't work. Then I downloaded NDK using android studio.
Screenshot of Android Studio
After downloading the NDK also not resolved my problem. Then I visited the SDK folder and found NDK and NDK-bundle. As I know the two folders have the same properties.
I had copied the source.properties file from the NDK \ 23.1.7779620 and pasted it into the NDK-Bundle folder.
Screenshot of source.properties file
It is working perfectly.
You should also try...
ndk.dir=c\:\\Users\\DanielWaiguru\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670
has been deprecated and the AGP should set the default ndk version but in case it doesn't, specify a specific version of ndk in your build.gradle as follows
android {
ndkVersion <version>
}
for example
ndkVersion "22.1.7171670"
Just remove or rename ndk-bundel in Android SDK folder
Things to be checked if you are facing this error:
Check whether Ndk location is specified or not in local.properties file.
If not, go to the NDK location inside your sdk folder,if there are multiple ndk versions delete previous versions if you don't need. Go inside the latest version folder and check whether source.properties file is present or not. Copy the folder path and specify the path in the local.properties file.
For me it is
ndk.dir=C:\Users\admin\AppData\Local\Android\Sdk\ndk\22.0.6917172
In app level build.gradle file specify the version number if it is incorrect
For me it is
android {
ndkVersion '22.0.6917172'
}
Important note:
The value for ndk.dir should no longer be set in your app's local.properties file, and support for this ndk.dir setting will be removed in a future version. The Android Gradle Plugin sets the NDK version by default, but if you need a specific version of the NDK, you can set android.ndkVersion in build.gradle.
You can visit this official page for more details
I was facing the same issue and solved it
Go to the Sdk path and then go inside the ndk folder and then cut - paste the folder with the version name somewhere else and then clean and rebuild.
I am using Android Studio 4.1.1 on MacOS 11.1. None of the above solutions worked for me. What worked for me was not a reconfiguration of gradle files but a simple reconfiguration of the NDK package.
cd ~/Library/Android/sdk/ndk/22.0.7026061
cp android-ndk-r22/source.properties .
The root cause for this is: for a specific buildToolsVersion, might come with a default ndk version, but this version of ndk might not located under the ndk.dir, so a simple fix would be
android {
ndkVersion <an existing version of ndk>
}
> Task :app:stripDebugDebugSymbols FAILED react native
> NDK at C:\Users\{username}\AppData\Local\Android\Sdk\ndk\21.4.7075529 did not have a source.properties file
if you are using the react native change ndk version in build.gradle
i was changed ndkVersion = "21.4.7075529" to ndkVersion = "22.1.7171670"
Go to build.gradle file paste ndkVersion "23.1.7779620" in the android section
android {
compileSdkVersion 30
ndkVersion "23.1.7779620"
}
Just go to:
File settings
Search for the Android SDK
In the SDK tools, locate ndk and tick "show package details."
Download the ndk error version displaying on your console.
Make sure you've cmake sdk also installed
Me too!
When I upgrade AS4.0.1---->4.1.1
And
project‘s build.gradle
classpath 'com.android.tools.build:gradle:4.1.1'
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
I got this problem,And solution is very simple:
I copy the file to ndk-bundle directory
DONE
Downloan Ndk https://developer.android.com/ndk/downloads
And place in /Users/yourname/Library/Android/sdk/ndk/21.3.6528147
Try downgrading your gradle version to 3.4.2, by adding the following line to your Project's build.grade file,
classpath 'com.android.tools.build:gradle:3.4.2'
1.First of all make sure you have installed ndk on the android studio sdk manager
2. add the following lines in the local.properties file
ndk.dir = C:\\Users\\MACOWIGO\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670
then on the build.gradle file add the following line
buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 ndkVersion = "22.1.7171670" }
nake sure the ndk version provided on the build.gradle file is the same as the one provided/written in local.properties file
Go to local.properties(SDK Locations)
Add to NDK Source path
ndk.dir=c\:\\Users\\SankA\\AppData\\Local\\Android\\Sdk\\ndk\\22.1.7171670
Look Like this Image - Myexample image
Removing following line from local.properties worked for me as mentioned in accepted answer it is deprecated.
ndk.dir=~/Library/Android/sdk/ndk-bundle
When trying to build OpenStreetMapView from git://github.com/osmdroid/osmdroid, I get this error:
failed to find target with hash string android-23: D:\Users\myusername\AppData\Local\Android
How can I fix this? Previous questions similar to this suggest checking that android 23 is not installed, but in my case, it is.
Below is some pertinent info:
ANDROID_HOME is D:\Users\myusername\AppData\Local\Android\sdk
D:\Users\myusername\AppData\Local\Android\sdk\platforms\ contains the directory \android-23\, (as well as android-19, android-21, android-22, android-MNC)
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.osmdroid.example"
minSdkVersion 8
targetSdkVersion 23
versionCode 16
versionName "4.4-SNAPSHOT"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'android.support:compatibility-v4:23+'
compile project(':osmdroid-android')
//compile 'org.osmdroid:osmdroid-third-party:4.4-SNAPSHOT'
}
I tried changing targetSdkVersion and compileSdkVersion to 22. This causes the error message to change to "android-22" instead of "android-23".
SDK Manager:
In my case, clearing caché didn't work.
On SDK Manager, be sure to check the box on "show package descriptions"; then you should also select the "Google APIs" for the version you are willing to install.
Install it and then you should be ok
In Android Studio File -> Invalidate Caches/Restart solved the issue for me.
The answer to this question.
Gradle gets stupid from time to time and wiping out the cache is the only solution that I've found. You'll find a hidden .gradle folder under your user home folder and another one wherever the checkout location is for osmdroid.
I fixed the issue for me by opening the Android SDK Manager and installing the build tools for all 23.x.x versions.
See the screenshot.
Update: Does not apply to the Android Studio released after this answer (April 2016)
Note: I think this might be a bug in Android Studio.
Go to Project Structure
Select App Module
Under the first tab "Properties" change the Compile SDK Version to API XX from Google API xx (e.g. API 23 instead of Google API 23)
Press OK
Wait for the completion of on going process, in my case I did not get an error at this point.
Now revert Compiled Sdk Version back to Google API xx.
If this not work, then:
With Google API (Google API xx instead of API xx), lower the build tool version (e.g. Google API 23 and build tool version 23.0.1)
Press Ok and wait for completion of on going process
Revert back your build tool version to what it was before you changed
Press Ok
Wait for the completion of process.
Done!
Following these reccomended directions seemed to work:
Hint: Open the SDK manager by running: /path/to/android/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
There are 2 solutions to this issue:
1) Download the relevant Android SDK via Tools -> Android -> SDK Manager -> SDK Tools (ensure you have 'Show Package Details') checked. Your case would be Android 6.0 (Marshmallow / API level 21)
2) Alternatively, open your build.gradle file and update the following attributes :
compileSdkVersion
buildToolsVersion
targetSdkVersion
either to the most recent version of the Android API that you have installed / another installed version you'd like to use (although I'd always recommend going with the latest version for the usual reasons: bug fixes etc.)
If you're following step 2 it's also important that you remember to update the Android support library version if your app is using it. This can be found in the dependencies section of your build file and looks something like this:
compile 'com.android.support:appcompat-v7:27.0.2'
(replace 27.0.2 with the most recent support library version for the API level you intend to use with your app)
Had the same issue with another number, this worked for me:
Click the error message at top "Gradle project sync failed" where the text says ´Open message view´
In the "Message Gradle Sync" window on the bottom left corner, click the provided solution "Install missing ... "
Repeat 1 and 2 if necessary
23:08 Gradle sync failed: Failed to find target with hash string 'android-26' in: C:\Users\vik\AppData\Local\Android\Sdk
Android SDK providing a solution in the bottom left corner
For me the problem was in that I wrote compileSdkVersion '23' instead of 23. The quotes were the problem.
It worked for me by changing compileSdkVersion to 24 and targetSdkVersion to 24 and change compile to com.android.support:appcompat-v7:24.1.0
This poblem is solved for me after Run as administrator the Andorid Studio
Open the Android SDK Manager and Update with latest.
Nothing worked for me. I changed SDK path to new SDK location and reinstalled SDK.Its working perfectly.
Tools > Android > SDK Manager.
I had this issue when using windows. It turned out that the SDK location in my profiles was the issue. So I had to relocate my SDK folder to documents and then it worked.
Mine was complaining about 26. I looked in my folders and found a folder for 27, but not 26. So I modified my build.gradle file, replacing 26 with 27. compileSdkVersion, targetSdkVersion, and implementation (changed those numbers to v:7:27.02). That changed my error message. Then I added buildToolsVersion "27.0.3" to the android bracket section right under compileSdkVersion.
Now the make project button works with 0 messages.
Next up, how to actually select a module in my configuration so I can run this.
Download the specific Android release from the link specified in the build console.
The problem is caused because the code you are running was created in an older API level, And your present SDK Manager doesn't support running them.
So do try the following;
1.Install the SDK Manager that support API level 23.
Go to >SDK Manager, >Android SDK , then select API 23 and install.
2.second alternative is to update your build.grade app module to change
compileSdkVersion,compile,and other numbers to your currently supported API level.
Note:please ensure to check the API and Revision numbers and change them exactly. otherwise Your project won't synchronize
Ensure the IDE recognizes that you have the package. It didn't on mine even after downloading 28, so I uninstalled then reinstalled it after realizing it wasn't showing up under File-Project Structure-Modules-App as a choice for SDK.
On top of that, you may want to change your build path to match.
Slightly related, the latest updates seem able to compile when I forced an update all the way to 28 for CompileSDK, and not just up to the new API 26 min requirement from Google Play. This is related to dependencies though, and might not affect yours
AndroidSDK > SDK platforms > and install API Level 23
When trying to build OpenStreetMapView from git://github.com/osmdroid/osmdroid, I get this error:
failed to find target with hash string android-23: D:\Users\myusername\AppData\Local\Android
How can I fix this? Previous questions similar to this suggest checking that android 23 is not installed, but in my case, it is.
Below is some pertinent info:
ANDROID_HOME is D:\Users\myusername\AppData\Local\Android\sdk
D:\Users\myusername\AppData\Local\Android\sdk\platforms\ contains the directory \android-23\, (as well as android-19, android-21, android-22, android-MNC)
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.osmdroid.example"
minSdkVersion 8
targetSdkVersion 23
versionCode 16
versionName "4.4-SNAPSHOT"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'android.support:compatibility-v4:23+'
compile project(':osmdroid-android')
//compile 'org.osmdroid:osmdroid-third-party:4.4-SNAPSHOT'
}
I tried changing targetSdkVersion and compileSdkVersion to 22. This causes the error message to change to "android-22" instead of "android-23".
SDK Manager:
In my case, clearing caché didn't work.
On SDK Manager, be sure to check the box on "show package descriptions"; then you should also select the "Google APIs" for the version you are willing to install.
Install it and then you should be ok
In Android Studio File -> Invalidate Caches/Restart solved the issue for me.
The answer to this question.
Gradle gets stupid from time to time and wiping out the cache is the only solution that I've found. You'll find a hidden .gradle folder under your user home folder and another one wherever the checkout location is for osmdroid.
I fixed the issue for me by opening the Android SDK Manager and installing the build tools for all 23.x.x versions.
See the screenshot.
Update: Does not apply to the Android Studio released after this answer (April 2016)
Note: I think this might be a bug in Android Studio.
Go to Project Structure
Select App Module
Under the first tab "Properties" change the Compile SDK Version to API XX from Google API xx (e.g. API 23 instead of Google API 23)
Press OK
Wait for the completion of on going process, in my case I did not get an error at this point.
Now revert Compiled Sdk Version back to Google API xx.
If this not work, then:
With Google API (Google API xx instead of API xx), lower the build tool version (e.g. Google API 23 and build tool version 23.0.1)
Press Ok and wait for completion of on going process
Revert back your build tool version to what it was before you changed
Press Ok
Wait for the completion of process.
Done!
Following these reccomended directions seemed to work:
Hint: Open the SDK manager by running: /path/to/android/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
There are 2 solutions to this issue:
1) Download the relevant Android SDK via Tools -> Android -> SDK Manager -> SDK Tools (ensure you have 'Show Package Details') checked. Your case would be Android 6.0 (Marshmallow / API level 21)
2) Alternatively, open your build.gradle file and update the following attributes :
compileSdkVersion
buildToolsVersion
targetSdkVersion
either to the most recent version of the Android API that you have installed / another installed version you'd like to use (although I'd always recommend going with the latest version for the usual reasons: bug fixes etc.)
If you're following step 2 it's also important that you remember to update the Android support library version if your app is using it. This can be found in the dependencies section of your build file and looks something like this:
compile 'com.android.support:appcompat-v7:27.0.2'
(replace 27.0.2 with the most recent support library version for the API level you intend to use with your app)
Had the same issue with another number, this worked for me:
Click the error message at top "Gradle project sync failed" where the text says ´Open message view´
In the "Message Gradle Sync" window on the bottom left corner, click the provided solution "Install missing ... "
Repeat 1 and 2 if necessary
23:08 Gradle sync failed: Failed to find target with hash string 'android-26' in: C:\Users\vik\AppData\Local\Android\Sdk
Android SDK providing a solution in the bottom left corner
For me the problem was in that I wrote compileSdkVersion '23' instead of 23. The quotes were the problem.
It worked for me by changing compileSdkVersion to 24 and targetSdkVersion to 24 and change compile to com.android.support:appcompat-v7:24.1.0
This poblem is solved for me after Run as administrator the Andorid Studio
Open the Android SDK Manager and Update with latest.
Nothing worked for me. I changed SDK path to new SDK location and reinstalled SDK.Its working perfectly.
Tools > Android > SDK Manager.
I had this issue when using windows. It turned out that the SDK location in my profiles was the issue. So I had to relocate my SDK folder to documents and then it worked.
Mine was complaining about 26. I looked in my folders and found a folder for 27, but not 26. So I modified my build.gradle file, replacing 26 with 27. compileSdkVersion, targetSdkVersion, and implementation (changed those numbers to v:7:27.02). That changed my error message. Then I added buildToolsVersion "27.0.3" to the android bracket section right under compileSdkVersion.
Now the make project button works with 0 messages.
Next up, how to actually select a module in my configuration so I can run this.
Download the specific Android release from the link specified in the build console.
The problem is caused because the code you are running was created in an older API level, And your present SDK Manager doesn't support running them.
So do try the following;
1.Install the SDK Manager that support API level 23.
Go to >SDK Manager, >Android SDK , then select API 23 and install.
2.second alternative is to update your build.grade app module to change
compileSdkVersion,compile,and other numbers to your currently supported API level.
Note:please ensure to check the API and Revision numbers and change them exactly. otherwise Your project won't synchronize
Ensure the IDE recognizes that you have the package. It didn't on mine even after downloading 28, so I uninstalled then reinstalled it after realizing it wasn't showing up under File-Project Structure-Modules-App as a choice for SDK.
On top of that, you may want to change your build path to match.
Slightly related, the latest updates seem able to compile when I forced an update all the way to 28 for CompileSDK, and not just up to the new API 26 min requirement from Google Play. This is related to dependencies though, and might not affect yours
AndroidSDK > SDK platforms > and install API Level 23
i just switched to intellij and pretty new to android development.. I've been working on one app for 5 moth and now that i moved it to intellij android studio my options menus became invisible. I've been reading a lot and trying to catch up with newest features that are available now today.
By biggest pain is that im hitting this error ->
Failed to refresh Gradle project 'ActionBarCompat-ListPopupMenu' You are using Gradle version 1.8, which is not supported. Please use version 1.9. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (
I did search on this problem and some pages suggesting changing classpath to soething like
build:gradle:0.7.+ but that doest help..
What am i doing wrong? All i need is just to make those examples from android to work..
Thanks
The Gradle wrapper file is at the path (project-root)/gradle/wrapper/gradle-wrapper.properties. The distributionUrl property is where you set the Gradle version; it's embedded in the URL:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
First make sure you've updated to the newest Android SDK Build-tools version, the most current one is 19.0.3; if you haven't, then open the Android SDK manager and update.
Then look in the build.gradle file inside your project folder (not the one in the root folder). This first couple of lines should resemble something like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
Set the class path to com.android.tools.build:gradle:0.9.+.
Then further along in the same file:
android {
compileSdkVersion 18
buildToolsVersion "19.0.3"
...
}
Set buildToolsVersion to 19.0.3 (the newest version).
Make sure Android Studio syncs the Gradle file changes. If it doesn't, restart Android Studio and/or rebuild the project. Then you should be good to go.
I think i figured this out.. Big thanks to Scott and Jaap.
I did updateof my intellij to 0.5.2, also i installed 19.0.3 ( newest build tools).
On few of the existing projects i had to change distributionUrl to
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
After rebuilding the project it worked like a charm.
Just a note to say : Scorr Berba's reply was probably the correct one. Also I'm not sure 1.11 can be used - I used the wrapper (there is a lot of confusion here : the wrapper is the gradlew ["gradle*w*"rapper] to set the gradle used for my samples to 1.10 and you must set up your project to use the wrapper OR you can build from the command line e.g "./gradlew build".