Upgrading to Jetpack Compose Alpha 12 causes errors on setContent
As per this issue, this issue is related to the new androidx.activity:activity-compose:1.3.0-alpha01
artifact.
From that issue:
Activity
1.3.0-alpha02
has been released and fixes this issue.Apps using Compose alpha12 and specifically artifacts like
androidx.compose.ui:ui-test-junit4:1.0.0-alpha12
that internally usesetContent
should add theactivity-compose:1.3.0-alpha02
dependency to theirdependencies
block to ensure that the1.3.0-alpha01
artifact is not used
So to fix your app, you should:
Remove the
freeCompilerArgs += "-Xallow-unstable-dependencies"
line from thebuild.gradle
file (as it is no longer needed)Add a specific dependency on Activity Compose
1.3.0-alpha02
:
implementation 'androidx.activity:activity-compose:1.3.0-alpha02'
By adding that dependency, any direct usages of setContent
as well as internal usages by androidx.compose.ui:ui-tooling:1.0.0-alpha12
or androidx.compose.ui:ui-test-junit4:1.0.0-alpha12
will use the fixed Activity Compose 1.3.0-alpha02 release.
With Activity 1.3.0-alpha02
, setContent
is working, but got another error.
Execution failed for task ':app:mergeDebugJavaResource'.> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction > 2 files found with path 'META-INF/AL2.0' from inputs:
Had to use the workaround to make it built
packagingOptions { exclude 'META-INF/AL2.0' exclude 'META-INF/LGPL2.1' }
And still have the warningFlag is not supported by this version of the compiler: -Xallow-jvm-ir-dependencies