添加少量依赖关系会导致在构建项目时出错

时间:2019-03-10 10:49:04

标签: android firebase google-cloud-firestore

最近,我添加了很少的依赖项,并且可能弄乱了其中的一些依赖项,这在构建项目时会导致错误。我尝试了许多版本组合,但失败了。

错误:

Information:Gradle tasks [:app:assembleDebug]
Error:Program type already present: com.google.android.material.internal.package-info
Information:BUILD FAILED in 8s
Information:1 error
Information:0 warnings
Information:See complete output in console

日志:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\211.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\212.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\213.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\214.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\215.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\216.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\217.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\218.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\219.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\220.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\221.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\222.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\223.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\224.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\225.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\226.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\227.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\228.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\577.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\578.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\579.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\580.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\581.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\582.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\583.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\584.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\585.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\586.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\587.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\588.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\589.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\590.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\591.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\592.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\593.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\594.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\595.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\596.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\597.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\598.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\599.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\600.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\601.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\602.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\603.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\604.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\605.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\606.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\607.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\608.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\609.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\610.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\611.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\612.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\613.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\614.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\615.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\616.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\617.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\618.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\619.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\620.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\621.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\622.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\623.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\624.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\625.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\626.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\627.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\628.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\629.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\630.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\631.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\632.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\633.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\634.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\635.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\636.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\637.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\638.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\639.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\640.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\641.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\642.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\643.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\644.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\645.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\646.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\647.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\648.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\649.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\650.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\651.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\652.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\653.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\654.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\655.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\656.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\657.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\658.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\659.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\660.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\661.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\662.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\663.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\664.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\665.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\666.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\667.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\668.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\669.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\670.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\671.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\672.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\673.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\674.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\675.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\676.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\677.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\678.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\679.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\680.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\681.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\682.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\683.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\684.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\685.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\686.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\687.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\688.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\689.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\690.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\691.jar, E:\again\core\app\build\intermediates\transforms\dexBuilder\debug\692.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s

这是我的AndroidManifest.xml代码:

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

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

    <application
        tools:replace="android:appComponentFactory"
        android:appComponentFactory="whateverString"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".RegisterActivity" />
        <activity android:name=".HomeActivity" />
        <activity
            android:name=".Home"
            android:label="@string/title_activity_home"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity android:name=".ReportActivity" />
        <activity android:name=".MonitorReportsActivity" />
        <activity android:name=".Report_Item" />
        <activity android:name=".declare_emergency" />
        <activity android:name=".alerts"></activity>
    </application>

    </manifest>

build.gradle(项目级别)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
        classpath 'com.google.gms:google-services:3.2.1'

    }
}


allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(应用级别)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.msuraksha.suraksha"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.jakewharton:butterknife:10.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.android.support:design:28.0.0-alpha1'

    implementation 'com.google.firebase:firebase-storage:16.0.5'
    implementation 'com.google.firebase:firebase-database:16.0.6'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.google.firebase:firebase-firestore:18.0.0'
    implementation 'com.google.android.gms:play-services-basement:16.1.0'
    implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation 'com.firebaseui:firebase-ui-storage:4.3.1'





    // Glide library
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'com.android.support:support-v4:28.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.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'

    implementation 'com.android.support:support-annotations:28.0.0'
}


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

我尝试了许多解决方案,但都失败了,每个解决方案都给我带来了一个新问题。

1 个答案:

答案 0 :(得分:1)

由于您添加了implementation 'com.google.android.material:material:1.0.0'依赖项并使用了支持库,因此出现了此错误。

因此,您应该使用所有androidx依赖项。

代替这些依赖项:

     implementation 'com.android.support:support-v4:28.0.0'
     androidTestImplementation 'com.android.support.test:runner:1.0.2'
     androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
     implementation 'com.android.support:support-annotations:28.0.0'
     implementation 'com.google.android.material:material:1.0.0'
     implementation 'com.android.support:design:28.0.0-alpha1'

使用这些:

     implementation 'androidx.legacy:legacy-support-v4:1.0.0'
     androidTestImplementation 'androidx.test:runner:1.1.0'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
     implementation 'androidx.annotation:annotation:1.0.0'
     implementation 'com.google.android.material:material:1.1.0-alpha02'

我们删除了design:28.0.0-alpha1,因为它包含在material:1.0.0-alpha02

然后您应将这些行添加到gradle.properties文件中

     android.useAndroidX = true
     android.enableJetifier = false

最后,您应该删除旧的导入,然后从androidx包中再次导入它,如下所示:

     import androidx.appcompat.app.AppCompatActivity;