Pertanyaan entri duplikat: com / google / android / gms / internal / zzahl.class


Berikut adalah kesalahan yang saya dapatkan ketika saya membangun proyek saya:

Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzahl.class

Saya tidak bisa mencari tahu apa yang menyebabkan kesalahan, saya menduga itu adalah sesuatu yang saya ganggu dalam gradle saya atau Aktivitas Java. Begini kodenya:

Gradle:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0' // version plugin support
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

plugins {
    id "org.sonarqube" version "2.1" // https://plugins.gradle.org/plugin/org.sonarqube
}

apply plugin: 'com.android.application'
apply plugin: 'com.github.ben-manes.versions' // ./gradlew dependencyUpdates -Drevision=release
apply plugin: 'sonar-runner'
apply plugin: 'android-apt'
apply plugin: 'com.google.gms.google-services'

repositories {
    jcenter()
}

def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0
def versionMajorMinorPatchBuild = "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
def versionString = "${versionMajor}.${versionMinor}.${versionPatch}"
def versionStringFull = "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"

android {
    compileSdkVersion 25
    buildToolsVersion "24.0.3"

    dexOptions {
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        applicationId "skipasses.android.abc.123.skipasses"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    // set dummy signing values if not defined in ~/.gradle/gradle.properties
    if (!project.hasProperty('SkiPassKeyStoreFile')) {
        println "Using dummy signing values"
        project.ext.setProperty('SkiPassKeyStoreFile', 'dummy.keystore')
        project.ext.setProperty('SkiPassKeyStorePassword', 'dummy!')
        project.ext.setProperty('SkiPassKeyAlias', 'dummy')
        project.ext.setProperty('SkiPassKeyPassword', 'dummy!')
    }

    // defined on the build server in the /usr/share/tomcat/.gradle/gradle.properties
    signingConfigs {
        release {
            storeFile file(SkiPassKeyStoreFile)
            storePassword SkiPassKeyStorePassword
            keyAlias SkiPassKeyAlias
            keyPassword SkiPassKeyPassword
        }
        lwa {
            storeFile file('keystore.jks')
            keyAlias 'androiddebugkey'
            keyPassword 'android'
            storePassword 'android'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "VERSION_NAME_FULL", "\"${versionString}\""
            signingConfig signingConfigs.release
        }
        debug {
            versionNameSuffix '-DEV'
            buildConfigField "String", "VERSION_NAME_FULL", "\"${versionStringFull}${versionNameSuffix}\""
        }
        beta {
            versionNameSuffix '-BETA'
            //noinspection GroovyAssignabilityCheck
            signingConfig android.signingConfigs.debug
            zipAlignEnabled true
            buildConfigField "String", "VERSION_NAME_FULL", "\"${versionStringFull}${versionNameSuffix}\""
        }
    }

    lintOptions {
        abortOnError false
    }
}

ext {
    // versions for libraries that multiple dependencies
    supportLibVersion = '25.0.0'
    dagger = '2.7'
    butterknife = '8.4.0'
    pocketknife = '3.2.1'
}

dependencies {
    // Support Libraries
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"

    // Dependency Injection dependencies
    compile "com.google.dagger:dagger:${dagger}"
    apt "com.google.dagger:dagger-compiler:${dagger}"

    // View Binding
    compile "com.jakewharton:butterknife:${butterknife}"
    apt "com.jakewharton:butterknife-compiler:${butterknife}"

    compile "com.vikingsen:pocketknife-core:${pocketknife}"
    apt "com.vikingsen:pocketknife-compiler:${pocketknife}"

    // Unit Testing
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // Firebase
    compile 'com.google.firebase:firebase-auth:9.8.0'
    compile 'com.firebaseui:firebase-ui-database:0.6.1'
    compile 'com.firebaseui:firebase-ui-auth:0.6.1'
    compile 'com.google.firebase:firebase-core:9.8.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    testCompile 'junit:junit:4.12'
    provided 'javax.annotation:jsr250-api:1.0'
}

sonarqube { //./gradlew sonarqube aDebug
    properties {
        if (!project.hasProperty("abc123SonarHostUrl")) {
            println '!!!! ABC123 Sonar properties must be set in your gradle.properties !!!!'
            return
        }

        // Project Information
        property "sonar.projectKey", "SkiPasses"
        property "sonar.projectName", "SkiPasses"
        property "sonar.projectVersion", versionMajorMinorPatchBuild

        // Sonar Information
        property "sonar.host.url", abcSonarHostUrl
        property "sonar.jdbc.url", abcSonarJdbcUrl
        property "sonar.jdbc.driverClassName", abcSonarJdbcDriver
        property "sonar.jdbc.username", abcSonarUsername
        property "sonar.jdbc.password", abcSonarPassword

        properties["sonar.sources"] = "src/main" //android.sourceSets.main.java.srcDirs
        properties["sonar.tests"] = android.sourceSets.androidTest.java.srcDirs

        if (file("build/intermediates/classes/debug").exists()) {
            properties["sonar.binaries"] = [file("build/intermediates/classes/debug")]
        }
        if (file("build/intermediates/classes/beta").exists()) {
            properties["sonar.binaries"] = [file("build/intermediates/classes/beta")]
        }
    }
}

Dan Aktivitas:

package abc123.android.abc.123.skipasses.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.google.firebase.auth.FirebaseAuth;

import abc123.android.abc.123.skipasses.R;

public class DashboardActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dashboard);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        //Todo: figure out why the BuildConfig is not being fetched
//        TextView textView = (TextView) findViewById(R.id.version_text);
//        textView.setText(getString(R.string.version_number, BuildConfig.VERSION_NAME));
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        int id = item.getItemId();
        //TODO Create fragments for each menu item
        if (id == R.id.nav_my_reservations) {
        } else if (id == R.id.nav_make_reservation) {
        } else if (id == R.id.nav_settings) {
        } else if (id == R.id.nav_log_out) {
            FirebaseAuth.getInstance().signOut();
            Intent loginIntent = new Intent(DashboardActivity.this, LoginActivity.class);
            startActivity(loginIntent);
        }
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}

