증분 주석 처리 요청 경고를 제거하는 방법은 무엇입니까?


150

방금 안드로이드 개발을 시작하고 방 라이브러리를 사용하려고했습니다. 어제부터이 경고 메시지가 나타납니다

w : [kapt] androidx.lifecycle.LifecycleProcessor (NON_INCREMENTAL), androidx.room.RoomProcessor (NON_INCREMENTAL) 프로세서는 증분되지 않으므로 증분 주석 처리가 요청되었지만 지원이 비활성화됩니다.

나는 연구하고 고치려고 노력했지만 여기서이 오류를 피할 수없는 것은 grale.build 파일입니다. 내가 뭘 잘못하고 있는지 제안 / 조언하십시오.

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "ps.room.bookkeeper"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
            }
        }    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    // life cycle dependencies
    def lifecycle_version = "2.0.0"
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"
    kapt "android.arch.lifecycle:compiler:$lifecycle_version"

    //Room dependencies
    //def room_version = "2.1.0"
    implementation 'android.arch.persistence.room:runtime:2.1.0'
    kapt 'android.arch.persistence.room:compiler:2.1.0'
    //annotationProcessor 'android.arch.persistence.room:compiler:2.1.0'

//    implementation "android.arch.lifecycle:extensions:$room_version"
//    kapt "android.arch.persistence.room:compiler:$room_version"
//    androidTestImplementation "android.arch.persistence.room:testing:$room_version"

    //implementation 'androidx.room:room-runtime:2.1.0'
    //annotationProcessor 'androidx.room:room-compiler:2.1.0'
}

annotationProcessor가 왜 주석을 달았습니까? 주석 처리를 제거한 후 프로젝트를 빌드하려고 했습니까? (룸과 라이프 사이클 모두)
— Ferhat Ergün

1
android.enableSeparateAnnotationProcessing를 추가하려고 = 당신의 gradle.properities의 사실이 reddit.com/r/androiddev/comments/ai92pt/... 이 발견, 그것은 당신의 문제와 관련 될 수있다
— Ferhat Ergün에게

7
당분간 프로젝트 build.gradle 파일의 kotlin-gradle-plugin을 버전 1.3.41로 다운 그레이드 할 수 있습니다. 나는 그것이 kapt와 관련된 버그라고 생각합니다. 더 많은 정보 : youtrack.jetbrains.com/issue/KT-33515
— Necrontyr

4
kapt.incremental.apt=false해결 방법으로 문제에 설명 된대로 libs / <모듈 이름>에 gradle.properties 파일을 만들 수도 있습니다 . 그것은 나를 위해 일했다.
— Necrontyr

2
@ Necrontyr, 당신의 제안은 실제로 해결되었습니다. 감사합니다
— Shax

답변:


80

@Necrontyr이 언급했듯이 kotlin-gradle-plugin 버전 1.3.50의 버그가 있습니다. build.gradle (Project)에서 kotlin_version을 1.3.41로 다운 그레이드하십시오.


71
@Necrontyr이 언급 한 버그는 경고와 관련이 없습니다. 경고는 실제로 의도 된 것이며 1.3.41로 내려 가면 경고가 숨겨 지지만 문제는 더 나쁘지 않더라도 동일하게 유지됩니다. 사람들은 증분 주석 처리를 설정했기 때문에 작업 속도가 빨라질 것이라고 생각할 수 있습니다. 그러나 어노테이션 프로세서 중 하나라도 증분이 아닌 경우 증분으로 처리되지 않습니다. 이것은 어떤 라이브러리가 범인인지 지적하는 친근한 알림입니다.
— 안티 모 니트

15
오래된 라이브러리 버전을 사용하는 것은 해결책이 아닙니다.
— Andrew Koster

5
이것은 여전히 ​​Kotlin의 경우 1.3.70입니까?
— IgorGanapolsky

2
Kotlin 1.3.72를 사용하고 있는데 여전히이 문제에 직면하고 있습니까?
— Anbuselvan Rocky

4
나는 또한이 문제에 직면하고있다 1.3.72 어떤 솔루션 녀석?
— hiashutoshsingh

