程序类型已存在:com.google.android.gms.common.util.VisibleForTesting-';:应用程序:transformDexArchiveWithExternalLibsDexMergerForDebug';

程序类型已存在:com.google.android.gms.common.util.VisibleForTesting-';:应用程序:transformDexArchiveWithExternalLibsDexMergerForDebug';,android,firebase,gradle,google-play-services,Android,Firebase,Gradle,Google Play Services,每当我尝试在Android Studio 3.1.2中运行程序时,就会出现此错误 程序类型已存在:com.google.android.gms.common.util.VisibleForTesting 消息{kind=ERROR,text=Program type已存在:com.google.android.gms.common.util.VisibleForTesting,sources=[未知源文件],tool name=Optional.of(D8)} 我的gradle模块应用程序: b

每当我尝试在Android Studio 3.1.2中运行程序时,就会出现此错误

程序类型已存在:com.google.android.gms.common.util.VisibleForTesting 消息{kind=ERROR,text=Program type已存在:com.google.android.gms.common.util.VisibleForTesting,sources=[未知源文件],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
}
}

}

}

这是我的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
}
}

}

Firebase Android SDK,允许更频繁、更灵活的更新

将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'

更多信息


我做了这里给我的改变,但问题还在发生

 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'
}
apply plugin:'com.google.gms.google services'

VisibleForTesting.java是支持注释库中的一个类,它会导致问题,如果您导入了上述库的多个版本,您将面临您提到的D8投诉,如果您的项目有多个模块尝试使用api,实现而不是在gradle.builds中编译,并尝试只使用所述库的一个版本,这对我来说是有效的

如果问题在将google play gradle插件版本更新为最新版本后仍然存在,使用Android Studio文件搜索搜索整个项目中的给定文件,并查找具有相同软件包名称的搜索。问题是,具有相同包和文件名的文件存在于两个不同的jar中(在我的例子中,一个jar是旧的google analytics services jar,它已被手动下载并添加为项目中的库)。我们必须解决此冲突(我已删除旧jar,因为不再需要它)这个项目将建立

我通过删除未使用的jar解决了这个问题,如果您没有使用任何jar,请对此行进行注释

实现文件树(dir:'libs',include:['*.jar'])

也检查一下:您尝试过我上面的解决方案吗?不起作用。相同的错误。请尝试以下操作:classpath'com.google.gms:google services:3.3.1'已将google services更新为4.0.1,但仍然无法工作:/最后,我解决了问题,创建了新项目,并按照此处的建议完成了操作。我不得不说,我们已经在运行的项目,当谷歌更新出现这种自发错误时,这真的很烦人。!!!Hi @ LiLaNaJ如果这个或任何答案已经解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这么做。嘿,你解决了吗?解决这个问题的方法是打开新项目,不要使用最新版本的android或firebase,我是说sdkversion 26。嘿,我们解决了这个问题!原来我们的项目有一个遗留的google analytics jar,它有
com.google.android.gms.common.util.VisibleForTesting
,它与firebase common中的一个相冲突,不起作用:/还有什么吗?嘿,@Sidharth Sethia这个库的任何替代品吗?这解决了为我发布的问题:)这是我读过的最有用的答案。谢谢。你不知道这帮我省了多少钱!!!我找了一整天这个问题,这帮我找到了哪个包有问题!非常感谢你!
apply plugin: 'com.google.gms.google-services'
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'
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'