Jetpack Compose가 앱을 컴파일 할 수 없으며 kotlin-compiler를 찾을 수 없습니다.

Sep 03 2020

최근에 저는 jetpack compose를 실행하려고 애 쓰고 있습니다 ... 모든 예제 코드를 따르고 카나리아를 다운로드했지만 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

이 버전으로 시도해 보았고 문서, 제트 뉴스 예제 및 모든 것을 따랐지만 프로젝트를 컴파일 할 수 없습니다. 내가 뭘 잘못하고 있습니까?

답변

1 CoffeeBreak Sep 03 2020 at 04:07

compileOptions를 놓쳤습니다.

 composeOptions {
        kotlinCompilerExtensionVersion kotlin_version
        kotlinCompilerVersion compose_version
    }

해야한다

composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion kotlin_version
    }