174

이 줄을 gradle.properties에 추가하십시오.

kapt.incremental.apt=true

11
이것이 받아 들일 수있는 더 나은 옵션입니다. 이해하고 자세한 정보가 필요한 사람들을 위해이 링크를 참조하십시오 : medium.com/avast-engineering/…
— Abhimanyu

4
나도 실패했다.
— Steven Smith

여기에서 왜 그런 일이 일어나는 사람이 있습니까?
— Omer

나는 최근에 내 안드로이드 (kotlin) 프로젝트에 데이터 바인딩을 활성화 하고이 경고를 받기 시작했다. 위에서 언급 한대로 재산을 추가하면 나를 위해 일했습니다. 또한 모든 의존성, 컴파일러, 빌드 툴, SDK 등 최신 버전을 사용합니다.
— Gail

4
이 작업을 수행하면 나를 위해 작동하지 않았습니다. Room 라이브러리 의 설명서에 설명 된대로 build.gradle 파일도 편집해야했습니다 .
— 넬슨 페라 구트

121

실제 문제는 증분 처리로 작업 속도가 빨라지지만, 주석 처리기가 증분이 아닌 경우 실제로는 그런 식으로 처리되지 않습니다.

증분 처리의 목적은 무엇입니까?

버전 1.3.30+ 부터 증분 처리를 통해 변경이 발생할 때마다 모듈을 다시 처리 할 수 ​​없었으므로 빌드 프로세스의 성능이 향상되었습니다.

이 릴리스의 주요 초점 영역은 Kotlin / Native, KAPT 성능 및 IntelliJ IDEA의 개선에 중점을 두었습니다.

에서 코 틀린 문서 :

Kapt 컴파일러 플러그인을 사용하여 Kotlin에서 주석 프로세서 (JSR 269 참조)가 지원됩니다. 간단히 말해서 Kotlin 프로젝트에서 Dagger 또는 Data Binding과 같은 라이브러리를 사용할 수 있습니다.

방 증분 처리를 수정하는 방법?

룸 증분 주석 프로세서는 기본적으로 비활성화 되어 있습니다. 이것은 알려진 문제이며 여기에 설명되어 있습니다 . 버전 2.2.0에서 수정하려고합니다. 업데이트를 기다리거나 다음을 설정하여 경고를 제거 할 수 있습니다.

에서 gradle.properties의 파일 :

kapt.incremental.apt=true

(선택적 단계)

수 있도록 데이터 바인딩 증가로 :

android.databinding.incremental=true

더 빠른 빌드를 위해 :

kapt.use.worker.api=true

몇 가지만 변경하면 빌드 시간이 크게 줄어 듭니다.

kapt.include.compile.classpath=false

(주제로 돌아 가기)

프로젝트 build.gradle 에서 필요한 종속성 (Groovy)을 추가하십시오.

dependencies {
    ...
    implementation "androidx.room:room-runtime:2.2.0-rc01"
    annotationProcessor "androidx.room:room-compiler:2.2.0-rc01"
}

과

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.incremental":"true"]
            }
        }
    }
}

코 틀린 DSL 버전 :

dependencies {
    ...
    implementation("androidx.room:room-runtime:2.2.0-rc01")
    kapt("androidx.room:room-compiler:2.2.0-rc01")
}

과

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = mapOf("room.incremental" to "true")
            }
        }
    } 
}

편집하다:

2019 년 10 월 9 일

androidx.room:room-*:2.2.0 이 릴리스되었습니다 .

Gradle 증분 주석 프로세서 : Room은 이제 Gradle 분리 주석 프로세서이며 프로세서 옵션 room.incremental을 통해 증분 성을 활성화 할 수 있습니다.


8
kapt.incremental.apt = true는 프로젝트에 룸을 포함시킬 때 누락되는 것으로 받아 들여 져야합니다. 방에
— sela

1
이 답변은 androidx.lifecycle:lifecycle-extensions버전 2.1.0에서 사용 하고 2.2.0-beta01로 전환 한 후 경고가 사라졌습니다.
— simne7

