在Android Studio 2.3.3中运行应用程序时出错

时间:2018-09-30 03:21:48

标签: android android-studio build.gradle

我试图解决与“ FirebaseListOptions”有关的错误,所以我遵循了一些主题,并更改了build.gradle文件。解决了“ FirebaseListOptions”错误,但在运行应用程序时出现了此错误:

  

错误:任务执行失败   ':app:transformClassesWithDexForDebug'。

     
    

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:     java.util.concurrent.ExecutionException:com.android.dex.DexException:     多个dex文件定义了Landroid / arch / lifecycle / ViewModel;

  

这是 build.gradle文件

library(proto)
library(gsubfn)
library(tidyr)
library(dplyr)
library(ggplot2)
library(stringr)
library(magrittr)
library(usmap)
library(RCurl)
library(RJSONIO)
library(sqldf)

我所做的更改是添加了以下3行:

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.bilel.ids.easycom"
        minSdkVersion 22
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:27.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'


    testCompile 'junit:junit:4.12'

    //add Library
    compile 'com.android.support:design:27.+'
    compile 'com.firebaseui:firebase-ui:1.0.1'
    compile 'com.google.firebase:firebase-database:11.4.2'
    compile 'com.firebaseui:firebase-ui-database:3.1.0'
    compile 'com.firebaseui:firebase-ui-auth:3.1.0'

}
apply plugin: 'com.google.gms.google-services'
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'

}

1 个答案:

答案 0 :(得分:0)

尝试在您的gradle上添加此依赖项

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'

implementation 'com.android.support:support-v4:27.1.1'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'

//firebase stuff
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'