[Q] [Solved] Error while using dx - General Questions and Answers

im trying to convert .class to .dex using dx but im gtting an error
Code:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name (com/dummy/sprite/BuildConfig
) does not match path (BuildConfig.class)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:
520)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:4
06)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary
(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.jav
a:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.j
ava:170)
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:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing BuildConfig.class
1 error; aborting

Noobdead said:
im trying to convert .class to .dex using dx but im gtting an error
Code:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name (com/dummy/sprite/BuildConfig
) does not match path (BuildConfig.class)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:
520)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:4
06)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary
(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.jav
a:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.j
ava:170)
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:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing BuildConfig.class
1 error; aborting
Click to expand...
Click to collapse
Did you install Java 1.6?
And add it to environment path?
BTW, you could have continued it here: http://forum.xda-developers.com/general/help/compile-source-code-t3119485/post60993620
Don't create new threads unnecessarily

I have set java alright I think I know my problem see my steps
There is a folder which contain decompiled code just like apktool but it has java it like the following Downloads/Compressed/source/src/com/dummy/sprite/BuildConfig.class
I copy the class file where DX is located and run the command
I found a link which explains this but I'm noob so I can't fully understand please help http://stackoverflow.com/questions/...e-processing-class-name-and-path-do-not-match
Sent from my One X using XDA Free mobile app

Solved by using --nostrict option
Sent from my One X using XDA Free mobile app

Related

Help Resigning APK's and ZIP's

I've been looking for information on how to resign apks and update.zip files.
So far i've found a lot of tools for windows, the problem is that i use linux ubuntu.
I went ahead and tried JF's jar but i get this error
"Failed to load Main-Class manifest attribute from
testsign.jar"
Would like to know if anyone out there could guide me through the process or point me in the right direction as i've only found information regarding resigning under windows.
Thanks in advance,
Check whether you are running the correct version of Java.
What is the whole output of the Java back trace?
Cheesebaron said:
Check whether you are running the correct version of Java.
What is the whole output of the Java back trace?
Click to expand...
Click to collapse
I have Sun-JDK 6, openJDK and other java stuff installed... don't know if i need to remove or add anything...
This is what i've tried so far:
xxx:$ java testsign.jar Launcherr
Exception in thread "main" java.lang.NoClassDefFoundError: testsign/jar
Caused by: java.lang.ClassNotFoundException: testsign.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: testsign.jar. Program will exit.
xxx:~/Desktop/testsign(2)(2)$
============================================================
xxx:~/Desktop/testsign(2)(2)$ sudo java -jar testsign.jar Launcherr
Failed to load Main-Class manifest attribute from
testsign.jar
xxx:~/Desktop/testsign(2)(2)$
try this:
java -classpath testsign.jar testsign input.zip output.zip
Deicist said:
try this:
java -classpath testsign.jar testsign input.zip output.zip
Click to expand...
Click to collapse
Worked perfectly with a zip file... heres the output =)
xxx:~/Desktop/testsign(2)(2)$ java -classpath testsign.jar testsign hero.zip
xxx:~/Desktop/testsign(2)(2)$
Now... when i have the apk extracted in a folder and modify it I assume i have to make the folder an APK file again and then try java -classpath testsign.jar testsign bla.apk... i think it might work, what i need to know is how do i make the folder an apk file... is it possible to make it a .zip file and then change the extension to .apk? will that work or I need a tool to make the apk?
EDIT1: Ok... i made a zip file from the folder, changed the extension to APK and resign... i will try to unpack an aplication and install it via ASTRO... let's see how that goes...
EDIT2: ok... edit1 method didn't work... tried installing with ASTRO didnt work, tried pushing it to the phone via adb... didn't work either... HEEEEEELP! hehe..
FIGURED IT OUT: ok... i figured it out... =) making a zip file and renaming the extension to apk and signing DOES work... i was making a mistake, while packing the zip file using archiver and the folder structure was changed... i did it manually and worked perfectly... now i know how to make apks and resign them... thanks to everybody who cooperated for the patience and support... =)
pep1t0 said:
I've been looking for information on how to resign apks and update.zip files.
So far i've found a lot of tools for windows, the problem is that i use linux ubuntu.
I went ahead and tried JF's jar but i get this error
"Failed to load Main-Class manifest attribute from
testsign.jar"
Would like to know if anyone out there could guide me through the process or point me in the right direction as i've only found information regarding resigning under windows.
Thanks in advance,
Click to expand...
Click to collapse
Hey any chance you could point me to the windows programs used to resign apk files, and do you know of any good walk throughs for resigning.
Thanks
pep1t0 said:
Worked perfectly with a zip file... heres the output =)
Click to expand...
Click to collapse
Now when you've learned how, could you make a "How to" for others?
the java testsign tool should work with windows, i think all you have to do is install the java sdk... the text line should be the same java -classpath testsign.jar testsign nameofthefile.apk/nameofthefile.zip
The zip files are... just zip files, can be made with 7zip (in windows) after you make the .zip if you want to make it an apk all you have to do is change the extension... maybe this works in cmd "copy zipedfile.zip newapkfile.apk"... if not... put it in the sdcard and do it via adb shell...
"adb shell /sdcard/nameofthezipfile.zip /sdcard/nameofthenewapk.apk"
I don't really have much time to make a tutorial and try things right now... i will try next week, in the meantime try these things... good luck...

