An exception occurred applying plugin request [id: 'com.android.application'] while integration Jetpack Compose
Solution 1
Android Gradle Plugin 7 requires Java 11.
Go to File
> Project Structure
and change JDK location to Embedded JDK
.
Solution 2
For Android Studio Artic Fox (2020.3.1), you can find the JDK settings here:
Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JDK
Then change the setting to "Embedded JDK"
Solution 3
For Android Studio Artic Fox (2020.3.1) Android Gradle Plugin 7 requires Java 11.
use short key Ctr+Alt+Shift+S or
Go to File > Project Structure and change JDK location to Embedded JDK. Same Answer @Mariusz
Solution 4
Check the following picture to re-direct the JDK source:
And you should be good to go.
Solution 5
I have issue with build cache and the error:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> The option 'android.enableBuildCache' is deprecated.
The current default is 'false'.
It was removed in version 7.0 of the Android Gradle plugin.
Removing org.gradle.caching=true
from root gradle properties file solved the issue.
Related videos on Youtube
![Devraj](https://i.stack.imgur.com/YrbcS.jpg?s=256&g=1)
Devraj
I am cool, weird, Techie, Fun loving, Gamer, Android developer... :-)
Updated on July 09, 2022Comments
-
Devraj almost 2 years
I am trying to implement JetPack Compose using Canary 8 but getting this error every time I try to sync gradle
An exception occurred applying plugin request [id: 'com.android.application']
My app\build.gradle file is below
plugins { id 'com.android.application' id 'kotlin-android' } android { compileSdkVersion 30 buildToolsVersion "30.0.0" defaultConfig { applicationId "com.example.myapplication" minSdkVersion 21 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '11' useIR = true } buildFeatures { compose true } composeOptions { kotlinCompilerExtensionVersion compose_version kotlinCompilerVersion '1.4.30' } } dependencies { implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.2.1' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.material:material:$compose_version" implementation "androidx.compose.ui:ui-tooling:$compose_version" implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha06' implementation 'androidx.activity:activity-compose:1.3.0-alpha02' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' }
My build.gradle file is below
buildscript { ext { compose_version = '1.0.0-beta01' } repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.0.0-alpha08' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30" } } task clean(type: Delete) { delete rootProject.buildDir }
and this is my gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME
-
Gaëtan over 3 yearsDo you have the exception as well?
-
Devraj over 3 years@Gaëtan yes, org.gradle.api.plugins.InvalidPluginException:
-
Yaqoob Bhatti almost 3 yearsuse short key Ctr+Alt+Shift+S or Go to File > Project Structure and change JDK location to Embedded JDK
-
-
Devraj over 3 yearsI dont understand why android behave so mistereously as same configuration was working fine 2 days back. Also when I am trying to update Gradle from 6.8.2 to 7.x.x , it starts giving another exception
-
MSDarwish over 3 yearsCould you share the new exception with us?
-
Mariusz over 3 yearsyou already use AGP 7
com.android.tools.build:gradle:7.0.0-alpha08
Android Gradle Plugin != Gradle, I bet AGP in alpha08 got some bug or some other dependencies are bugged or not upteded -
Mariusz over 3 yearsupdate: switched to gradle 7 m 2
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-milestone-2-bin.zip
still giving same exceptionAn exception occurred applying plugin request [id: 'com.android.application']
-
Devraj over 3 years@Mariusz, Hurraah!!! fixed this time. but it is very stange that I have developed a demo app with distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin-zip and java8. but suddenly it stopped working. Thank you so much.. Upgrading java 8 to java 11 solved my problem.
-
Mariusz over 3 years@Devraj most probably you used stable Android Studio (with java8) and AS Preview uses AGP 7 that require J11
-
Devraj over 3 years@Mariusz but Android Jetpack compose does not work on Stable Android studio, It requires Canary. correct me if I am wrong.
-
a55 almost 3 yearswhere is
Project Structure
? i can not find it. -
aldok almost 3 years@a55 As the answer said, "File -> Project Structure...". Or, the shortcut: "CMD+;".
-
Yaqoob Bhatti almost 3 yearsuse short key Ctr+Alt+Shift+S
-
Vikash Parajuli over 2 yearsWhat could be the impact if I remove org.gradle.caching=true from the existing project
-
0xAliHn over 2 yearsWe don't need it anymore. You can remove this
-
Farid over 2 yearsStill the same error
-
Farid over 2 yearsWas already 11 so nope, not a solution
-
Farid over 2 yearsNothing, still the same error