Jetpack Compose dev06 setContent() doesn't work? - android

While updating to dev06 and ran the app I got the following error:
java.lang.NoSuchMethodError: No static method setContent(Landroid/app/Activity;Lkotlin/jvm/functions/Function0;)Landroidx/compose/Composition; in class Landroidx/ui/core/WrapperKt; or its super classes (declaration of 'androidx.ui.core.WrapperKt' appears in /data/app/tt.reducto.composesample-BYNjMDWbVhiprnPCNJw0LA==/base.apk)

If you're coming from dev05, dev04 (or less), there's a migration needed.
UPDATE: This logic works up to Dev09. BETA Release is currently available.
I manage to make it work. You need to do the following:
Android Studio 4.1 Canary 2 or +
gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip
build.gradle: (project level)
buildscript {
ext.kotlin_version = "1.3.70"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0-alpha02"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app level):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.package.name"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
composeOptions {
kotlinCompilerExtensionVersion = "0.1.0-dev06" // THIS ONE is important
}
buildFeatures {
compose true
}
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 = '1.8'
}
}
dependencies {
def compose_version = "0.1.0-dev06"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.ui:ui-foundation:$compose_version"
implementation "androidx.ui:ui-framework:$compose_version"
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.ui:ui-layout:$compose_version"
implementation "androidx.ui:ui-material:$compose_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Once you get all that done, run your code and you'd be good to go.

For Kotlin DSL
kotlinOptions {
jvmTarget = V.JVM.Kotlin.target
useIR = true
}
buildFeatures {
// Enables Jetpack Compose for this module
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.0.0-beta03"
}

Make sure to set compose true inside your gradle file..
for build.gradle.kts
buildFeatures {
compose = true
}
for traditional build.gradle
buildFeatures {
compose true
}

In you apps build.gradle app
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_compiler_verion
}

I had the same error with unnecessary dependency in buildSrc/build.gradle.kts
dependencies {
implementation("com.android.tools.build:gradle:7.0.0-beta02")
}
After removing this the error is gone.
compose version 1.0.0-beta07

I got the same error while used Compose dev07. I fixed the issue by giving the below code in build.gradle (app level):
composeOptions {
kotlinCompilerExtensionVersion = "0.1.0-dev07"
}
For more info please check here

