重复条目:com / google / android / gms / internal / zzqv.class Android Studio - java

在我的项目中,我实现了play-services-games,首先我尝试添加
compile 'com.google.android.gms:play-services:10.0.1'
但是我遇到了麻烦,发现的解决方案是只编译所需的库
compile 'com.google.android.gms:play-services-games:10.0.1'
一切都很棒,但是当我尝试添加play-services-ads时,事情变得混乱了,我添加了
compile 'com.google.android.gms:play-services-ads:10.0.1'
现在我明白了

错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复项:com / google / android / gms / internal / zzqv.class

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.apps.fightersam"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile name: 'unity-ads', ext: 'aar'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.google.android.gms:play-services-games:10.0.1'
    compile 'com.google.android.gms:play-services-ads:10.0.1'

    compile project(':BaseGameUtils')
}
repositories {
    flatDir {
        dirs 'libs'
    }
}

参考方案

您必须排除重复使用内部传递依赖项。
找出哪个

gradle -q dependencies

这将为您提供依赖关系树。然后你可以做类似的事情

  compile('com.example.m:m:1.0') {
     exclude group: 'org.unwanted', module: 'x 
  }

有没有一种方法可以在一个mediaplayer对象中播放mp3文件? - java

我可以使用Java android中的Mediaplayer类播放声音。我这样制作一个Mediaplayer对象。Mediaplayer mp=Mediaplayer.create(this,R.raw.mysong); 然后开始播放,但是如果我有一首以上的歌曲必须播放。我需要为每个人都做对象吗?我要说的是Mediaplayer类是否具有可以清除旧歌曲并放上…

绑定Java库Xamarin.Android - java

我花了两天时间在每个论坛,文档,tuto,博客等上寻找答案。我为实习生启动了一个Android应用程序,因为我不懂Java,所以用xamarin C#开发了它。直到最近一切都还不错,但现在我需要集成一个SDK才能在应用程序中使用POS(销售点),但是该库是用Java编写的,即使跟随文档或辅导老师,我也无法将其与xamarin绑定(我什至无法调试)。这里有人已…

无法解析R.array.items中的“数组”(Android Studio) - java

我知道已经存在很多类似的问题,但是我仔细检查了一下却找不到答案。由于某种原因,关键字“数组”用红色下划线标出,并且出现错误:无法解析“数组”。我已经建立了项目,检查了我的xml文件,但是我只是无法弄清楚出了什么问题。package com.example.listapp; import android.content.res.Resources; impor…

意图不断使我的应用崩溃? - java

我正在为我的课程构建一个简单的菜单应用程序。我在我的应用程序上有一个ListView,我正在尝试制作它,以便当您单击列表中的某个项目时,您将进入该项目的适当活动。到目前为止,我的意图是在函数外部工作,但是当我在函数内部运行它时,会使我的程序崩溃。谁能指出我正确的方向 //set the item listener menu.setOnItemClickLis…

为什么我的应用在启动时总是崩溃-Android - java

刚刚遵循了有关如何制作按钮和活动的youtube指南。我按照他的代码减小字体大小,并且在启动时一直崩溃。有人知道为什么吗?public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { su…