How to modify compiled AndroidManifest.xml to downgrade it from 2.1 to 2.0?

Attached is the HTC_IME from the HTC Android 2.1 rom. I have extracted the AndroidManifest.xml and I want to tweak it so that it thinks it is revision level 5 (Android 2.0) instead of 6 (2.1). This will allow us to attempt to install it on our Droids! Right now it wont let you cause of the version difference.
So I have the manifest extracted but since it's in some binary format I cannot spot the area to change the 6 to a 5!
Does anyone have any experience with this that can lend a hand?
I've opened up this xml file with a hex editor and I can see this, but no number to change:
Code:
.v.e.r.s.i.o.n.N.a.m.e.....v.e.r.s.i.o.n.C.o.d.e.....m.i.n.S.d.k.V.e.r.s.i.o.n.....t.a.r.g.e.t.S.d.k.V.e.r.s.i.o.n.....n.a.m.e.....l.a.b.e.l.
Ok so I have found the spot by trial and error and changed the 6 to a 5. Now it throws a digest error. Any easy
Code:
12-01 17:41:24.357: WARN/PackageParser(1015): java.lang.SecurityException: META-INF/MANIFEST.MF has invalid digest for AndroidManifest.xml in /data/app/vmdl69536.tmp
I guess thats cause I didnt change the SHA1-Digest. Is this even possible to calculate a new one?
Code:
Name: AndroidManifest.xml
SHA1-Digest: fEnI7fRlROXrwteoq4qvTr9c4zs=
Ok, so you going to release one that will work on 2.0 or 2.0.1 firmwares that doesn't do the htc check?
Hi pcm2a,
Seems you need to re-sign the full apk.
Clean the Manifest file from all the SHA1-DIGEST lines and signa again the apk file.
There is also the SignApk tool as well.
pcm2a said:
Ok so I have found the spot by trial and error and changed the 6 to a 5. Now it throws a digest error. Any easy
Code:
12-01 17:41:24.357: WARN/PackageParser(1015): java.lang.SecurityException: META-INF/MANIFEST.MF has invalid digest for AndroidManifest.xml in /data/app/vmdl69536.tmp
I guess thats cause I didnt change the SHA1-Digest. Is this even possible to calculate a new one?
Code:
Name: AndroidManifest.xml
SHA1-Digest: fEnI7fRlROXrwteoq4qvTr9c4zs=
Click to expand...
Click to collapse
Can you tell me where you found the versionCode? I'm trying to do something similar myself.

Xml read error

