我创建了一个Android应用程序&正在API级别21以上运行。 但不能在API级别21以下运行。
这是错误日志:
错误:任务':app:transformClassesWithJarMergingForDebug'执行失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android / support / v4 / accessibilityservice / AccessibilityServiceInfoCompat $ AccessibilityServiceInfoVersionImpl.class 帮助我完成
以下是我的gradle代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "*******"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
packagingOptions {
exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
}
dependencies {
compile fileTree(exclude: 'android-support-*.jar', dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':simple-crop-image-lib')
// compile 'com.github.navasmdc:MaterialDesign:+'
compile project(':material-login')
compile 'com.android.support:multidex:1.0.1'
compile ('com.android.support:appcompat-v7:23.4.0'){
exclude module: 'support-v4'
}
}
答案 0 :(得分:1)
首先使用
编译构建编译'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"
>
在 build.gradle 中也添加
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
}