app:transformClassesWithJarMergingForDebug,com.android.build.api.transform.TransformException:java.util.zip.ZipException:

时间:2017-01-18 14:22:06

标签: android android-studio android-gradle google-play-services

首先我知道有很多类似的问题,但我的情况有所不同。请先阅读完整的问题!

这是完整的错误...

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/appindexing/Action$Builder$StatusType.class

每当我尝试在我的模拟器中运行时,都会显示此错误。

此外,如果我尝试生成.apk文件(在调试或释放模式下),则会显示相同的错误。

现在魔法 ......

如果我在手机中以调试模式运行,那就完全可以了。没有错误显示,运行正常。

这是我的清单文件......

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.brandtechnosolutions.petbaazar">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/iconpetbazar"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light">
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!--
     ATTENTION: This was auto-generated to add Google Play services to your project for
     App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
        -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_login"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity android:name=".WebActivity" />
        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>
        <activity
            android:name=".BuyerSellerActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".OptionActivity"
            android:label="@string/title_activity_option"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".TakeAdInfoActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
    </application>

</manifest>

我的build.gradle ......

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    dexOptions {
        javaMaxHeapSize "1g"
    }
    repositories {
        mavenCentral()
    }
    defaultConfig {
        applicationId "com.brandtechnosolutions.petbaazar"
        minSdkVersion 15
        targetSdkVersion 25
        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'
        }
    }
}



dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //    apply plugin: 'com.google.gms.google-services'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'junit:junit:4.12'
}

使用sdk平台......

姜饼,蜂窝,棉花糖

将仿真器与Jelly Bean一起使用。

任何人都知道如何解决它,请帮助!

1 个答案:

答案 0 :(得分:0)

您应该使用相同级别的库:

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'

还要添加文件的按钮:

apply plugin: 'com.google.gms.google-services'

编辑:
要使用该插件,您必须在buildscript块(在顶级文件或模块文件中)中添加依赖项:

dependencies {
    classpath 'com.google.gms:google-services:3.0.0'
    // ...
}