Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
698 views
in Technique[技术] by (71.8m points)

android - Gradle: Execution Failed For Task

Hi I just tried to do a example program of Android Tab Layout With Swipe. I added android support libraries in the lib folder. I added appcompat v4 and v7 in that. After that I clicked sync project with gradle files. Then I entered code then everything went and I found no error in code but when I try to run the program its showing me this error

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/ArrayRes.class

And my build.gradle file contains this

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.eugene.swipeabletablayout"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}

In my code there is no problem but I don't know why I am getting this error.

I tried to search for this issue in SOF but I didn't find any answer.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Remove the Android support libraries from the libs directory. Since you are using gradle and have indicated a compile dependency with appcompat-v7 you do not need to include the JARs manually. This is causing a conflict at build time with duplicate symbols. Listing it as a compile dependency will cause gradle to work with Maven to pull the lib automatically (and its dependencies.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...