2
@ simne7 마지막에 편집 내용을 확인하십시오. 버전 2.2.0이 릴리스되었습니다. =) 증분 처리 기능에 액세스하고 빌드를 향상시키기 위해 이미 업그레이드 할 수 있습니다.
— Dimas Mendes

활성화 android.buildcache=true하면 더 빨라질까요?
— IgorGanapolsky

1
Google 개발자 웹 사이트에 따르면 @IgorGanapolsky Projects using Android plugin 2.3.0 and higher enable the build cache by default (unless you explicitly disable the build cache). 따라서 기본적으로 활성화되어 있으므로 활성화하는 것이 적합하지 않습니다.
— Dimas Mendes

37

에서 방 문서 :

"Room에는 다음과 같은 주석 프로세서 옵션이 있습니다 ... room.incremental : Gradle 증분 주석 처리기를 활성화합니다."

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                    "room.schemaLocation":"$projectDir/schemas".toString(),
                    "room.incremental":"true",
                    "room.expandProjection":"true"]
            }
        }
    }
}

룸 버전을 2.2.x 이상으로 업데이트하십시오.


3
증분 처리를 유지하려는 경우 정답하십시오. 위에서 설정된 schemaLocation 또는 expandProjection 인수가 필요하지 않을 수 있습니다. 증분 충분하다.
— bajicdusko

1
developer.android.com/jetpack/androidx/releases/room 에 따르면 여전히 2.2.0-rc01 버전이 있습니다.
— CoolMind


룸 버전을 2.2.0으로 업데이트하십시오. 이것은 나를 위해 일했습니다
— DivideBy0

25

다음은이 문제를 해결하고 빌드 시간을 대폭 단축 할 수있는 작업 목록입니다.

당신에 build.gradle(모듈) 파일 :

android {
    ...
    defaultConfig {
        ...
        kapt {
            arguments {
                 arg("room.schemaLocation", "$projectDir/schemas".toString())
                 arg("room.incremental", "true")
                 arg("room.expandProjection", "true")
            }
        }
    }
    ...
}

당신에 gradle.properties파일 :

kapt.incremental.apt=true            // enabled by default on 1.3.50+
kapt.use.worker.api=true             // faster builds
kapt.include.compile.classpath=false // near instant builds when there are few changes

android.databinding.incremental=true
android.lifecycleProcessor.incremental=true
//add your specific library if it supports incremental kapt 

18

Kapt 증분 주석 처리 요청 활성화

Kotlin 1.3.31 또는 최신 Kotlin 1.3.30 릴리스 사용

안드로이드 kotlin 프로젝트 gradle.properties 파일에서

# Enable Kapt Incremental annotation processing requeste
kapt.incremental.apt=true

# Enable android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC)
android.databinding.incremental=true

# Decrease gradle builds time 
kapt.use.worker.api=true

# turn off AP discovery in compile path, and therefore turn on Compile Avoidance
kapt.include.compile.classpath=false

# Enable In Logcat to determine Kapt
kapt.verbose=true

무엇에 대해 android.lifecycleProcessor.incremental=true?
— IgorGanapolsky

10

여기에있는 다른 많은 답변은 실제로 원하는대로 작동시키는 대신 오류를 처리하거나 증분 처리를 비활성화합니다.

gradle.properties파일 에서 특정 라이브러리에 대한 증분 처리를 활성화 할 수 있습니다 . 이 설정을 추가하거나 오류를 발생시키는 라이브러리와 일치하는 설정을 추가하십시오.

android.databinding.incremental=true
android.lifecycleProcessor.incremental=true

2
나는 그렇게 확신에 대한 아니에요 android.lifecycleProcessor.incremental=true, 어디 문서화하지 않는 것
— 다니엘 윌슨에게

나도 확실하지 않지만 한 번에 시도했지만 컴파일러는 lifecycleProcessor 라이브러리에 증분 처리가 활성화되어 있지 않다고 말하지 않았습니다.
— Jacques.S

5

