Gradle doesn't work anymore after IDEA update - Cannot convert string value 'JETPACK_COMPOSE'

Answered

I'm using gradle version 6.1.1 and gradle plugin version 201.6668.121. 

Gradle worked fine before inside the IDE, now it suddenly throws this error whenever I try to rebuild the project: 

 

Cannot convert string value 'JETPACK_COMPOSE' to an enum value of type 'com.android.builder.model.AndroidGradlePluginProjectFlags$BooleanFlag' (valid case insensitive values: APPLICATION_R_CLASS_CONSTANT_IDS, TEST_R_CLASS_CONSTANT_IDS, TRANSITIVE_R_CLASS)

 

Running `./gradlew build` in my terminal works fine and builds the project successfully.

 

This is my top level gradle file:

 

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.71'
ext.objectboxVersion = '2.5.1'
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-beta04'

classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion" //objectbox orm
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //kotlin
classpath 'com.google.gms:google-services:4.3.3' //google play services
classpath 'io.fabric.tools:gradle:1.31.2' //crashlytics
classpath 'com.google.firebase:perf-plugin:1.3.1' // Performance Monitoring plugin

}
}

allprojects {
repositories {
google()
jcenter()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}



my gradle.properties:

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official



and my app-level build.gradle:



apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt' // Required for annotation processing.

apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric' //crashlytics
apply plugin: 'com.google.firebase.firebase-perf' //firebase performance


android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.shapify"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
debuggable true
applicationIdSuffix ".debug"

}
release {
minifyEnabled true
shrinkResources true

// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path file('src/main/cpp/Android.mk')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

crashlytics {
enableNdk true
}
tasks.whenTaskAdded { task ->
def taskName = task.name
if (taskName.startsWith('assemble')) {
print ' \n benitest ' + "crashlyticsUploadSymbols" + task.name.substring('assemble'.length())
task.finalizedBy ("crashlyticsUploadSymbols" + task.name.substring('assemble'.length()))
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.android.gms:play-services-ads:19.0.1'
implementation 'com.google.firebase:firebase-config-ktx:19.1.3'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.1.1'
implementation 'com.google.firebase:firebase-perf:19.0.6'

debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
releaseImplementation "io.objectbox:objectbox-android:$objectboxVersion"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

apply plugin: 'io.objectbox'



Can anyone help this java noob?

7 comments
Comment actions Permalink

Could be compatibility issue. Try using different Android build tools version, Gradle version. If you are using jetpack compose, please verify the configuration. Try re-importing project in IDE.

If issue remains please provide a sample project.

-1
Comment actions Permalink

I have the same issue. Using:

classpath 'com.android.tools.build:gradle:4.1.0-alpha05'

buildFeatures {
// Enables Jetpack Compose for this module
compose true
viewBinding true
}

ext {
compose_version = "0.1.0-dev07"
}

I believe its an IDE problem as Android Studio works just fine. This is a blocker from using:

IntelliJ IDEA 2020.1 (Ultimate Edition)
Build #IU-201.6668.121, built on April 8, 2020
Licensed to Fuzz Productions / Andrew Grosner
Subscription is active until April 20, 2020
Runtime version: 11.0.6+8-b765.25 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.3
GC: G1 Young Generation, G1 Old Generation
Memory: 2098M
Cores: 12
Non-Bundled Plugins: PlantUML integration, com.denis.zaichenko.angular.2.ws.live.templates, com.intellij.nativeDebug, com.github.beansoftapp.reatnative.idea, org.jetbrains.plugins.ruby, Dart, io.flutter, org.jetbrains.kotlin, com.intellij.plugins.html.instantEditing, com.deadlock.scsyntax, com.jetbrains.php, ru.adelf.idea.dotenv, intellij.prettierJS, com.github.masahirosuzuka.PhoneGapIntelliJPlugin

 

Same error:

Cannot convert string value 'JETPACK_COMPOSE' to an enum value of type 'com.android.builder.model.AndroidGradlePluginProjectFlags$BooleanFlag' (valid case insensitive values: APPLICATION_R_CLASS_CONSTANT_IDS, TEST_R_CLASS_CONSTANT_IDS, TRANSITIVE_R_CLASS)

 

Happened on

classpath 'com.android.tools.build:gradle:4.1.0-alpha04'

As well. Even without using Jetpack compose, using the new Android gradle plugin breaks sync.

1
Comment actions Permalink

I'm facing the same issue on my KMP project.

The problem is on AndroidGradlePluginProjectFlags.java they add JETPACK_COMPOSE and ML_MODEL_BINDING to the BooleanFlag enum, so probably somewhere in the build tools they are trying to access it but the plugin implementation does not have it yet.

I did not found how to update the android plugin on IntelliJ and I did not found any beta or alpha release of IntelliJ to check if it is bundled with a newer version of the android plugin, so I tried to open the project on Android Studio 4.1 Canary 6 and it works as expected.

2
Comment actions Permalink

@Ademar111190 thanks for the information!

>I did not found how to update the android plugin on IntelliJ and I did not found any beta or alpha release of IntelliJ to check if it is bundled with a newer version of the android plugin, so I tried to open the project on Android Studio 4.1 Canary 6 and it works as expected.

IntelliJ IDEA Android support is provided by Google's AndroidStudio IDE and new AS updates are merged to IntelliJ IDEA Android plugin once Google releases new version. When a new AndroidStudio release is available the changes will be merged to IntelliJ IDEA Android plugin as well.

1
Comment actions Permalink

You may track this issue progress in our tracker: https://youtrack.jetbrains.com/issue/IDEA-233929 See also this comment for more information. As a workaround in the meantime you may use android-gradle-plugin 3.6.2 or use AndroidStudio if 4+ plugin version is a must.

 

0
Comment actions Permalink

I have the same issue only my gradle version is 4.0.0

0
Comment actions Permalink

Looks like this is fixed in IntelliJ 2020.2

1

Please sign in to leave a comment.