无法在android studio 3.0

时间:2017-12-07 10:07:49

标签: android android-multidex

我正在寻找可以帮助我解决这个问题的答案。我试图在最近2天内解决这个问题。但是,我还没有得到可以解决我的问题的答案。我已经尝试了很多这里给出的解决方案。但没有解决方案适合我。 请帮我解决这个问题。非常感谢。

实际问题是:

Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForGlobalServerDebug'.
 java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

每当我在android studio 3.0上运行现有项目时都会发生这种情况

我为此尝试了很多解决方案,如:

  

1-在gradle中添加mutidexenabled true

     

2-更改依赖项的版本

     

3-使用实现

更改compile关键字      

4-清理并重建项目

     

5-删除Gradle文件(这很难,因为当你再次   重新启动项目没有Gradle文件将自动重新生成)等。

我正在寻找不同于上述解决方案的解决方案。请帮帮我。请...

gradle文件的代码如下:

apply plugin: 'com.android.application'
buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'io.fabric'

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }

    flatDir {
        dirs 'libs'
    }
}
repositories {
    maven { url 'http://clojars.org/repo' }
}

android {
    signingConfigs {
        config {
            keyAlias 'example'
            keyPassword 'example'
            storeFile file('/Users/standarduser/Documents/Android_Projects/example.jks')
            storePassword '@@@@@@@@'
        }
    }
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId 'com.example.example'
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 9  // both Latest
        versionName "2.0.7"
        multiDexEnabled true
        useLibrary 'org.apache.http.legacy'
        vectorDrawables.useSupportLibrary = true
        signingConfig signingConfigs.config
    }
    dexOptions {
        incremental = true
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
    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'
                }
    }

    lintOptions{
        abortOnError false
    }
}

dependencies {
    compile files('libs/httpcore-4.4.1.jar')
    compile('com.twitter.sdk.android:twitter:2.1.1@aar') { //1.6.1@aar
        transitive = true;
    }
    compile('com.github.afollestad.material-dialogs:core:0.8.5.2@aar') {
        transitive = true
    }
    compile('io.socket:socket.io-client:0.8.2') { // 0.6.3
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    testCompile 'junit:junit:4.12'
    compile 'com.writingminds:FFmpegAndroid:0.3.2'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'io.nlopez.smartlocation:library:3.2.9'
    //   compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services-appinvite:9.8.0'
    //9.0.1
    compile 'com.google.android.gms:play-services-gcm:9.8.0'
    compile 'com.google.android.gms:play-services-location:9.8.0'
    compile 'com.google.android.gms:play-services-places:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'
    compile 'com.google.android.gms:play-services-ads:9.8.0'
    compile 'com.google.android.gms:play-services-auth:9.8.0'
    compile 'com.google.android.gms:play-services-plus:9.8.0'
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.0.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'org.apache.httpcomponents:httpmime:4.3.5'
//    implementation 'org.apache.httpcomponents:httpmime:4.3.6'
//    implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.facebook.android:facebook-android-sdk:4.23.0'
    compile 'com.pusher:pusher-java-client:1.1.2'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.daimajia.swipelayout:library:1.2.0@aar'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.6'
    compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.9'
    compile 'com.commit451:PhotoView:1.2.4'
    compile 'commons-lang:commons-lang:2.3'
    compile 'com.karumi:dexter:2.3.1'
    compile 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    implementation 'com.android.support:multidex:1.0.2'
    compile 'org.ocpsoft.prettytime:prettytime:3.2.7.Final'
    compile 'com.koushikdutta.async:androidasync:2.+'
    compile 'com.soundcloud.android:android-crop:1.0.1@aar'
    compile 'net.danlew:android.joda:2.9.4.1'
    compile 'com.albinmathew:photo-crop-library:1.0.3'
    compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.wowza.gocoder.sdk.android:com.wowza.gocoder.sdk:1.0b7@aar'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.4@aar') {
        transitive = true;
    }
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    //    compile 'com.cocosw:bottomsheet:1.+@aar'
    compile project(':libbambuser7')
    compile 'com.squareup.okhttp:okhttp:2.0.0'
}

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

2 个答案:

答案 0 :(得分:0)

build.gradle

中添加此内容
groupby
  • 首先同步gradle然后
  • 从构建菜单 - >按清洁项目按钮。
  • 任务完成后,按“构建”菜单中的“重建项目”按钮。
  • 编译现在是deprecated所以最好使用implementation或api

希望这会对你有所帮助。

答案 1 :(得分:0)

试试这个

使用此

com.google.android.gms:play-services:11.6.0

com.google.android.gms:play-services-location:11.6.0 

而不是

com.google.android.gms:play-services:9.8.0

同步后的

- > 清洁 - >的重建