Android Studio 3.0 - Gradle Sync failed for externalNativeBuild

I get the following trace when I port in Android studio 3.0

* What went wrong: Could not determine the dependencies of task ':celltower:compileExternalNativeBuildJavaWithJavac'. > Could not resolve all task dependencies for configuration ':celltower:externalNativeBuildCompileClasspath'. > Could not resolve project :commonandroidutils. Required by: project :celltower > Unable to find a matching configuration of project :commonandroidutils: - Configuration 'debugApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Configuration 'debugRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'. - Configuration 'releaseApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Configuration 'releaseRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'. > Could not resolve project :wimtutils. Required by: project :celltower > Unable to find a matching configuration of project :wimtutils: - Configuration 'debugApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Configuration 'debugRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'. - Configuration 'releaseApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Configuration 'releaseRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'externalNativeBuild' and found incompatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'. 

My build.gradle is here.

 apply plugin: 'com.android.library' android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" externalNativeBuild { ndkBuild { } } ndk { // abiFilters "armeabi-v7a", "x86" abiFilters "armeabi-v7a" moduleName "HelloJNI" //ldLibs.addAll(["android", "log"]) } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable true minifyEnabled false ndk { abiFilters "armeabi-v7a", "x86" moduleName "HelloJNI" } } externalNativeBuild { ndkBuild { path "src/main/jni/Android.mk" } } } buildTypeMatching 'debug', 'release' compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } } ext { retrofitVersion = '2.1.0' rxJavaVersion = '1.2.1' rxAndroidVersion = '1.2.1' okHttpVersion = '3.4.1' playServicesVersion = '9.8.0' fireBaseVersion = '9.8.0' daggerVersion = '2.7' appCompatV7Version = '26.0.1' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation "com.android.support:support-annotations:$appCompatV7Version" implementation 'com.google.code.gson:gson:2.7' testImplementation 'junit:junit:4.12' implementation 'com.squareup.retrofit:retrofit:1.9.0' implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.0.2' implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion" implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' implementation project(':commonandroidutils') implementation project(':wimtutils') } 

Any help is much appreciated!

+7
android android-studio gradle
source share
3 answers

I took out the externalNativeBuild outside of buildTypes and placed it under android. He started to work.

 android { .... ... buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable true minifyEnabled false ndk { abiFilters "armeabi-v7a", "x86" moduleName "HelloJNI" } } } externalNativeBuild { ndkBuild { path "src/main/jni/Android.mk" } } buildTypeMatching 'debug', 'release' ... .... } // end of android 
+2
source share

Try replacing implementation with api only for the last two project dependencies:

  • commonandroidutils
  • wimutils

The documentation states that:

The dependency is available to the module at compile time, and is also available to the consumer of the module at compile time and runtime. This configuration behaves exactly like compile (which is now deprecated), and you should usually use this only in library modules . Application modules should use implementation if you do not want your APIs to map to a separate test module .

Link: Porting to Android Plugin for Gradle 3.0.0

Not sure, but give it a try. Hope this helps.

0
source share

I am not sure how this is possible. It looks like you have a mismatch between the Gradle plugin itself and its dependencies that the WaitableExecutor class provides.

However, you mention Gradle 1.5, and that is the problem.

The plugin version 0.3 was compatible with Gradle 1.3-1.4. New version last week, 0.4 compatible with Gradle 1.6+

Make sure you are using 0.4 and the new version of Gradle.

0
source share

All Articles