I'm trying to add libraries from maven, specifically, Crouton library.
I can add it, Sync and use the Crouton object in my project, but when trying to run the app, i get this
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':timetable:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Program Files (x86)\Android\android-studio\sdk\build-tools\19.0.1\dx.bat --dex --output D:\Developer\TimeTable3\timetable\build\pre-dexed\debug\crouton-library-1.8.2-c968ce53b92080dec516373cec51e9993ca5051f.jar C:\Users\Shahar\.gradle\caches\modules-2\files-2.1\de.keyboardsurfer.android.widget\crouton-library\1.8.2\725b0873131748c8c1bf2e1a27465e5bea857ab3\crouton-library-1.8.2.jar
Error Code:
1
Output:
error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name (de/keyboardsurfer/android/widget/crouton/Configuration$1) does not match path (release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class
EDIT: gradle file added
this is my gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 15
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'de.keyboardsurfer.android.widget:crouton-library:1.8.2'
compile files('libs/ActiveAndroid.jar')
}
if i use all three without "de.keyboardsurfer.android.widget:crouton-library:1.8.2"
then it all works ok.
Yeah, the build was broken. I didn't notice it locally. But thanks to you it's fixed and deployed to maven central. Clear your cache to get the new build of 1.8.2.
It looks like the crouton library is mispackaged. If you examine its contents:
jar -tf /Users/sbarta/.gradle/caches/modules-2/files-2.1/de.keyboardsurfer.android.widget/crouton-library/1.8.2/725b0873131748c8c1bf2e1a27465e5bea857ab3/crouton-library-1.8.2.jar
META-INF/
META-INF/MANIFEST.MF
release/
release/de/
release/de/keyboardsurfer/
release/de/keyboardsurfer/android/
release/de/keyboardsurfer/android/widget/
release/de/keyboardsurfer/android/widget/crouton/
release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class
release/de/keyboardsurfer/android/widget/crouton/Configuration$Builder.class
release/de/keyboardsurfer/android/widget/crouton/Configuration.class
release/de/keyboardsurfer/android/widget/crouton/Crouton.class
release/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.class
release/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.class
release/de/keyboardsurfer/android/widget/crouton/Manager$1.class
release/de/keyboardsurfer/android/widget/crouton/Manager$Messages.class
release/de/keyboardsurfer/android/widget/crouton/Manager.class
release/de/keyboardsurfer/android/widget/crouton/Style$1.class
release/de/keyboardsurfer/android/widget/crouton/Style$Builder.class
release/de/keyboardsurfer/android/widget/crouton/Style.class
release/de/keyboardsurfer/mobile/
release/de/keyboardsurfer/mobile/app/
release/de/keyboardsurfer/mobile/app/android/
release/de/keyboardsurfer/mobile/app/android/widget/
release/de/keyboardsurfer/mobile/app/android/widget/crouton/
release/de/keyboardsurfer/mobile/app/android/widget/crouton/BuildConfig.class
Everything is inside a release directory, but based on the error message, Configuration$1.class is in the package de.keyboardsurfer.android.widget.crouton (without release). You can contact the library author, or you could disassemble the jar, pull everything inside the release directory one level up, and repackage it.
The packing is wrong for the library on maven repository. So by the time it is corrected by author you can use the this libary as module by downloading and adding it in your project structure .
The path is https://github.com/keyboardsurfer/Crouton
I have informed author Benjamin Weiss on Google plus regarding the same.
Related
I updated Android Studio to the latest version, and let it "fix the project" and the like - but now my project does not compile, gives me
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\VGA\AndroidStudio\sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --output D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\dex\debug --input-list=D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
However, this isn't resolved by just multidexing, because when I added this:
defaultConfig {
...
multiDexEnabled = true
}
This happens
D:\VGA\AndroidStudio\sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --multi-dex --main-dex-list D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\multi-dex\debug\maindexlist.txt --output D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\dex\debug --input-list=D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
3
Output:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.cf.code.ConcreteMethod.makeSourcePosistion(ConcreteMethod.java:254)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:306)
at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:612)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:367)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:787)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:742)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
at com.android.dx.command.dexer.Main.run(Main.java:243)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
I tried changing the build tools to latest
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
Because by default it changed to 20.0.0 which seemed to use the SDK for 4.4W, but this didn't fix my problem.
Does anyone know what could be wrong here?
EDIT:
Changing the build tools or the compile SDK did not fix the problem.
Turning the app into a multi-dex project and also adding the following
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
...
multiDexEnabled true
}
...
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
Fixed the build process, however this still seems to be just a "treatment" but not a fix to the problem.
I am not sure if this is related, but this is my dependency list:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.7.1'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude module: 'junit'
}
compile 'com.google.android.gms:play-services:6.5.87'
}
The only new dependency since then has been the last line, which I added as per https://developer.android.com/google/gcm/client.html so I don't think that is the source of the problem.
EDIT2:
Yes, it was the source of the problem. As I needed Google Cloud Messaging, I replaced that dependency with the base as per http://developer.android.com/google/play-services/setup.html#split :
compile 'com.google.android.gms:play-services-base:6.5.87'
And it fixed the problem. Thank you for the help.
EDIT3:
As of play services 7.0.0, the GCM is in
compile 'com.google.android.gms:play-services-gcm:7.0.0'
EDIT4:
Play Services updated to 7.3.0.
Please keep check of the latest version here: http://developer.android.com/google/play-services/setup.html#split
The error means you have reached maximum method count in your app. That does include any libraries that you use for your project.
There are two ways to tackle the issue:
Get rid of any third-party libraries that you don't really need. If you use google play services that might contribute a lot to the method count. Fortunately as of the latest play-services release it is possible to include only parts of the framework.
Use a multi dex setup for your application.
I am phasing these problem & in my case used these link to overcome that error successfully..!!!
The DEX 64k limit is not a problem anymore, almost
To sum it up, adding multidex support:
In case of
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
Google decided to release an official solution for this in the form of the MultiDex Support Library.
dependencies {
...
compile 'com.android.support:multidex:'
...
}
Then enable multi-dexing by setting the multiDexEnabled flag in the buildType or productFlavor section of your gradle configuration.
defaultConfig {
...
multiDexEnabled true
...
}
Then depending on your project, you have 3 options:
If you haven’t created your own Application class, simply declare android.support.multidex.MultiDexApplication as your application class in AndroidManifest.xml
....
android:name="android.support.multidex.MultiDexApplication"
...
If you already have your own Application class, make it extend android.support.multidex.MultiDexApplication instead of android.app.Application
If your Application class is extending some other class and you don’t want to or can’t change it, override attachBaseContext() as shown below:
public class MyApplication extends FooApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Your compilation process might run out of memory.
To fix it, set the following dex options in the ‘android’ closure –
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
More to know about multidex is here: http://developer.android.com/tools/building/multidex.html
Another link which becomes helping to solve a these error : Referance Link
I am working with Android Studio and I try to integre the MonkeyTalk agent into the APK with Ant.
Basically I have followed the follow steps:
1.Download MonkeyTalk 2.0.1 Pro Beta
2.Create a new empty folder on desktop titled “example” or whatever you like
3.Copy monkeytalkpro/agents/android/monkeytalk-agent-2.0.1.jar into “example” directory
4.Copy monkeytalkpro/ant/monkeytalkpro-ant-2.0.1.beta.jar into “example” directory
5.Copy your apk file into “example” directory (named myapp.apk for this example)
6.Create a new file called build.xml in “example” directory and fill it with the following:
<target name="instru">
<mt:instrument
srcfile="myapp.apk"
destfile="myapp-post-instrumented.apk"
agent="monkeytalk-agent-2.0.1.jar"
androidsdk="/path/to/your/sdk"
androidtarget="android-21"
log="log.txt"
verbose="true" />
</target>
7.Open terminal and cd into your “example” directory
8.Issue command ant instru -lib monkeytalkpro-ant-2.0.1.beta.jar
9.The command should run and then produce a monkeytalk compatible apk in your “example” directory titled “myapp-post-instrumented.apk”
WARNING: There seems to be a bug where the instrumentation process
will also place another file in your “example” directory titled
“myapp-instrumented.apk”, but this file will be empty. So make sure
your destination file is not titled “myapp-instrumented.apk” in your
build.xml file or this empty file will overwrite your monkeytalk
compatible file.
Source: http://w3facility.org/question/android-studio-and-monkeytalk/#answer-23016422
There are two differences between I have done and the original steps:
The actual version of MonkeyTalk agent and the ant jar is 2.0.10, not 2.0.1
With the compilation tool 21.1.2, the APKTool integrated in the monkeytalkpro-ant-2.0.10.beta.jar is not able to extract the files. So, I have updated the APKTool and generate a new jar. You can find it here:
https://www.dropbox.com/s/qsjaz5g15hy9i7k/monkeytalkpro-ant-2.0.10.beta.mod.jar?dl=0
But event with this fix, ant is not capable to "instrument" the APK. Ant has problem to dex the file.
Any help and suggestion is appreciated.
P.d.1: I have tried to compile Android studio with gradle android plugin of aspectj, from uphyca(v0.9.7), but it does not works. It compiles the project but it crashes when I try to launch it.
P.d.2: Here are some logs:
-pre-compile:
-compile:
-post-compile:
-obfuscate:
-dex:
[dex] input: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/classes
[dex] input: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/monkeytalk-agent-2.0.10.jar
[dex] input: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/weaved.jar
[dex] Pre-Dexing /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/monkeytalk-agent-2.0.10.jar
-> monkeytalk-agent-2.0.10-3ffc60da466c609b3dc28c1c7533ad15.jar
[dex] Pre-Dexing /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/weaved.jar
-> weaved-0d60e12eb7c45a42662ee42c5398a922.jar
[dx]
[dx] EXCEPTION FROM SIMULATION:
[dx] local 0005: invalid
[dx]
[dx] ...at bytecode offset 0000000b
[dx] locals[0000]: Landroid/support/v7/widget/ActionMenuView;
[dx] locals[0001]: Landroid/view/ViewGroup$LayoutParams;
[dx] locals[0002]:
[dx] locals[0003]:
[dx] locals[0004]:
[dx] locals[0005]:
[dx] ...while working on block 000b
[dx] ...while working on method generateLayoutParams:(Landroid/view/ViewGroup$LayoutParams;)Landroid/support/v7/widget/ActionMenuView$LayoutParams;
[dx] ...while processing generateLayoutParams (Landroid/view/ViewGroup$LayoutParams;)Landroid/support/v7/widget/ActionMenuView$LayoutParams;
[dx] ...while processing android/support/v7/widget/ActionMenuView.class
[dx]
[dx] 1 error; aborting
BUILD FAILED
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:892:
The following error occurred while executing this line:
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:894:
The following error occurred while executing this line:
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:906:
The following error occurred while executing this line:
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:283:
null returned: 1
Total time: 14 seconds : ERROR: Process exited with an error: 1 (Exit
value: 1)
instrumented APK file was not created at:
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/app-debug-debug.apk
Error instrumenting apk '/Users/monkeyTalk/app-debug.apk':
instrumented APK file was not created at:
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/app-debug-debug.apk
com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor$InstrumentationException:
instrumented APK file was not created at:
/private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/app-debug-debug.apk
at
com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor.copyInstrumentedApk(AndroidInstrumentor.java:244)
at
com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor.beginInstrumentation(AndroidInstrumentor.java:173)
at
com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor.instrumentApk(AndroidInstrumentor.java:130)
at
com.gorillalogic.monkeytalk.ant.InstrumentTask.execute(InstrumentTask.java:62)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348) at
org.apache.tools.ant.Target.execute(Target.java:390) at
org.apache.tools.ant.Target.performTasks(Target.java:411) at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at
org.apache.tools.ant.Main.runBuild(Main.java:809) at
org.apache.tools.ant.Main.startAnt(Main.java:217) at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
And here is the complete log:
https://www.dropbox.com/s/y3mo9ifgalpzf29/log.txt?dl=0
Update
This is the content of the build.gradle file.
apply plugin: 'com.android.application'
apply plugin: 'robolectric'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.jiahaoliuliu.monkeytalk"
minSdkVersion 14
targetSdkVersion 19
versionCode 52
versionName "1.9999"
multiDexEnabled true
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
monkeytalk.initWith(buildTypes.debug)
monkeytalk {
applicationIdSuffix ".monkey"
}
}
sourceSets {
androidTest {
setRoot('src/test')
}
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.etsy.android.grid:library:1.0.5'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.google.android.gms:play-services-base:6.5.+'
compile 'com.google.android.gms:play-services-wallet:6.5.+'
compile 'com.google.android.gms:play-services-ads:6.5.+'
compile 'com.google.android.gms:play-services-maps:6.5.+'
compile 'com.google.android.gms:play-services-drive:6.5.+'
compile 'com.google.android.gms:play-services-appindexing:6.5.+'
compile 'com.google.android.gms:play-services-location:6.5.+'
compile 'com.google.android.gms:play-services-identity:6.5.+'
compile 'com.google.android.gms:play-services-plus:6.5.+'
compile 'com.android.support:multidex:1.0.0'
compile project(':Adjust')
compile project(':aFileChooser-cbccac1d1cb74a6d57d25c5ded61e4bf4fc40c91')
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:recyclerview-v7:+'
androidTestCompile 'org.robolectric:robolectric:2.4'
androidTestCompile('junit:junit:4.12')
androidTestCompile('org.mockito:mockito-core:1.10.19')
}
}
robolectric {
include '**/*Test.class'
}
I was facing the same issue but now I am able to instrument the apk.
You should have apk in debug mode. Do NOT add any monkeytalk libs dependencies in your android studio. Add GET_TASKS permission in app/AndroidManifest.xml. In version 21 this api is depreciated so you need to set lower targetsdkversion say 19.
If you compile your sdk with lower version you will be able to instrument the apk successfully. :)
Cheers,
Suman
I updated Android Studio to the latest version, and let it "fix the project" and the like - but now my project does not compile, gives me
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\VGA\AndroidStudio\sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --output D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\dex\debug --input-list=D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
However, this isn't resolved by just multidexing, because when I added this:
defaultConfig {
...
multiDexEnabled = true
}
This happens
D:\VGA\AndroidStudio\sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --multi-dex --main-dex-list D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\multi-dex\debug\maindexlist.txt --output D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\dex\debug --input-list=D:\VGA\Projects\Sales-App\Android-Project\svn\android\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
3
Output:
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.cf.code.ConcreteMethod.makeSourcePosistion(ConcreteMethod.java:254)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:306)
at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:612)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:367)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:787)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:742)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
at com.android.dx.command.dexer.Main.run(Main.java:243)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
I tried changing the build tools to latest
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
Because by default it changed to 20.0.0 which seemed to use the SDK for 4.4W, but this didn't fix my problem.
Does anyone know what could be wrong here?
EDIT:
Changing the build tools or the compile SDK did not fix the problem.
Turning the app into a multi-dex project and also adding the following
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
...
multiDexEnabled true
}
...
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
Fixed the build process, however this still seems to be just a "treatment" but not a fix to the problem.
I am not sure if this is related, but this is my dependency list:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.7.1'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude module: 'junit'
}
compile 'com.google.android.gms:play-services:6.5.87'
}
The only new dependency since then has been the last line, which I added as per https://developer.android.com/google/gcm/client.html so I don't think that is the source of the problem.
EDIT2:
Yes, it was the source of the problem. As I needed Google Cloud Messaging, I replaced that dependency with the base as per http://developer.android.com/google/play-services/setup.html#split :
compile 'com.google.android.gms:play-services-base:6.5.87'
And it fixed the problem. Thank you for the help.
EDIT3:
As of play services 7.0.0, the GCM is in
compile 'com.google.android.gms:play-services-gcm:7.0.0'
EDIT4:
Play Services updated to 7.3.0.
Please keep check of the latest version here: http://developer.android.com/google/play-services/setup.html#split
The error means you have reached maximum method count in your app. That does include any libraries that you use for your project.
There are two ways to tackle the issue:
Get rid of any third-party libraries that you don't really need. If you use google play services that might contribute a lot to the method count. Fortunately as of the latest play-services release it is possible to include only parts of the framework.
Use a multi dex setup for your application.
I am phasing these problem & in my case used these link to overcome that error successfully..!!!
The DEX 64k limit is not a problem anymore, almost
To sum it up, adding multidex support:
In case of
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
Google decided to release an official solution for this in the form of the MultiDex Support Library.
dependencies {
...
compile 'com.android.support:multidex:'
...
}
Then enable multi-dexing by setting the multiDexEnabled flag in the buildType or productFlavor section of your gradle configuration.
defaultConfig {
...
multiDexEnabled true
...
}
Then depending on your project, you have 3 options:
If you haven’t created your own Application class, simply declare android.support.multidex.MultiDexApplication as your application class in AndroidManifest.xml
....
android:name="android.support.multidex.MultiDexApplication"
...
If you already have your own Application class, make it extend android.support.multidex.MultiDexApplication instead of android.app.Application
If your Application class is extending some other class and you don’t want to or can’t change it, override attachBaseContext() as shown below:
public class MyApplication extends FooApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Your compilation process might run out of memory.
To fix it, set the following dex options in the ‘android’ closure –
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
More to know about multidex is here: http://developer.android.com/tools/building/multidex.html
Another link which becomes helping to solve a these error : Referance Link
I have imported a project from Eclipse into Android Studio 1.0.1 that consists in an Android Library Project (RuletaAfortunadaCore) and an Android Project (RuletaAfortunada), also have some third parties library dependencies. During the import everything seemed fine, but now when I try to build it I get this error message from Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ruletaAfortunadaCore:proguardRelease'.
> java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
The whole output from the start of the building process:
Executing tasks: [clean, :ruletaAfortunada:compileDebugSources, :facebookSDK:compileDebugSources, :ruletaAfortunadaCore:compileDebugSources]
Configuration on demand is an incubating feature.
:facebookSDK:clean
:ruletaAfortunada:clean UP-TO-DATE
:ruletaAfortunadaCore:clean
:facebookSDK:compileLint
:facebookSDK:copyReleaseLint UP-TO-DATE
:facebookSDK:mergeReleaseProguardFiles UP-TO-DATE
:facebookSDK:preBuild
:facebookSDK:preReleaseBuild
:facebookSDK:checkReleaseManifest
:facebookSDK:prepareReleaseDependencies
:facebookSDK:compileReleaseAidl
:facebookSDK:compileReleaseRenderscript
:facebookSDK:generateReleaseBuildConfig
:facebookSDK:generateReleaseAssets UP-TO-DATE
:facebookSDK:mergeReleaseAssets
:facebookSDK:generateReleaseResValues UP-TO-DATE
:facebookSDK:generateReleaseResources
:facebookSDK:packageReleaseResources
:facebookSDK:processReleaseManifest
:facebookSDK:processReleaseResources
:facebookSDK:generateReleaseSources
:facebookSDK:compileReleaseJava
:facebookSDK:processReleaseJavaRes UP-TO-DATE
:facebookSDK:packageReleaseJar
:facebookSDK:compileReleaseNdk
:facebookSDK:packageReleaseJniLibs UP-TO-DATE
:facebookSDK:packageReleaseLocalJar
:facebookSDK:packageReleaseRenderscript UP-TO-DATE
:facebookSDK:bundleRelease
:ruletaAfortunada:preBuild
:ruletaAfortunada:preDebugBuild
:ruletaAfortunada:checkDebugManifest
:ruletaAfortunada:preReleaseBuild
:ruletaAfortunadaCore:compileLint
:ruletaAfortunadaCore:copyReleaseLint UP-TO-DATE
:ruletaAfortunadaCore:preBuild
:ruletaAfortunadaCore:preReleaseBuild
:ruletaAfortunadaCore:checkReleaseManifest
:ruletaAfortunadaCore:preDebugBuild
:ruletaAfortunadaCore:preDebugTestBuild
:ruletaAfortunadaCore:prepareComAndroidSupportSupportV42100Library
:ruletaAfortunadaCore:prepareComGoogleAndroidGmsPlayServices6587Library
:ruletaAfortunadaCore:prepareRuletaAfortunadaFacebookSDKUnspecifiedLibrary
:ruletaAfortunadaCore:prepareReleaseDependencies
:ruletaAfortunadaCore:compileReleaseAidl
:ruletaAfortunadaCore:compileReleaseRenderscript
:ruletaAfortunadaCore:generateReleaseBuildConfig
:ruletaAfortunadaCore:generateReleaseAssets UP-TO-DATE
:ruletaAfortunadaCore:mergeReleaseAssets
:ruletaAfortunadaCore:generateReleaseResValues UP-TO-DATE
:ruletaAfortunadaCore:generateReleaseResources
:ruletaAfortunadaCore:mergeReleaseResources
:ruletaAfortunadaCore:processReleaseManifest
:ruletaAfortunadaCore:processReleaseResources
:ruletaAfortunadaCore:generateReleaseSources
:ruletaAfortunadaCore:compileReleaseJava
:ruletaAfortunadaCore:extractReleaseAnnotations
:ruletaAfortunadaCore:mergeReleaseProguardFiles UP-TO-DATE
:ruletaAfortunadaCore:compileReleaseNdk
:ruletaAfortunadaCore:packageReleaseJniLibs UP-TO-DATE
:ruletaAfortunadaCore:packageReleaseRenderscript UP-TO-DATE
:ruletaAfortunadaCore:packageReleaseResources
:ruletaAfortunadaCore:proguardRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ruletaAfortunadaCore:proguardRelease'.
> java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
The contents of the build.gradle file for such library project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 13
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:+'
compile files('libs/chartboost.jar')
compile files('libs/mint-4.0.7.jar')
}
UPDATE: I have realized that the Android Library Project named RuletaAfortunadaCore can be build as an standalone project or made as a module without problems at all. It only fails to build when building the whole RuletaAfortunada Android Project that uses it.
The build.gradle file for such Android Project is the default one created by Android Studio, I think, so has nothing interesting inside. Anyway, here it is, just in case:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
This is the settings.gradle:
include ':facebookSDK'
include ':ruletaAfortunadaCore'
include ':ruletaAfortunada'
And finally, just to have all of them, this is the facebookSDK module build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 9
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/bolts-android-1.1.2.jar')
}
As suggested by one guy which answer seem to have vanished now :-?, the solution for me has been to set minifyEnabled to false in the build.gradle of my Library Project. As far as I have it set as true for the Android Project itself, proguard will be executed anyway and the error have disappeared.
I've found some useful info here: http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0
One notable difference is that runProguard was changed to minifyEnabled.
However, after completing the steps from this migration topic, I still run into the same build error.
I have been trying allot to fix this problem. I cant figure out what to do, i get stuck on the following output error when i want to debug the project.
Execution failed for task ':inspectoratecalculator:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\FlikFlak\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dex\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\classes\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dependency-cache\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\android-support-v4-9fdb020c999e0f186e4aef883e8a4b8676e1e3ac.jar
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\classes-3cbf09a1ad548c6398f541ca3aae99491954a4cd.jar
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\support-v4-19.1.0-ce3af6ab4e02f6c952693d6706242484504a4302.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
-------------------------------------BUILD.GRADLE-----------------------------------
apply plugin: 'android'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
Remove the v4 JAR file from your project/module jar directory as #rupps mentioned. Also remove your "excludes" piece from the configuration. Because you're using the the appcompat-v7 dependency, you will automatically pick up the v4 support library via Maven.
This may occur because your have same jar referenced during building of project multiple time , may be that jar is already included some other module or library module.double check and make sure that this condition does not exist.
We have faced this kind of problem earlier.
I'm not sure you have same issue with me, but my issue is I use a JDK 1.8 to compile the code, which not supported by android dx tools.
The fix is change the SDK path from 1.8 to a 1.7 JDK in Project's Module Settings.
Reference this for detail config in Mac:
https://stackoverflow.com/a/24680375/1043032