Execution Failed For Task :App:Compiledebugjavawithjavac in Android Studio

Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio

Try to upgrade your buildToolsVersion to "23.0.1", like this:

compileSdkVersion 23
buildToolsVersion "23.0.1"

If you didn't install the buildTools for this version, please download it with SDKManager as hint.

Execution failed for task ':app:compileDebugJavaWithJavac' Android Studio 3.1 Update

  • My solution is simple, don't look at the error notification in Build - Run tasks (which should be Execution failed for task ':app:compileDebugJavaWithJavac')

  • Just fix all errors in the Java Compiler section below it.

Sample Image

Flutter error: Execution failed for task ':app:compileDebugJavaWithJavac'

Edit: Solution was a combination of creating a new project with AndroidX selected and add the proper SDK versions to the gradle file. Possibly with using correct dependency versions.

To migrate to AndroidX, you need to set the SDK versions to 21 or higher. I recommend 23 because that removes some other issues as well.

compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example"
minSdkVersion 23
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Error on gradle task ':app:compileDebugJavaWithJavac'

I found the problem. There is an error in my code, but Android Studio don`t show me errors in code, for studio everything is fine. When I look to step by step task execution of gradle, I saw the problems.

failed for task ':app:compileDebugJavaWithJavac'

Did you have
1.multidex initialization in app/build.gradle like below

defaultConfig {
//add this line
multiDexEnabled true
}
dependencies {
//add these lines
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}

2.Check below or add in android/gradle.properties

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

android - Execution failed for task ':app:compileDebugJavaWithJavac'

Setting the JAVA_HOME variable to C:\Program Files\Java\jdkX.XX worked for me.

It was previously set to the JRE directory for some reason.



Related Topics



Leave a reply



Submit