For Kotlin DSL(build.gradle.kts):
android {
buildFeatures {
compose = true
composeOptions.kotlinCompilerExtensionVersion = Depends.Versions.composeVersion //"1.0.0-alpha08"
composeOptions.kotlinCompilerVersion = Depends.Versions.kotlinVersion //"1.4.20"
}
gradle-wrapper.properties file ->
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip

Related

Why can't I upgrade compose_version from compose_version = '1.1.0-beta01' to 1.2.1?

I create an project based the wizard Empty Compose Activity of Android Studio Chipmunk | 2021.2.1 Patch 1. It can be compiled, and it works well.
I get the following running error after I upgrade compose_version from compose_version = '1.1.0-beta01' to 1.2.1.
Could not resolve all files for configuration ':app:kotlin-extension'.
> Could not find androidx.compose.compiler:compiler:1.2.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/androidx/compose/compiler/compiler/1.2.1/compiler-1.2.1.pom
- https://repo.maven.apache.org/maven2/androidx/compose/compiler/compiler/1.2.1/compiler-1.2.1.pom
But the app can run well when I remove kotlinCompilerExtensionVersion compose_version in build.gradle (Module), why?
build.gradle (Project)
buildscript {
ext {
compose_version = '1.1.0-beta01' //I will upgrade it to 1.2.1
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
build.gradle (Module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.myapplication"
minSdk 25
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
composeOptions {
kotlinCompilerExtensionVersion compose_version //OK after I removed it
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
The problem is that there is no Compose Compiler 1.2.1 version. Currently, Compose Compiler follows a different release schedule than other Compose libraries.
Here is the compatibility map and the available versions of Compose Compiler to use together with Kotlin.
In case you're wondering about using different versions between Compose Compiler and the other Compose libraries, it's totally ok to do that, and that's what you should do to have access to the latest versions of them.
You can configure your gradle as follows:
Project module
buildscript {
ext {
kotlinVer = '1.7.10'
composeCompilerVer = '1.3.1' // should be compatible with kotlin version
composeVer = '1.2.1'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version "$kotlinVer" apply false
// ...
}
App module
// ...
android {
// ...
composeOptions {
kotlinCompilerExtensionVersion composeCompilerVer
}
// ...
}
dependencies {
implementation "androidx.compose.ui:ui:$composeVer"
implementation "androidx.compose.ui:ui-tooling-preview:$composeVer"
// ...
}
The version androidx.compose.compiler:compiler:1.2.1 doesn't exist.
You can check it in the google maven repo
You can in any case use the stable version of the module compiler 1.3.0 and all the other compose dependencies at 1.2.1:
buildscript {
ext {
compose_compiler = '1.3.0'
compose_version = '1.2.1'
}
//...
}
and then:
composeOptions {
kotlinCompilerExtensionVersion compose_compiler
}
dependencies {
// stable 1.2.1 releases
implementation "androidx.compose.material:material:$compose_version"
//...
}
As described in the documentation the compiler 1.3.0 requires kotlin 1.7.10:

Jetpack Compose Material 3 Error . Could not resolve all files for configuration ':app:debugRuntimeClasspath'

I have Two lines of error when i run the simple Jetpack Compose Material 3 Project
build.gradle(Project:)
buildscript {
ext {
compose_version = '1.3.0-beta02'
core_ktx_version = '1.9.0-rc01'
material3_version = 'material3:1.3.0-beta02'
lifecycle_version = '2.4.1'
activity_compose_version = '1.5.1'
nav_version = "2.5.2"
hilt_version = "2.42"
hilt_nav_fragment = "1.0.0"
lottieVersion = "5.2.0"
timber_version = "5.0.1"
hilt_navigation_compose = "1.0.0"
room_version = "2.3.0-beta02"
kotlin_version = "1.6.21"
}
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "com.android.tools.build:gradle:4.2.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module : )
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdk 33
defaultConfig {
applicationId "com.jetpackcompose.jp1"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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 = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation "androidx.core:core-ktx:$core_ktx_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material3:$material3_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.activity:activity-compose:$activity_compose_version"
implementation "androidx.compose.compiler:compiler:1.3.1"
implementation 'androidx.appcompat:appcompat:1.6.0-beta01'
// hilt -android
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
// To Integrate Navigation
implementation "androidx.navigation:navigation-compose:$nav_version"
// To use additional extensions of navigation frameworks like hiltViewModel()
implementation "androidx.hilt:hilt-navigation-fragment:$hilt_nav_fragment"
implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation_compose"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
}
rootProject.name = "jp1"
include ':app'
when i run the project i have an error of :
Execution failed for task ':app:desugarDebugFileDependencies'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find androidx.compose.material3:material3:1.3.0-beta02.
Compose compiler and the other compose dependencies have different releases.
The version androidx.compose.compiler:compiler:1.3.0-beta02 doesn't exist.
You can check it in the google maven repo
You can in any case use the stable version of the module compiler 1.3.1 and all the other compose dependencies at 1.2.1 or 1.3.0-beta02:
buildscript {
ext {
compose_compiler = '1.3.1' //compiler
compose_version = '1.3.0-beta02' //compose dependencies
compose_material3 = '1.0.0-beta02' //material3 release
}
//...
}
and then:
composeOptions {
kotlinCompilerExtensionVersion compose_compiler
}
dependencies {
// beta 1.3.0 releases
implementation "androidx.compose.material:material:$compose_version"
//...
//material3
implementation "androidx.compose.material3:material3:$compose_material3"
}
As described in the documentation the compiler 1.3.x requires kotlin 1.7.10:

Android fail to import library

I am new to Android development and making simple app using Jetpack Compose thesedays.
When I import a library in an empty Jetpack Compose project, the compiler can't find the package path.
import me.aflak.arduino.Arduino
import me.aflak.arduino.ArduinoListener
Error message: Unresolved reference: me
This library works fine for "normal View" project. I already googled but couldn't find a clear answer for it.
I doulble checked that I didn't change any settings but for library include.
I really want to know why it fails to import.
Thanks
Here's the build.gradle (Module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.composewitharduino"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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 = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'me.aflak.libraries:arduino:1.4.5'
}
Add these lines into settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// THESE LINES NEED TO BE ADDED
jcenter()
maven { url "https://jitpack.io" }
}
}

Databinding in recyclerview using kotlin causing issue

Here is my app-level gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.app.myapplication"
minSdkVersion 19
targetSdkVersion 31
versionCode 1
versionName "1.0"
multiDexEnabled true
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 = '1.8'
}
buildFeatures {
dataBinding = true
}
}
kapt {
generateStubs = true
correctErrorTypes = true
}
sourceSets {
main {
java {
srcDir "${buildDir}/generated/source/kapt/main"
}
}
test {
java {
srcDir 'src/test/java'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
kapt "com.android.databinding:compiler:3.2.0-alpha10"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
//glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.paging:runtime:1.0.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
this is my main gradle file
buildscript {
ext.kotlin_version = "1.4.10"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I am trying to implement databinding in recyclerview using kotlin. But it is giving me runtime error
Execution failed for task ':app:kaptDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
java.lang.reflect.InvocationTargetException (no error message)
Anyone has faced the same error? I have searched and gone through many links related to this error but all states the use of room library which I am not using and still getting this error.
Any help is much appreicated.
Thanks
Instead of
buildFeatures {
dataBinding = true
}
Try this
buildFeatures {
dataBinding true //<--- for binding the data
viewBinding true //<-- for binding the view
}
I solved this error after updating my
Android studio to
Android Studio Arctic Fox 2020.3.1 Patch 3
and also updated
gradle version to 7.0.3
and
kotlin plugin update to 1.5.20.
Basically I updated all my resources and the error was solved.
Updated gradle files
app-level gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.app.navigationdemoapp"
minSdkVersion 19
targetSdkVersion 31
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 = '1.8'
}
}
dependencies {
implementation "androidx.navigation:navigation-fragment-ktx:2.4.0-beta02"
implementation "androidx.navigation:navigation-ui-ktx:2.4.0-beta02"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
project level gradle
buildscript {
ext.kotlin_version = "1.5.20"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Getting problems when trying to setup Jetpack Compose Found interface rPluginContext

So, I'm trying to let jetpack compose run with a simple example, I have already updated my kotlin plugin to 1.4.0 and also updated all my build gradle with the jetpack compose documentation, but I got this error when compiling
java.lang.IncompatibleClassChangeError: Found interface
org.jetbrains.kotlin.backend.common.extensions.IrPluginContext, but
class was expected at
androidx.compose.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:41)
I have also downloaded the canary version of Android studio
build.gradle project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.0-rc"
repositories {
google()
jcenter()
maven{
url "https://dl.bintray.com/kotlin/kotlin-eap/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven{
url "https://dl.bintray.com/kotlin/kotlin-eap/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.jetpackcompose"
minSdkVersion 22
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'
}
}
buildFeatures {
// Enables Jetpack Compose for this module
compose true
}
// Set both the Java and Kotlin compilers to target Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
composeOptions {
kotlinCompilerVersion kotlin_version
kotlinCompilerExtensionVersion "0.1.0-dev13"
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.ui:ui-core:0.1.0-dev13'
implementation 'androidx.ui:ui-tooling:0.1.0-dev13'
implementation 'androidx.ui:ui-layout:0.1.0-dev13'
implementation 'androidx.ui:ui-material:0.1.0-dev13'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
}
}
But I cant compile the app, I'm trying to run the basic example
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent{
sayHello()
}
}
#Preview
#Composable
fun sayHello(){
Text("Hello World")
}
}
Does anyone knows why this error is thrown ?
Using Kotlin version 1.4.10 instead of 1.4.20 solved my problem.
Try to update Compose version to 0.1.0-dev16. Looks like 0.1.0-dev13 isn't compatible with Kotlin 1.4-rc

Categories

Resources