Jetpack Compose 无法编译应用程序,找不到 kotlin-compiler
Jetpack Compose cant compile the app, could not find kotlin-compiler
最近我一直在努力尝试让 jetpack compose 运行...我已经遵循了所有的示例代码,下载了 canary 等等,但是 1.4.0 插件不适合我,我明白了编译问题
这些是我的 gradle 个文件
// 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
}
和
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'
}
我得到的错误是这个
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
我试过这个版本,我已经按照文档、jet news 示例和所有内容进行操作,但我无法编译该项目,我做错了什么?
我的编译选项不匹配
composeOptions {
kotlinCompilerExtensionVersion kotlin_version
kotlinCompilerVersion compose_version
}
应该是
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version
}
最近我一直在努力尝试让 jetpack compose 运行...我已经遵循了所有的示例代码,下载了 canary 等等,但是 1.4.0 插件不适合我,我明白了编译问题
这些是我的 gradle 个文件
// 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
}
和
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'
}
我得到的错误是这个
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
我试过这个版本,我已经按照文档、jet news 示例和所有内容进行操作,但我无法编译该项目,我做错了什么?
我的编译选项不匹配
composeOptions {
kotlinCompilerExtensionVersion kotlin_version
kotlinCompilerVersion compose_version
}
应该是
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version
}