2016-03-07 53 views
0

我無法構建Android Studio項目。我得到這個錯誤:錯誤:任務':app:transformClassesWithDexForDebug'的執行失敗。 > TransformException:ProcessException:ExecException:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_71\bin\java.exe'' finished with non-zero exit value 1 

MultiDex在app.gradle啓用:

android { 
     compileSdkVersion 23 
     buildToolsVersion '23.0.1' 
     useLibrary 'org.apache.http.legacy' 

     defaultConfig { 
      applicationId 'my.app' 
      minSdkVersion 14 
      targetSdkVersion 23 
      versionCode 4 
      versionName "1.1.0" 
      multiDexEnabled true 
     } 
... 

我試圖刪除「建設」的文件夾,但它並沒有給我任何結果。我如何解決這個問題?

編輯:此項目是其它計算機(Mac Mini的/ OS X),但我的電腦上沒有建立的(Windows)中

回答

0

這是因爲依賴repeat.Plesae修改這個錯誤,乾淨並重建了這個項目。

+0

我已閱讀您的app.gradle。 'proguard-rules.pro'和'compile fileTree(dir:'libs',include:['* .jar'])'可能有衝突。您可以在proguard中的'-libraryjars libs/.jar'之前添加'#' -rules.pro有一個嘗試。 – TanLingxiao

1

你可以試試下面的步驟來解決問題:

第1步:添加一個名爲MyApplication的MultiDexApplication類擴展它。

第2步:在清單中的應用程序標記中聲明此MyApplication類名稱。

<application 

    android:name=".MyApplication" 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme"> 

步驟3:覆蓋attachBaseContext在所有MyApplication類並調用Multidex.install()方法:

@Override 
protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
} 

嘗試使用上面的修改正在運行的項目,它應該工作!

+0

這個錯誤可能有很多原因。如果上面的答案沒有幫助,那麼請嘗試在build.gradle中查看您的依賴關係。您需要檢查您是否使用兩個相同的庫,或者您沒有使用特別適用於Google Play服務子庫的相同庫的不同版本。 –

相關問題