Error:Execution failed for task ':app:transfor

2020-01-26 05:36发布

I am moving my projects from eclipse to Android Studio. While running one of my app I get the following error. Not able to find any solution. I have enabled multidex as well.

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

also my gradle file is below

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
    applicationId "com.myapp"
    minSdkVersion 9
    targetSdkVersion 21
    multiDexEnabled true
}buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
     }
   }
 }
 dependencies {
 compile 'com.android.support:support-v4:23.4.0'
 compile 'com.google.android.gms:play-services:+'
 compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-support-v7-cardview.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-appengine:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client-appengine:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client-appengine:1.18.0-rc'
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-api-client-java6-1.18.0-rc.jar')
compile files('libs/google-api-client-servlet-1.18.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-http-client-jdo-1.18.0-rc.jar')
compile files('libs/google-oauth-client-java6-1.18.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar')
compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar')
compile files('libs/GraphView-4.0.1.jar')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jetty-6.1.26.jar')
compile files('libs/jetty-util-6.1.26.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/jxl.jar')
compile files('libs/mail.jar')
compile files('libs/transaction-api-1.1.jar')
 }

17条回答
我只想做你的唯一
2楼-- · 2020-01-26 05:44

Or you can try this -

Extend your Application class with MultiDexApplication instead of Application !
查看更多
Bombasti
3楼-- · 2020-01-26 05:44

For Ionic 4 Just

$ cordova clean

Helped me then run

$ ionic cordova run android --device
查看更多
淡お忘
4楼-- · 2020-01-26 05:45

Duplicate name Classes

like

class BackGroundTask extends AsyncTask<String, Void, Void> {

and

class BackgroundTask extends AsyncTask<String, Void, Void> {
查看更多
我只想做你的唯一
5楼-- · 2020-01-26 05:46

i have tried this one for more projects and it worked for me. note that solution can configure your app for multidex:

android {
     compileSdkVersion 25
     buildToolsVersion "25.0.1"

     defaultConfig {
           ...
           minSdkVersion 9
           targetSdkVersion 25
     }

     buildTypes {
          release {
              shrinkResources true
              minifyEnabled true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          }
     }}

 dependencies {
       compile 'com.android.support:support-v4:25.1.0'
       compile 'com.google.android.gms:play-services:8.3.0'
       ...
 }
查看更多
Ridiculous、
6楼-- · 2020-01-26 05:46

My Settings Screenshot: image

Thanks to this post.

Just turn off instant run in your settings. You can easily search the keyword "instant" like I showed and it would switch to the window you want.

查看更多
叛逆
7楼-- · 2020-01-26 05:47

This can be because of following reason:

  1. one of the jar files inside project was using an older version of google play services.

  2. use multiDexEnabled true in defaultconfig

  3. Be specific with classes you add in dependencies. like

    compile 'com.google.android.gms:play-services-maps:8.4.0'

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

查看更多
登录 后发表回答