Android Studio Execution failed for task ':app

2019-02-18 19:27发布

This question already has an answer here:

This strange behavior is happenning with my build application.

The strange is that this com.nineoldandroids is a jar that is from android resource libraries.

I have tried to delete build source and recompile again without luck.

My buildgradle:

buildscript {
    repositories {
        maven { url 'http://download.crashlytics.com/maven' }
    }

    dependencies {
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

repositories {
    maven { url 'http://download.crashlytics.com/maven' }
}

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "xxxxxxxx"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            // enable crashlytics where you need
            buildConfigField "boolean", "USE_CRASHLYTICS", "false"
            ext.enableCrashlytics = false
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':library_refreshaction_appcompat')
    compile project(':EnhancedListView')
    compile project(':library_numberpicker')
    compile project(':materialDesign')
    compile project(':library_typeface')
    compile project(':library_updatechecker')
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'se.emilsjolander:stickylistheaders:2.5.0'
    compile files('libs/Parse-1.7.1.jar')
    compile files('libs/BixolonPrinter.jar')
    compile files('libs/bolts-android-1.1.3.jar')
    compile files('libs/core-3.1.0.jar')
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/universal-image-loader-1.9.2.jar')
    compile files('libs/VposAPI.jar')
    compile project(':android-support-v4-preferencefragment-master')
}

Error Log:

Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/Marcus/Downloads/adt-bundle-mac-x86_64-20140702/sdk/build-tools/21.0.2/dx --dex --output /Users/Marcus/Workspace/android-pdv/app/build/intermediates/pre-dexed/debug/library-2.4.0-c0bb3fabf202a58f481b22d99eb3ba9b89fd232d.jar /Users/Marcus/.gradle/caches/modules-2/files-2.1/com.nineoldandroids/library/2.4.0/e9b63380f3a242dbdbf103a2355ad7e43bad17cb/library-2.4.0.jar
  Error Code:
    139

3条回答
聊天终结者
2楼-- · 2019-02-18 19:57

As linked by @zapl Cannot build android project using Android Studio - Gradle 1.7, it is a strange behaviour that doesn't have only one way to solve it, as related by this post.

I couldn't say exactly what I did to solve it, because I tried many things until it disappeared.

But as said in the post, this is the way:

  • Malformed Resources (Missing attributes, wrong tags, etc...)
  • +id in Styles
  • Duplicated resources / libraries
  • Declare-Style able missing name
  • Resource miss-match, try to use different AAPT versions.

Unknown, like mine. So it would be useful to:

  1. Find a way to identify the real cause of this error
  2. Wait for an update to AAPT that returns some error message
  3. Write a list of possible common causes.
查看更多
劳资没心,怎么记你
3楼-- · 2019-02-18 20:05

I had the same problem and it was fixed simply by restarting Android Studio.

I can only guess at the cause, but I think it happened because I launched my app while my emulator was still booting up.

查看更多
做自己的国王
4楼-- · 2019-02-18 20:14

Seems like you have build-tools 21.0.2 installed but you are using 20.0.0 in your gradle buildTootlsVersion Also you have defined repositories twice and you need it only in the first gradle block.

Try changing the build tools version.

查看更多
登录 后发表回答