Well, not Sure if the past should be here, I think so.
*I was tinkering with a rom (Ledro id for desire), and wanted to take a look at the xml, in such framework-res.apk, but that open from the pc, I get: hexadecimal value 0x03 is an invalid character (with xml notepad). I still open it but it is unintelligible.
What are apk's trying to open with java (do not know if I have what it takes to open them) and that makes me: failed to load main-class manifest attribute ....
I just want to tweak a little, have if I learn slowly.
Sorry for my english I am from spain
Sent from my HTC Desire using XDA App
XML files in apks are compiled to binary form, so you can't open them directly. You have to use some decoding tool: apktool (in my signature), Apk Manager (a wrapper around apktool) or AXMLPrinter2 (older and less powerful tool: can't rebuild XML and only partial info is decoded).
And no, you can't run apk files using Java on your PC.
Brut.all said:
XML files in apks are compiled to binary form, so you can't open them directly. You have to use some decoding tool: apktool (in my signature), Apk Manager (a wrapper around apktool) or AXMLPrinter2 (older and less powerful tool: can't rebuild XML and only partial info is decoded).
And no, you can't run apk files using Java on your PC.
Click to expand...
Click to collapse
Thanks, I will try
Edit: lol I dont know how I can install apktol in Windows...
I unpack the files into c:/ and now?
dany_danay said:
Thanks, I will try
Edit: lol I dont know how I can install apktol in Windows...
I unpack the files into c:/ and now?
Click to expand...
Click to collapse
So How can do this?
dany_danay said:
I unpack the files into c:/ and now?
Click to expand...
Click to collapse
You don't read carefully:
http://code.google.com/p/android-apktool/
Unpack both to your Windows directory
Click to expand...
Click to collapse

Deodex Q

Move to Q+A Please
Having a tough time with deodexing Mms.apk from the new Rodgers build.
I simply wanted to figure out how to deodex a file so I can use it in Pinnacle(learning), I downloaded baksmali and loaded it up pointed to the framework directories and tried to deodexing and that didn't work.
So I copied the all the /app and /framework folders from the mounted image to a local project folder /home/dan/project tried it that way too and this is now the error I get:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: ./services.odex: file too short
at org.jf.dexlib.Util.ExceptionWithContext.withContext(ExceptionWithContext.java:54)
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:220)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:145)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPathFromOdex(ClassPath.java:110)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:104)
at org.jf.baksmali.main.main(main.java:282)
Caused by: java.lang.RuntimeException: ./services.odex: file too short
at org.jf.dexlib.Util.FileUtils.readFile(FileUtils.java:103)
at org.jf.dexlib.DexFile.<init>(DexFile.java:293)
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:216)
... 4 more
Error while reading boot class path entry "services.odex".
Click to expand...
Click to collapse
Anyone have any ideas?
Running RHEL 6.1 x64

Need a little help deodexing HC...

