我在gradle构建消息中遇到以下错误 我试过很多与此问题相关的Stackoverflow帖子。但没有什么对我有用。
错误:任务执行失败 ':应用程序:transformClassesWithJarMergingForDebug'。
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目: 机器人/支撑/注解/ IntegerRes.class
修改
应用/的build.gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.golive.vernon"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
//incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/gcm.jar')
compile files('libs/glide-3.6.1.jar')
compile files('libs/httpcore-4.3-beta1.jar')
compile files('libs/httpmime-4.3.jar')
compile files('libs/universal-image-loader-1.9.5.jar')
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile project(':facebook')
compile project(':InstaLibrary')
compile project(':simple-crop-image-lib')
compile files('libs/twitter4j-core-4.0.4.jar')
compile 'com.android.support:multidex:1.0.1'
}
下面我添加了libs截图:
下面我添加了依赖项列表:
清单:
>
Appcontroller.java:
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
mInstance = this;
}
答案 0 :(得分:1)
在您的Gradle中使用支持编译:multidex并添加dexOptions
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
..............
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
//incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile files('libs/gcm.jar')
compile files('libs/glide-3.6.1.jar')
compile files('libs/httpcore-4.3-beta1.jar')
compile files('libs/httpmime-4.3.jar')
compile files('libs/universal-image-loader-1.9.5.jar')
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile project(':facebook')
compile project(':InstaLibrary')
compile project(':simple-crop-image-lib')
compile files('libs/twitter4j-core-4.0.4.jar')
compile 'com.android.support:multidex:1.0.1'
}
在 AndroidManifest.xml 中添加以下行 android:name
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>
如果还是错误而不是编译
compile 'com.google.android.gms:play-services:+'
取代
compile 'com.google.android.gms:play-services-maps:8.4.0'
答案 1 :(得分:0)
跟着呃。 Arjun saini回答提到添加multidex&amp;许可证,我已更正添加facebook sdk来解决此问题:
之前,我通过添加导入模块添加了Facebook库。错误方式:
编译项目(&#39;:facebook&#39;)
正确的方式:
compile&#39; com.facebook.android:facebook-android-sdk:4.5.0&#39;
还有顶级build.gradle :
allprojects {
repositories {
jcenter() // This is the default repo
mavenCentral() // This is the Maven Central repo
}
}