Reputation: 2455
I am using android studio and openning the hello-jni sample project. However when I trying to compile the project,it prompts:
Error:Cause: failed to find target with hash string 'android-23' in:
/Users/xx/opensource/android-sdk-macosx
<a href="openAndroidSdkManager">Open Android SDK Manager</a>
I had installed the android 6.0 (api 23).Why still prompts failed to find? I looked up in the preference in android stuido ,in android SDK tab it seems android 6.0 (api level 23 revision 1) can be found.
Belows is my gradle file:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.0"
defaultConfig.with {
applicationId = "com.example.hellojni"
minSdkVersion.apiLevel = 3
targetSdkVersion.apiLevel = 23
}
}
/*
* native build settings
*/
android.ndk {
moduleName = "hello-jni"
/*
* Other ndk flags configurable here are
* cppFlags += "-fno-rtti"
* cppFlags += "-fno-exceptions"
* ldLibs = ["android", "log"]
* stl = "system"
*/
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" @
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters += "armeabi"
}
create("arm7") {
ndk.abiFilters += "armeabi-v7a"
}
create("arm8") {
ndk.abiFilters += "arm64-v8a"
}
create("x86") {
ndk.abiFilters += "x86"
}
create("x86-64") {
ndk.abiFilters += "x86_64"
}
create("mips") {
ndk.abiFilters += "mips"
}
create("mips-64") {
ndk.abiFilters += "mips64"
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
Upvotes: 1
Views: 2502
Reputation: 26
This worked for me:
I removed the application I was working on in home directory under AndroidStudioProjects
Restarted Android Studio
Upvotes: 1
Reputation: 2584
I just encountered same problem and I think it is a bug. But I managed to make it work with the following workaround:
First be sure you both install the api and also build-tools (see figure below)
Than in build.gradle, change versions for api and build tools to previous ones: i.e.
android{ compileSdkVersion = 22
buildToolsVersion = "22.0.1"
defaultConfig.with {
applicationId = "com.sample.teapot"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 22
}
}
Sync gradle successfully
Change versions back
I also restarted android studio several times but not sure whether it is required or not.
Upvotes: 1