Hi I am new to Android and I have an apk file from which I extracted the source code.
My problem is that now I need to open all the java and xml files in eclipse as a new Android project for editing.
Right now I am only able to view the java class but not able to run it i.e; I cannot put it in a project I have created. When I try to read the xml files it shows some garbage values.
Thank you for your help in advance.
An .apk files is package that contains the compiled code, not source code. No java files live in there, just the android .class equivalent -- the classes.dex file. There is no way to get the original source (.java files) from the .apk.
Kindly refer this blog post, GT's Blog also this StackOverflow Question decompiling DEX into Java sourcecode
You can try to decompile some of the .class files but I never tried to do it for the XML files. I found a discussion in XDA Developers Blog which may help you. How to decompile/recompile binary XML from .apk file?
Related
I was trying to create a .jar from a .java file for a school project but now I can't read my .java file. The code I had written was overwritten somehow and I need to know how to (if possible) revert my .jar file back to the code I had written. Thanks in advance because this is a time sensitive matter.
You could try "decompiling" your JAR file using any JAR decompiler, such as http://www.javadecompilers.com/.
You won't get exactly the source code you originally wrote, but the decompiler will do it's best to map the .class files embedded in the JAR back to Java source code.
If you are using Eclipse you can right click on your project and check in history for getting old code
I have de-compiled an apk file using apk-tool (command: "apktool d file.apk") and changed some xml parts.
Also I have the jar file using dex2jar. I opened jar with java de-compiler and selected "save all sources". Then I unzipped it and changed some parts of the code (modified it).
Now how should I regenerate the new apk file?? I tried copying java sources into the folder from apk-tool and the recompiled them together but it didn't work. What should I do??
You are trying to mix technologies that aren't possible to mix. Apktool during rebuild requires files to be either in the pre-assembled dex format or various disassembled .smali files.
Apktool doesn't have any support to build from java sources. Not to mention, it wouldn't work as Apktool can't rewrite resource IDs which would happen with java sources. You can read the technical explanation here.
You need to build your java sources, then use baksmali to obtain the .smali equivalence and use those in apktool.
Well, I had just finished coding a java project and went into testing it using eclipse. It was exporting fine and I went ahead and created a new file in src named "config.yml" and it all of a sudden removed all the .java files in my project!
Fortunately, I still have the .jar which contains all the .class files, but I seem to be unable to edit the code (i'm guessing this is to do with it being a .class instead of .java) so, is there any way I can transfer these .classes back to .java ?
btw, if you're recommending any software please note that i'm on a macbook so i'll be limited to what i can use..
Try this (JD-GUI). Have a Mac version and it's nice.
It will show to you the code from the class file.
Okay, so my programming teacher sent me an app that I should look at and modify. I downloaded the APK file, and turned it into a source code following these instructions: how to extract code of apk file.
I have the java (src) files, the resources files, and the XML files. I have the Manifest file too.
I imported them successfully on eclipse, but now it has like 2000 errors.
I really don't know what to do. The apk works fine on my phone.
Why is it doing this?
If anyone needs the apk, I'll upload it.
If someone can be so generous to convert it into a working eclipse workspace for me, I'll be more than grateful.
You can never get the exact source code from the .apk file. The .apk file is generated from the compiled classes which doesnt have all information like actual variable names, actual method names. so you cannot retrieve back 100% original source code.
Basically everything will be obfuscated. so when obfuscated, multiple classes may have same name.
eg: two classes may have name 'a'. Hence the Errors in Eclipse.
As far I know re-compiling apk file will not give you exact results except the images and xml resources. Some free tools available that cannot provide 100% accurate code. here's a tutorial you can check How To Retrieve The Source Code From A Compiled Android .Apk
i wanna use weka source code (not jar file!)and i download weka-src.jar from this address
http://www.java2s.com/Code/Jar/w/Downloadwekadev379sourcesjar.htm
and i wanna have weka project in netbeanes in windows .i do step by step this site instruction
http://weka.wikispaces.com/Netbeans+6.0+%28weka-src.jar%29
when i extract jar file into src directory in my project,it give me a lot of error
such as:
package java_cup.runtime does not exist
and a lot of other error.
anyone can tell me how can i do that without any error ?? i am working on this problem for a week and i'm so tired.
please help me if you can.
you have to download java-cup.jar file And add this jar to your classpath
if you didn't find java-cup.jar then you can download jflex.jar jflex also contain java-cup classes so you can download jflex.jar from link below
click on this link