2016-03-07 90 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服务子库的相同库的不同版本。 –

相关问题