"증분 주석 처리가 요청되었지만 다음 프로세서가 증분되지 않기 때문에 지원이 비활성화되어있다"고 불평하는 경우 gradle.properties에서 "kapt.incremental.apt"를 "true"(다른 답변에서 언급 됨)로 설정하는 것은 반대입니다. 직관적. "false"로 설정해야합니다. 그것은 나를 위해 그것을했다.


1
실제로 작동했습니다. 거짓 사람들로 설정하십시오! 감사합니다
— Sakiboy

그리고 어떻게 될까요? 컴파일 속도가 빨라지거나 단순히 경고를 숨기나요?
— CoolMind

@CoolMind 당신은 당신의 의존성 중 하나라도 그것을 지원하지 않는다면 어쨌든 일어나지 않을 인크 리 멘탈 주석 처리를 비활성화 할 것입니다. 따라서 경고가 사라지고 이전부터 빌드 프로세스에 변화가 없습니다.
— DC 크리스토퍼

2
놀랍게도 설정이 kapt.incremental.apt=false저를 도와, 나는 더 이상 오류 받고 없습니다
— 초콜렛을 Dhavale

2
당신은 더 이상 오류가 있지만 지금은 더 증분 처리 : 없습니다
— JustAnotherCoder

2

AndroidX를 사용 하고 있지만에 대해 동일한 것 같습니다 android.arch.lifecycle. 나를 위해 단순히 이것을 대체하는 데 도움이되었습니다.

kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

... 이것으로 :

implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

따라서 사용 android.arch.lifecycle하는 경우 이것을 대체하는 것과 동일한 효과가있을 수 있습니다.

kapt "android.arch.lifecycle:compiler:$lifecycle_version"

... 이것으로 :

implementation "android.arch.lifecycle:common-java8:$lifecycle_version"

이것은 Java 8을 사용하는 경우에만 작동 OnLifecycleEvent하며 LifecycleObserver클래스에 대한 주석을 제거 하고 해당 관찰자가 DefaultLifecycleObserver대신 구현하도록해야 합니다.

여기에build.gradle 표시된 장치에서도이 방법으로 변경하는 것이 좋습니다 .


왜 제거 kapt합니까?
— IgorGanapolsky

@IgorGanapolsky Java 8을 사용하는 경우 AndroidX Lifecycle에서 제안하는 내용입니다. 자세한 내용은 developer.android.com/jetpack/androidx/releases/…
— Anigif

kaptKotlin에 필수적
— IgorGanapolsky

1
lib에 필요한 경우에만. 이 페이지에 따르면 Java 8이 Android에서 더 많은 주류를 얻으면 주석이 더 이상 사용되지 않으므로 common-java8가능한 경우 권장 합니다. developer.android.com/reference/androidx/lifecycle/Lifecycle
— Anigif

흥미 롭군 그들은 kapt특별히 언급하지 않습니다 ...
— IgorGanapolsky

2

실제로해야 할 일은 모듈 앱 의 buildConfig태그에 이러한 코드 줄을 구현하는 것입니다 build.gradle.

javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "room.schemaLocation"  : "$projectDir/schemas".toString(),
                        "room.incremental"     : "true",
                        "room.expandProjection": "true"]
            }
        }

0

위의 답변이 유용 할 수는 있지만 프로젝트에 참여하고 건물 을 줄이는 데 도움이 kotlin_version되었습니다 . 이를 통해 엔티티 모델에 문제가 있는지 확인할 수 있습니다.build.gradle(Project)1.3.41

내가 주석을 달 것을 잊었다 @PrimaryKey. 당신은 뭔가 다른 것일 수 있습니다. Kotlin 1.3.41은 이러한 문제를 확인할 수 있습니다. 이러한 문제를 해결하고 kotlin_version이전 문제로 되 돌리십시오 .


-1

시스템 언어가 영어가 아닌 언어 인 경우 데이터 바인딩 측 의 " İ " 와 같은 문자 문제로 인해 발생할 수도 있습니다 . 이 경우 영어로 된 컴퓨터 시스템 언어를 사용하면 문제가 해결됩니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.