When I received the "Ill-advised or mistaken usage of a core class" error while attempting to build my application, I searched through Stackoverflow and, as some suggested, used ant and jarjar to build the application.
The ant build failed at the dx step with the error reported below.
I searched the web for suggestions on how to fix the "can't coerce" error (see below) and found nothing that helped.
Please note that the jarjar step in the ant build seemed to work. When I checked the content of the java directories in bin/repackagedclasses.jar, they were empty with all of their content transferred to the equivalent renamed directories (/java).
Please also note that the suggestions I followed (using ant and jarjar) were more than two years old and applied to android 2.x. It is possible (likely?) that with android 4 and related infrastructure they will not work, just a guess.
One last point. I changed dx in sdk/platform-tools as follows:
exec java $javaOpts -jar "$jarpath" "$@"
exec java $javaOpts -jar "$jarpath" --core-library "$@"
With or without the above change, made no difference to the ant build or the Eclipse build.
-dex:
[dex] Converting compiled files and external libraries into /home/adonnini/workspace3/CommManagerN6/bin/classes.dex...
[dx]
[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] com.android.dx.util.ExceptionWithContext: can't coerce string{"android.permission.ACCESS_CACHE_FILESYSTEM"} to Lcommmanager/java/lang/String;
[dx] at com.android.dx.util.ExceptionWithContext.withContext(ExceptionWithContext.java:46)
[dx] at com.android.dx.dex.cf.CfTranslator.processFields(CfTranslator.java:176)
[dx] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:133)
[dx] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:87)
[dx] at com.android.dx.command.dexer.Main.processClass(Main.java:483)
[dx] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[dx] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[dx] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[dx] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[dx] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[dx] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[dx] at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[dx] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:206)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:174)
[dx] at com.android.dx.command.Main.main(Main.java:91)
[dx] Caused by: java.lang.UnsupportedOperationException: can't coerce string{"android.permission.ACCESS_CACHE_FILESYSTEM"} to Lcommmanager/java/lang/String;
[dx] at com.android.dx.dex.cf.CfTranslator.coerceConstant(CfTranslator.java:210)
[dx] at com.android.dx.dex.cf.CfTranslator.processFields(CfTranslator.java:160)
[dx] ... 14 more
[dx] ...while processing ACCESS_CACHE_FILESYSTEM Lcommmanager/java/lang/String;
[dx] ...while processing android/commmanager/Manifest$permission.class
[dx]
[dx] 1 error; aborting
BUILD FAILED
/home/adonnini/workspace3/CommManagerN6/build.xml:964: The following error occurred while executing this line:
/home/adonnini/workspace3/CommManagerN6/build.xml:376: null returned: 1