android – 使用Parse和Multidex重复输入
作者:互联网
我的项目是一个使用Parse的聊天应用程序.添加其他依赖项后,此问题开始出现:
Error:Execution failed for task ‘:app:dexDebug’.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/usr/lib/jvm/java-7-oracle/bin/java” finished with non-zero exit value 2
在StackOverflow中搜索,一些人告诉我它可能是Android的65K限制.
所以,要解决我按照以下步骤:
1 – 添加Multidex
DefaultConfig {
multiDexEnabled true
}
和
compile 'com.android.support:multidex:1.0.0'
https://developer.android.com/tools/building/multidex.html
2 – 在Android Gradle设置中启用Jumbo模式
dexOptions {
jumboMode = true
}
我清理了项目并运行了gradle构建.它没有产生任何错误.大!但是当我点击“运行应用”时,它会在下面生成此错误.
Error: Execution failed for task ‘: app:
packageAllDebugClassesForMultiDex’. > Java.util.zip.ZipException:
duplicate entry: bolts / AggregateException.class
如果我删除依赖项’com.parse.bolts:bolts-android:1.’“运行应用程序”有效,但我不能没有Parse的依赖.
这是我的Gradle构建脚本:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "br.com.triangulum.mink"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse*.jar')
compile project('libraries:httprequest')
compile project('libraries:cameralibrary')
compile project('libraries:bgarefreshlayout')
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:design:+'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.afollestad:material-dialogs:0.7.4.0'
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'de.greenrobot:eventbus:2.4.+'
compile'com.edmodo:cropper:1.0.+'
compile 'com.github.ksoichiro:android-observablescrollview:+'
compile 'com.etsy.android.grid:library:1.0.5'
compile('com.mikepenz:actionitembadge:3.0.2@aar') {
transitive = true
}
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.android.support:multidex:1.0.+'
}
解决方法:
试着改变这个:
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
对此:
compile('com.android.support:multidex:1.0.0');
有时使用bolds模块来修复Duplicated dexLibs
问候
标签:android,gradle,parse-platform,multidex 来源: https://codeday.me/bug/20190628/1315482.html