尝试使用Android Studio 3构建样本Canary 5 with Architecture Components和Kotlin发出此警告。
谁能告诉我原因?
谢谢,Ove
编辑#1: 这是Dan Lew不久前制作的样本
https://github.com/dlew/android-architecture-counter-sample
的build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "net.danlew.counter"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
compile "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile "android.arch.lifecycle:extensions:${rootProject.archLifecycleVersion}"
compile "android.arch.persistence.room:runtime:${rootProject.archRoomVersion}"
compile "android.arch.persistence.room:rxjava2:${rootProject.archRoomVersion}"
kapt "android.arch.lifecycle:compiler:${rootProject.archLifecycleVersion}"
kapt "android.arch.persistence.room:compiler:${rootProject.archRoomVersion}"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
String butterKnifeVersion = '8.5.1'
compile "com.jakewharton:butterknife:$butterKnifeVersion"
kapt "com.jakewharton:butterknife-compiler:$butterKnifeVersion"
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
String daggerVersion = '2.10'
compile "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
String rxBindingVersion = '2.0.0'
compile "com.jakewharton.rxbinding2:rxbinding:$rxBindingVersion"
compile "com.jakewharton.rxbinding2:rxbinding-kotlin:$rxBindingVersion"
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
}
repositories {
mavenCentral()
}
答案 0 :(得分:26)
现在有一个Java 8注释处理器,arch组件是稳定的,所以替换:
"android.arch.lifecycle:compiler:${rootProject.archLifecycleVersion}"
与
"android.arch.lifecycle:common-java8:1.0.0"
答案 1 :(得分:17)
只需添加此答案以供将来参考:不久之前Android Arch Components团队也提出了同样的问题,现在official answer就是:
(...)这只是一个警告。应该不是问题。
这适用于遵循问题标题中提到的格式的警告,并包括:
w:警告:支持的源版本' RELEASE_7'来自注释处理器' android.arch.lifecycle.LifecycleProcessor'少于-source' 1.8' w:
w:警告:支持的源版本' RELEASE_7'来自注释处理器' android.arch.persistence.room.RoomProcessor'少于-source' 1.8' w:
基本上它javac
通知您这些注释处理器是针对不同(较旧)版本的Java(Java 7)编译而生成的,而不是模块的源级别设置到(Java 8)。这样做的原因是编译器无法做出任何承诺,处理器仍能正常运行[但开发人员可以在这种特殊情况下做到]。
请注意,如果删除-Xlint
编译器标志,仍会发出警告,因此,如果不能使用-nowarn
,则无法禁止它。