2017-09-08 218 views
7

我在Android Studio中使用Telegram的源代碼時遇到此問題。所以我使用android studio preview 3.0.0 beta 2,gradle 4.1-all.zip,mainsdk:15。 我做了一切,但它不能正常工作。錯誤:任務執行失敗

錯誤是:

Error:Execution failed for task: TMessagesProj:transformDexArchiveWithExternalLibsDexMergerForDebug. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

build.gradle文件是:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.0-beta4' 
    } 
} 
apply plugin: 'com.android.application' 

repositories { 
    mavenCentral() 
} 

dependencies { 
    compile 'com.android.support:support-v4:21.0.+' 
    compile 'com.google.android.gms:play-services:3.2.+' 
    compile 'net.hockeyapp.android:HockeySDK:3.5.+' 
    compile 'com.googlecode.mp4parser:isoparser:1.0.+' 
    compile 'com.android.support:recyclerview-v7:+' 
} 

android { 
    compileSdkVersion 21 
    buildToolsVersion '26.0.0' 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    signingConfigs { 
     debug { 
      storeFile file("config/debug.keystore") 
     } 

     release { 
      storeFile file("config/release.keystore") 
      storePassword RELEASE_STORE_PASSWORD 
      keyAlias RELEASE_KEY_ALIAS 
      keyPassword RELEASE_KEY_PASSWORD 
     } 
    } 

    buildTypes { 
     debug { 
      debuggable true 
      jniDebuggable true 
      signingConfig signingConfigs.debug 
     } 

     release { 
      debuggable false 
      jniDebuggable false 
      //signingConfig signingConfigs.release 
     } 

     foss { 
      debuggable false 
      jniDebuggable false 
      signingConfig signingConfigs.release 
     } 
    } 

    sourceSets.main { 
     jniLibs.srcDir 'libs' 
     jni.srcDirs = [] //disable automatic ndk-build call 
    } 

    sourceSets.debug { 
     manifest.srcFile 'config/debug/AndroidManifest.xml' 
    } 

    sourceSets.release { 
     manifest.srcFile 'config/release/AndroidManifest.xml' 
    } 

    sourceSets.foss { 
     manifest.srcFile 'config/foss/AndroidManifest.xml' 
    } 

    lintOptions { 
     checkReleaseBuilds false 
     abortOnError false 
    } 

    defaultConfig { 
     applicationId "org.telegram.plus" 
     minSdkVersion 15 
     targetSdkVersion 21 
     versionCode 458 
     versionName "2.5.2.1" 

    } 
} 

所以gradle-wrapper.propertiesservices.gradle.org/distributions/gradle-4.1-all.zip

+0

看來你使用的舊版本。你有沒有在https://github.com/DrKLO/Telegram嘗試最新的? –

+0

[Dex錯誤在Android Studio 3.0 Beta4]可能的重複(https://stackoverflow.com/questions/46053902/dex-error-on-android-studio-3-0-beta4) – Chisko

回答

0

嘗試刪除行:

compile 'com.google.android.gms:play-services:3.2.+' 

如果可行。將其替換爲您需要的播放服務的特定部分,例如:

compile 'com.google.android.gms:play-services-gcm:11.2.0' 

Google Cloud Messaging。

0

試試下面這工作對我來說

  • 刪除./gradle文件夾項目中
  • 刪除所有構建文件夾和gradle這個緩存。我跑以下命令:

基於關閉 Dex error On Android Studio 3.0 Beta4

+0

我認爲該命令缺少你的回覆。 –

相關問題