应用程序未使用multidexEnabled启动在Android Studio中为true-著名的65k参考方法 [英] App not launching with multidexEnabled true in android studio - Famous 65k reference method
问题描述
我以前使用的是Eclipse IDE,而且由于我使用了许多来自Amazon的库,所以我开始遇到65K方法引用错误.因此,我从Eclipse转到了Android Studio最新的预览频道版本.我的摇篮看起来像:
Earlier I was using Eclipse IDE and as I have used lot of library from Amazon I started getting 65K method reference error. SO I shifted from Eclipse to Android studio latest preview channel version. My gradle looks like :
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'META-INF/LICENSE'
}
signingConfigs {
xxx {
keyAlias 'xxx'
keyPassword 'xxx'
storeFile file('path')
storePassword 'xxx'
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.xxx.app"
versionCode 4
versionName "0.4"
// Enabling multidex support.
multiDexEnabled true
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 15
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.xxx
}
debug {
signingConfig signingConfigs.xxx
minifyEnabled false
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.soundcloud.android:android-crop:1.0.0@aar'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/gcm.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/universal-image-loader-1.9.2-with-sources.jar')
compile files('libs/aspectjweaver.jar')
compile files('libs/aws-java-sdk-1.9.39.jar')
compile files('libs/commons-codec-1.6.jar')
compile files('libs/commons-logging-1.1.3.jar')
compile files('libs/freemarker-2.3.18.jar')
compile files('libs/httpclient-4.3.jar')
compile files('libs/httpcore-4.3.jar')
compile files('libs/jackson-annotations-2.3.0.jar')
compile files('libs/jackson-core-2.3.2.jar')
compile files('libs/jackson-databind-2.3.2.jar')
compile files('libs/javax.mail-api-1.4.6.jar')
compile files('libs/joda-time-2.2.jar')
compile files('libs/spring-beans-3.0.7.jar')
compile files('libs/spring-context-3.0.7.jar')
compile files('libs/spring-core-3.0.7.jar')
compile 'com.google.android.gms:play-services:7.5.0'
compile project(':flipcheckbox')
}
我的gradle构建成功,我将构建变量设置为devDebug,但是当我单击Run(绿色图标)时,该应用程序未在设备上安装.我等了45分钟,但它只是显示我的Gradle任务正在运行.
My gradle build successfully and I have set my build variant to devDebug but when i click on Run (Green icon), the app is not getting installed on device. I waited for 45 minutes but its just showing my Gradle task running.
我有扩展MultiDexApplication的应用程序类,还添加了attachBaseContext方法.
I have application class which extends MultiDexApplication and also added attachBaseContext method.
@Override
protected void attachBaseContext(Context base) {
MultiDex.install(this);
super.attachBaseContext(base);
}
我现在尝试运行该应用程序超过一天,但不幸的是,没有任何工作适用于我.我的申请表中还有其他内容吗?欢迎提出所有建议.
I am trying to run the app more than a day now and unfortunately nothing is working for me. Is there anything else I am missing in my application? All suggestions are welcome.
更新日志:-
Error: duplicate files during packaging of APK E:\Workspace\AndroidStudio\Loneous\app\build\outputs\apk\app-dev-debug-unaligned.apk
Path in archive: META-INF/LICENSE
Origin 1: E:\Workspace\AndroidStudio\Loneous\app\libs\jackson-annotations-2.3.0.jar
Origin 2: E:\Workspace\AndroidStudio\Loneous\app\libs\httpcore-4.3.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/LICENSE'
}
}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDevDebug'.
> Duplicate files copied in APK META-INF/LICENSE
File 1: E:\Workspace\AndroidStudio\Loneous\app\libs\jackson-annotations-2.3.0.jar
File 2: E:\Workspace\AndroidStudio\Loneous\app\libs\httpcore-4.3.jar
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageDevDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.tooling.BuildException: Duplicate files copied in APK META-INF/LICENSE
File 1: E:\Workspace\AndroidStudio\Loneous\app\libs\jackson-annotations-2.3.0.jar
File 2: E:\Workspace\AndroidStudio\Loneous\app\libs\httpcore-4.3.jar
at com.android.build.gradle.tasks.PackageApplication.doFullTaskAction(PackageApplication.groovy:111)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.groovy:64)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 14 more
Caused by: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File 1: E:\Workspace\AndroidStudio\Loneous\app\libs\jackson-annotations-2.3.0.jar
File 2: E:\Workspace\AndroidStudio\Loneous\app\libs\httpcore-4.3.jar
at com.android.builder.internal.packaging.Packager$JavaAndNativeResourceFilter.checkEntry(Packager.java:178)
at com.android.builder.signing.SignedJarBuilder.writeZip(SignedJarBuilder.java:260)
at com.android.builder.internal.packaging.Packager.addResourcesFromJar(Packager.java:458)
at com.android.builder.core.AndroidBuilder.packageApk(AndroidBuilder.java:1511)
at com.android.builder.core.AndroidBuilder$packageApk$11.call(Unknown Source)
at com.android.build.gradle.tasks.PackageApplication.doFullTaskAction(PackageApplication.groovy:98)
... 22 more
推荐答案
现在您正在使用Android Studio,请尝试仅包含Play服务所需的模块,而不是完整堆栈,这将大大减少方法总数:
Now that you are using Android Studio, try including only the required modules of Play Services instead of the full stack, it will greatly reduce the total methods count:
https://developers.google.com/android/guides/setup#split
也许在那之后您将不需要multidex.
Maybe you won't need multidex after that.
您还必须删除gcm.jar
并改用Play服务版本,否则项目中可能会有重复的文件,并且无法生成.
You must also remove gcm.jar
and use the Play Services version instead, otherwise you'll probably have duplicate files in your project and it won't build.
这篇关于应用程序未使用multidexEnabled启动在Android Studio中为true-著名的65k参考方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!