Following is the build.gradle code in Android Studio
apply plugin: \'com.android.application\'
android {
compileSdkVersion 23
buildToolsVersion \"23
In my case, I was missing the target SDK platform installed. I remember this error was straightforward and prompted you to install it automatically. Worth checking that as well.
In my case, i got wifi problem. make sure you have valid internet connection
In my case I have changed version of Kotlin plugin in gradle file related to module but hadn't change it in root gradle file.
I've resolved this issue by cleaning all the Gradle cache, stoping the Gradle Daemon process, and created a new build successfully using the following command. Make sure your current directory is android.
rm -rf ~/.gradle/caches && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease
I'm using React Native. So I've added following in my scripts in package.json,
"build-android": "rm -rf ~/.gradle/caches && cd android && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease && cd ..",
you need check your gradle version. gradle -v
then you should know your gradle version and your gradle plugin version compatible.
Example:
gradle 4.6 is not compatible with gradle plugin 2.2.
so need update com.android.tools.build:gradle version to 2.3.3.
then you need check gradle/wrapper/gradle-wrapper.properties distributionUrl gradle version
google Android Plugin for Gradle Release Notes
on the other hand
using newer plugin version might require to update Android Studio
thanks @antek
With the new google support gradle plugin (com.google.gms.google-services
) this can be caused by some dependency version problems with your com.google.android.gms.*
modules.
You can probably see the root cause by running the build command with the --stacktrace
parameter. i.e.:
./gradlew :app:dependencies --stacktrace
which might output the cause of the problem:
Caused by: org.gradle.api.GradleException: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [16.0.0,16.0.0]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies. at com.google.gms.googleservices.GoogleServicesPlugin$1$_afterResolve_closure1.doCall(GoogleServicesPlugin.groovy:328) at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)