多重jar, lib包含时,出现jar包含错误的解决方法

来源:互联网 发布:创维21t15aa总线数据 编辑:程序博客网 时间:2024/06/07 21:14

我想添加支持库 notification 项目第一 time 。但得到一些错误

Error:Execution failed for task
‘:app:transformClassesWithDexForDebug’.
com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process ‘command
‘C:\Program Files\Java\jdk1.8.0_40\bin\java.exe” finished with
non-zero exit value 2
不知道如何解决,希望有一个的给一个暗示。 我 build 格拉德尔

apply plugin: ‘com.android.application’

android {
compileSdkVersion 23
buildToolsVersion “23.0.1”

defaultConfig {
applicationId “com.union.noti”
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName “1.0”
multiDexEnabled true
}
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.0.1’
compile ‘com.android.support:design:23.0.1’
compile files(‘libs/android-support-v4.jar’)
compile ‘com.android.support:multidex:1.0.1’
}
添加我现在得到的 multidex 时的错误

Error:Execution failed for task ‘:app:transformClassesWithJarMergingForDebug’.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/LayoutRes.class
解决方法 1:

你为什么把 android 支持 v4.jar libs 文件夹中。如果你想要使用安卓系统支持 v4.jar 像这样︰

dependencies {
compile fileTree(include: [‘*.jar’], dir: ‘libs’)
testCompile ‘junit:junit:4.12’
compile ‘com.android.support:appcompat-v7:23.0.1’
compile ‘com.android.support:design:23.0.1’
compile ‘com.android.support:support-v4:23.1.1’
compile ‘com.android.support:multidex:1.0.1’
}
在一些地方在您的项目支持库和设计库或 appcompat 库有冲突。因为支持库也有 appcompat 在它。使用这样就可以这帮助你。让我知道,如果不成功。

0 0
原创粉丝点击