I'm trying to deodex the stock HC rom and I've run into a few issues. First, I know that there are deodex'ed HC roms out there, but I'm doing this for my own edumacation. I've deodex'ed a donut and gingerbread rom and they work just fine, but honeycomb is giving me issues.
I'm using roach's patched baksmali jar that he fixed for HC. I'm using the 8.6.5.13 as a starting point. Here's my process in a nutshell:
I use baksmali without -x on all odex files (and jar/apk files without an odex file). This gives me all class paths. I wrote a script that puts them all into neat and tidy folders.
Then I baksmali the odex/jar files from framework using the BOOTCLASSPATH from my transformer.
Next, I baksmali the apk files using the BOOTCLASSPATH, plus whatever other jar it looks like it needs. This is the step that is giving me issues.
Most of the apps decompile/compile just fine, but a handful of them are referencing classes and superclasses that don't show up anywhere.
Is there something that I am missing? Is there something wrong with with my process? I did the exact same thing with a donut rom on my g1 and a gingerbread rom on my g2, and everything is working swell with those roms. Just for giggles, I added all the jars to the boot class path and I still got the same errors. Is this a case of a class that isn't used?
Here's a taste of my half-baked rom... the excerpt from the log file shows the apk and the bootclass path that I used.
Code:
AWS.apk -c core.jar:apache-xml.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Ljavax/servlet/http/HttpServlet;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:784)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:668)
at org.jf.dexlib.Code.Analysis.ClassPath.loadClassDef(ClassPath.java:280)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:163)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:111)
at org.jf.baksmali.main.main(main.java:282)
Error while loading class Lcom/ecareme/http/RedirectServlet; from file /android/hc_work/deodex_hc/system/app/AWS.odex
Error while loading ClassPath class Lcom/ecareme/http/RedirectServlet;
Dictionary.apk -c core.jar:apache-xml.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Ljava/awt/event/WindowAdapter;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:784)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:668)
at org.jf.dexlib.Code.Analysis.ClassPath.loadClassDef(ClassPath.java:280)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:163)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:111)
at org.jf.baksmali.main.main(main.java:282)
Error while loading class Lorg/htmlparser/beans/BeanyBaby$1; from file /android/hc_work/deodex_hc/system/app/Dictionary.odex
Error while loading ClassPath class Lorg/htmlparser/beans/BeanyBaby$1;
NVIDIATegraZone.apk -c core.jar:apache-xml.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar
Error while disassembling method Lcom/github/droidfu/http/BetterHttpRequest$2;->retryRequest(Ljava/io/IOException;ILorg/apache/http/protocol/HttpContext;)Z. Continuing.
org.jf.dexlib.Code.Analysis.ValidationException: class Loauth/signpost/OAuthConsumer; cannot be resolved.
at org.jf.dexlib.Code.Analysis.ClassPath$UnresolvedClassDef.unresolvedValidationException(ClassPath.java:535)
at org.jf.dexlib.Code.Analysis.ClassPath$UnresolvedClassDef.getClassDepth(ClassPath.java:543)
at org.jf.dexlib.Code.Analysis.ClassPath.getCommonSuperclass(ClassPath.java:383)
at org.jf.dexlib.Code.Analysis.RegisterType.merge(RegisterType.java:275)
at org.jf.dexlib.Code.Analysis.AnalyzedInstruction.mergeRegister(AnalyzedInstruction.java:185)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.propagateRegisterToSuccessors(MethodAnalyzer.java:444)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.setPostRegisterTypeAndPropagateChanges(MethodAnalyzer.java:409)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.setDestinationRegisterTypeAndPropagateChanges(MethodAnalyzer.java:396)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeIgetWideObject(MethodAnalyzer.java:2605)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeInstruction(MethodAnalyzer.java:777)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyze(MethodAnalyzer.java:208)
at org.jf.baksmali.Adaptors.MethodDefinition.addAnalyzedInstructionMethodItems(MethodDefinition.java:370)
at org.jf.baksmali.Adaptors.MethodDefinition.getMethodItems(MethodDefinition.java:292)
at org.jf.baksmali.Adaptors.MethodDefinition.writeTo(MethodDefinition.java:132)
at org.jf.baksmali.Adaptors.ClassDefinition.writeMethods(ClassDefinition.java:323)
at org.jf.baksmali.Adaptors.ClassDefinition.writeVirtualMethods(ClassDefinition.java:308)
at org.jf.baksmali.Adaptors.ClassDefinition.writeTo(ClassDefinition.java:137)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:201)
at org.jf.baksmali.main.main(main.java:282)
opcode: iget-object
CodeAddress: 96
Method: Lcom/github/droidfu/http/BetterHttpRequest$2;->retryRequest(Ljava/io/IOException;ILorg/apache/http/protocol/HttpContext;)Z
OK, I tried it with the -I option for the offending apks and I didn't have any errors after that. Smali was fine with ignoring the missing classes. The rom seems to be OK. I don't get any force closes, but I didn't test out everything too thoroughly, especially the bloatware. Make me wonder why I bother deodexing it in the first place?
I would still like to know how these missing classes get there in the first place?

Categories

Resources