程序类型已存在:com.google.android.gms.common.util.VisibleForTesting -':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
Program type already present: com.google.android.gms.common.util.VisibleForTesting -':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
每当我尝试 运行 Android Studio 3.1.2 中的程序时,我都会收到此错误。
程序类型已存在:com.google.android.gms.common.util.VisibleForTesting
Message{kind=ERROR, text=程序类型已经存在:com.google.android.gms.common.util.VisibleForTesting, sources=[Unknown source file], tool name=Optional.of(D8)}
我的 gradle 模块应用程序:
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
maven {
url "https://maven.fabric.io/public"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的 Gradle 模块应用程序
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "myproject"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'enter code here
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-auth:15.0.0'
//Firebase RealTime Database
implementation 'com.google.firebase:firebase-database:15.0.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
implementation 'com.google.firebase:firebase-storage:15.0.0'
//circleimageView
implementation 'de.hdodenhof:circleimageview:2.1.0'
//Libreria utilizada para medir dimension de layout de chat cuando cambia de tamaño
implementation 'net.the4thdimension:android-utils:2.0.4'
//To scale every screen sizes , sp
implementation 'com.intuit.sdp:sdp-android:1.0.5'
//authenticacion para formato de numero de telefono
implementation 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.0'
//Volley
implementation 'com.android.volley:volley:1.0.+'
implementation 'org.apache.commons:commons-lang3:3.6'
}
apply plugin: 'com.google.gms.google-services'
Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates.
更新google play gradle插件版本到最新版本,目前是3.3.0。
classpath 'com.google.gms:google-services:3.3.0'
请更改以下代码行:
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
至
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.firebase:firebase-storage:15.0.2'
更多信息here。
和
classpath 'com.google.gms:google-services:3.2.1'
至
classpath 'com.google.gms:google-services:3.3.0'
我做了这里建议的更改,但问题仍然存在!!
classpath 'com.google.gms:google-services:3.3.0'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-invites:15.0.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'
compile 'com.google.firebase:firebase-core:15.0.2'
// FirebaseUI for Firebase Auth
implementation 'com.google.firebase:firebase-auth:15.1.0'
//Firebase RealTime Database
implementation 'com.google.firebase:firebase-database:15.0.1'
// FirebaseUI for Cloud Storage
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.google.android.gms:play-services-gcm:15.0.0'
//circleimageView
implementation 'de.hdodenhof:circleimageview:2.1.0'
//Libreria utilizada para medir dimension de layout de chat cuando cambia de tamaño
implementation 'net.the4thdimension:android-utils:2.0.4'
//To scale every screen sizes , sp
implementation 'com.intuit.sdp:sdp-android:1.0.5'
//authenticacion para formato de numero de telefono
implementation 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.0'
//Volley
implementation 'com.android.volley:volley:1.0.+'
implementation 'org.apache.commons:commons-lang3:3.6'
}
应用插件:'com.google.gms.google-services'
VisibleForTesting.java 是 Support Annotations library 中的 class,这是导致问题的原因,如果您导入了上述库的多个版本,您将面对你提到的 D8 抱怨,如果你的项目有多个模块,请尝试在你的项目中使用 api、implmentation 而不是 compile gradle.builds,并尝试只使用上述库的一个版本,这对我有用!
如果将 google 播放 gradle 插件版本更新到最新版本后问题仍然存在,使用 Android 在整个项目中搜索给定文件Studio 文件搜索 和 查找具有相同包名称 的搜索。问题是具有相同包和文件名的文件存在于两个不同的 jar 中(在我的例子中,一个 jar 是旧的 google analytics services jar,它已被手动下载并作为库添加到项目中). Please check image for clarity. 我们必须解决这个冲突(我已经删除了我的旧 jar,因为它不再需要)并且项目将会构建。
我通过删除未使用的 jar 解决了这个问题,或者如果您不使用任何 jar,请评论这一行
实现 fileTree(dir: 'libs', include: ['*.jar'])
每当我尝试 运行 Android Studio 3.1.2 中的程序时,我都会收到此错误。
程序类型已存在:com.google.android.gms.common.util.VisibleForTesting Message{kind=ERROR, text=程序类型已经存在:com.google.android.gms.common.util.VisibleForTesting, sources=[Unknown source file], tool name=Optional.of(D8)}
我的 gradle 模块应用程序:
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
maven {
url "https://maven.fabric.io/public"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的 Gradle 模块应用程序
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "myproject"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'enter code here
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-auth:15.0.0'
//Firebase RealTime Database
implementation 'com.google.firebase:firebase-database:15.0.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
implementation 'com.google.firebase:firebase-storage:15.0.0'
//circleimageView
implementation 'de.hdodenhof:circleimageview:2.1.0'
//Libreria utilizada para medir dimension de layout de chat cuando cambia de tamaño
implementation 'net.the4thdimension:android-utils:2.0.4'
//To scale every screen sizes , sp
implementation 'com.intuit.sdp:sdp-android:1.0.5'
//authenticacion para formato de numero de telefono
implementation 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.0'
//Volley
implementation 'com.android.volley:volley:1.0.+'
implementation 'org.apache.commons:commons-lang3:3.6'
}
apply plugin: 'com.google.gms.google-services'
Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates.
更新google play gradle插件版本到最新版本,目前是3.3.0。
classpath 'com.google.gms:google-services:3.3.0'
请更改以下代码行:
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
至
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.firebase:firebase-storage:15.0.2'
更多信息here。
和
classpath 'com.google.gms:google-services:3.2.1'
至
classpath 'com.google.gms:google-services:3.3.0'
我做了这里建议的更改,但问题仍然存在!!
classpath 'com.google.gms:google-services:3.3.0'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-invites:15.0.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'
compile 'com.google.firebase:firebase-core:15.0.2'
// FirebaseUI for Firebase Auth
implementation 'com.google.firebase:firebase-auth:15.1.0'
//Firebase RealTime Database
implementation 'com.google.firebase:firebase-database:15.0.1'
// FirebaseUI for Cloud Storage
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.google.android.gms:play-services-gcm:15.0.0'
//circleimageView
implementation 'de.hdodenhof:circleimageview:2.1.0'
//Libreria utilizada para medir dimension de layout de chat cuando cambia de tamaño
implementation 'net.the4thdimension:android-utils:2.0.4'
//To scale every screen sizes , sp
implementation 'com.intuit.sdp:sdp-android:1.0.5'
//authenticacion para formato de numero de telefono
implementation 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.0'
//Volley
implementation 'com.android.volley:volley:1.0.+'
implementation 'org.apache.commons:commons-lang3:3.6'
} 应用插件:'com.google.gms.google-services'
VisibleForTesting.java 是 Support Annotations library 中的 class,这是导致问题的原因,如果您导入了上述库的多个版本,您将面对你提到的 D8 抱怨,如果你的项目有多个模块,请尝试在你的项目中使用 api、implmentation 而不是 compile gradle.builds,并尝试只使用上述库的一个版本,这对我有用!
如果将 google 播放 gradle 插件版本更新到最新版本后问题仍然存在,使用 Android 在整个项目中搜索给定文件Studio 文件搜索 和 查找具有相同包名称 的搜索。问题是具有相同包和文件名的文件存在于两个不同的 jar 中(在我的例子中,一个 jar 是旧的 google analytics services jar,它已被手动下载并作为库添加到项目中). Please check image for clarity. 我们必须解决这个冲突(我已经删除了我的旧 jar,因为它不再需要)并且项目将会构建。
我通过删除未使用的 jar 解决了这个问题,或者如果您不使用任何 jar,请评论这一行
实现 fileTree(dir: 'libs', include: ['*.jar'])