Lately I have been strugling trying to make jetpack compose run... I have follow all the example codes, downloaded canary and all, but the 1.4.0 plugin is not working for me and I get compile problems
These are my gradle files
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.0"
ext.compose_version = '1.0.0-alpha01'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0-alpha08"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.jetexample"
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 = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion kotlin_version
kotlinCompilerVersion compose_version
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
//Fundamental building blocks of Compose's programming model and state management, and core runtime for the Compose Compiler Plugin to target.
implementation "androidx.compose.runtime:runtime:$compose_version"
//Fundamental components of compose UI needed to interact with the device, including layout, drawing, and input.
implementation "androidx.compose.ui:ui:$compose_version"
//Build Jetpack Compose UIs with ready to use Material Design Components. This is the higher level entry point of Compose, designed to provide components that match those described at www.material.io.
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
//Write Jetpack Compose applications with ready to use building blocks and extend foundation to build your own design system pieces.
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
//Build animations in their Jetpack Compose applications to enrich the user experience.
implementation "androidx.compose.animation:animation:$compose_version"
//In charge of annotators like @Preview and tooling for render views
implementation "androidx.ui:ui-tooling:$compose_version"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
The error I get is this one
Could not resolve compiler classpath. Check if Kotlin Gradle plugin repository is configured in project ':app'.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugAndroidTestKotlin'.
> Could not resolve all files for configuration ':app:kotlinCompilerClasspath'.
> Could not find org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-alpha01.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.0.0-alpha01/kotlin-compiler-embeddable-1.0.0-alpha01.pom
- https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.0.0-alpha01/kotlin-compiler-embeddable-1.0.0-alpha01.pom
Required by:
project :app
> Could not find org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-alpha01.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.0.0-alpha01/kotlin-compiler-embeddable-1.0.0-alpha01.pom
- https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.0.0-alpha01/kotlin-compiler-embeddable-1.0.0-alpha01.pom
Required by:
project :app
I have tried with this version, I have followed the documentation, the jet news example and everything but I cant compile the project, what I'm doing wrong ?
I have missmatched the compileOptions
composeOptions {
kotlinCompilerExtensionVersion kotlin_version
kotlinCompilerVersion compose_version
}
should be
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With