问题
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')
}
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.
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.
UPDATED LOGS :-
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
回答1:
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
Maybe you won't need multidex after that.
Edit: 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.
来源:https://stackoverflow.com/questions/31474555/app-not-launching-with-multidexenabled-true-in-android-studio-famous-65k-refer