Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
759 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 Reply

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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...