Saya sudah mencoba melakukan build bersih. Saya tidak dapat menemukan pustaka duplikat. Saya tidak dapat melihat di mana ada layanan-bermain dan firebase tidak berbaris dalam nomor versi. Saya hanya tidak melihat bagaimana kesalahan ini terjadi. Bimbingan apa pun akan dihargai.


5
2017-11-01 17:39


asal


Jawaban:


Punya masalah yang sama dan saya tahu bahwa salah satu ketergantungan saya menggunakan versi lain dari PlayServices daripada yang diberikan dalam garis ketergantungan firebase.

Hadir

compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.8.0'

Diubah menjadi

compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'

Juga, sebagaimana disebutkan sebelumnya, Anda harus menempatkan      apply plugin: 'com.google.gms.google-services' di bagian bawah file build.gradle Anda.


6
2017-11-03 14:05



Itu dokumentasi untuk Firebase UI menunjukkan versi 0.6.2 harus digunakan dengan pustaka Firebase / Google Play Services versi 9.8.0.

Perubahan:

compile 'com.firebaseui:firebase-ui-database:0.6.1'
compile 'com.firebaseui:firebase-ui-auth:0.6.1'

untuk:

compile 'com.firebaseui:firebase-ui-database:0.6.2'
compile 'com.firebaseui:firebase-ui-auth:0.6.2'

Juga, apply plugin: 'com.google.gms.google-services' seharusnya ditempatkan di bagian bawah file build.gradle.

Kamu punya multiDexEnabled true tetapi tidak termasuk compile 'com.android.support:multidex:1.0.1' di dependensi Anda. Tidak jelas apakah Anda membutuhkan Multidex, tetapi tanpa pustaka dan konfigurasi dalam manifes Anda, itu tidak akan diaktifkan.


3
2017-11-02 01:29