I recently updated my SDK Tools and the ADT Plugin to the latest version (got Android 2.3 as well). This required a few changes in my config (mainly I added proguard.config=procfg.txt
to default.properties
so that I could use the built-in support for proguard), and removed the old proguard config from build.xml
. Now, my problem is that Eclipse gives a pretty lengthy error (which I'll embed at the end of the question) The problem is that I did not recently add any libraries. And again, compiling using ant
works as expected:
$ ant debug
Buildfile: /home/felix/workspace/XXX/build.xml
[setup] Android SDK Tools Revision 8
[setup] Project Target: Android 2.3
[setup] API level: 9
[setup]
[setup] ------------------
[setup] Resolving library dependencies:
[setup] No library dependencies.
[setup]
[setup] ------------------
[setup]
[setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (9)
[setup]
[setup] Importing rules file: tools/ant/main_rules.xml
-debug-obfuscation-check:
-set-debug-mode:
-compile-tested-if-test:
-dirs:
[echo] Creating output directories if needed...
-pre-build:
-resource-src:
[echo] Generating R.java / Manifest.java from the resources...
-aidl:
[echo] Compiling aidl files into Java classes...
-pre-compile:
compile:
[javac] /opt/android-sdk/tools/ant/main_rules.xml:361: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to /home/felix/workspace/XXX/bin/classes
-post-compile:
-obfuscate:
-dex:
[echo] Converting compiled files and external libraries into /home/felix/workspace/XXX/bin/classes.dex...
-package-resources:
[echo] Packaging resources
[aapt] Creating full resource package...
-package-debug-sign:
[apkbuilder] Creating XXX-debug-unaligned.apk and signing it with a debug key...
debug:
[echo] Running zip align on final apk...
[echo] Debug Package: /home/felix/workspace/XXX/bin/XXX-debug.apk
BUILD SUCCESSFUL
Total time: 6 seconds
However, Eclipse is whining about repeated classes or something:
[2010-12-08 15:06:43 - XXX]: Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/android/vending/licensing/AESObfuscator;
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processClass(Main.java:338)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:315)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:266)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processOne(Main.java:284)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:220)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.run(Main.java:176)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2010-12-08 15:06:43 - XXX]: Dx at java.lang.reflect.Method.invoke(Method.java:597)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
[2010-12-08 15:06:43 - XXX]: Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/android/vending/licensing/AESObfuscator;
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processClass(Main.java:338)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:315)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:266)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processOne(Main.java:284)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:220)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.run(Main.java:176)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2010-12-08 15:06:43 - XXX]: Dx at java.lang.reflect.Method.invoke(Method.java:597)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
[2010-12-08 15:06:43 - XXX]: Dx
trouble processing:
[2010-12-08 15:06:44 - XXX]: Dxclass name (com/android/vending/licensing/LicenseCheckerCallback) does not match path (classes/com/android/vending/licensing/LicenseCheckerCallback.class)
...while parsing classes/com/android/vending/licensing/LicenseCheckerCallback.class
...while processing classes/com/android/vending/licensing/LicenseCheckerCallback.class
[2010-12-08 15:06:44 - XXX]: Dx
trouble processing:
[2010-12-08 15:06:44 - XXX]: Dxclass name (com/android/vending/licensing/NullDeviceLimiter) does not match path (classes/com/android/vending/licensing/NullDeviceLimiter.class)
...while parsing classes/com/android/vending/licensing/NullDeviceLimiter.class
...while processing classes/com/android/vending/licensing/NullDeviceLimiter.class
[2010-12-08 15:06:44 - XXX]: Dx
trouble processing:
[2010-12-08 15:06:44 - XXX]: Dxclass name (com/android/vending/licensing/PreferenceObfuscator) does not match path (classes/com/android/vending/licensing/PreferenceObfuscator.class)
...while parsing classes/com/android/vending/licensing/PreferenceObfuscator.class
...while processing classes/com/android/vending/licensing/PreferenceObfuscator.class
[2010-12-08 15:06:44 - XXX]: Dx
... --------------------------------------- ...
... and so on for every class in my project ...
... --------------------------------------- ...
[2010-12-08 15:06:44 - XXX]: Dx229 warnings
[2010-12-08 15:06:44 - XXX]: Dx2 errors; aborting
[2010-12-08 15:06:44 - XXX] Conversion to Dalvik format failed with error 1
Why is this happening? Why is it looking in classes/
, which doesn't exist?
The project worked without any problems until yesterday, and it still works if compiled via ant
.
Edit: The usual Fix project properties
and Clean project
don't work.
Edit 2: The errors keep coming and going. I do not have any .jar
s. Also, I'm using ProGuard. At some point ant stopped working as well (can't remember the errors), I did a
touch `find .`
and things started working again (both Eclipse and ant), for a while. Now Eclipse spews errors again. What's going on!?
Edit 3: It would seem the problem lies with the ProGuard integration. Whenever I comment out the proguard.config
directive from default.properties
and to a project refresh + clean, it works. This is pretty weird because, when building in debug mode, Eclipse shouldn't obfuscate / optimize the code via ProGuard anyway. Also, my ProGuard configuration works just fine via Ant.
Edit 4: Eclipse + Ant + ProGuard = not getting along together. If I close Eclipse, uncomment my proguard.config
directive, build with Ant, comment my proguard.config
directive, open Eclipse, Eclipse starts spewing errors. It would seem like Ant is leaving something behind. If I do a clean project it works just fine.
It seems the problem was with Eclipse and Ant not getting along together. I've stopped using Ant at all and now Eclipse seems to be working fine (I can even export signed & obfuscated packages using the wizard).
So, to conclude, Ant + Eclipse = a big no no.
Execute "ant clean" then clean your project in Eclipse. Make sure you save your proguard generated files (/bin/proguard) before doing this because the "bin" and "gen" dirs get deleted. Annoying solution, but that is how I got around this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With