设置注释处理器会导致 META-INF/DEPENDENCIES 出现问题
Setting an annotation processor creates a problem with META-INF/DEPENDENCIES
我正在尝试处理这个错误(我在 Android Studio 中更新某些内容之前从未遇到过):
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- auto-value-1.4.jar (com.google.auto.value:auto-value:1.4)
Alternatively, set
android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
所以我添加了一个注释处理器:annotationProcessor 'com.google.auto.value:auto-value:1.4'
。
现在,显示了一个新错误:
More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
问题
我读到我应该更改包装选项( + Error : More than one file was found with OS independent path 'META-INF/LICENSE' + 等)。
但是,有没有一种方法可以在不触发第二个问题的情况下解决第一个问题,而只需对我的应用程序进行一些更改 build.gradle?会更好
build.gradle(应用级别)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.x.x"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 26
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-admin:6.5.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
annotationProcessor 'com.google.auto.value:auto-value:1.4'
}
您可以完全排除文件或将其限制为出现一次:
android {
...
packagingOptions {
// pickFirst "META-INF/DEPENDENCIES"
exclude "META-INF/DEPENDENCIES"
}
}
我正在尝试处理这个错误(我在 Android Studio 中更新某些内容之前从未遇到过):
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - auto-value-1.4.jar (com.google.auto.value:auto-value:1.4) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
所以我添加了一个注释处理器:annotationProcessor 'com.google.auto.value:auto-value:1.4'
。
现在,显示了一个新错误:
More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
问题
我读到我应该更改包装选项(
但是,有没有一种方法可以在不触发第二个问题的情况下解决第一个问题,而只需对我的应用程序进行一些更改 build.gradle?会更好
build.gradle(应用级别)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.x.x"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 26
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-admin:6.5.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
annotationProcessor 'com.google.auto.value:auto-value:1.4'
}
您可以完全排除文件或将其限制为出现一次:
android {
...
packagingOptions {
// pickFirst "META-INF/DEPENDENCIES"
exclude "META-INF/DEPENDENCIES"
}
}