how to open an .apk file - java

hi i am a new developer, i created an app of my own. I created the .apk file and get it signed and aligned it. When i was running it on my device i thought of doing some changes in it, but i missed the original source code. Can i get back my source code using the aligned.apk file... I am using eclipse

The apk is just a zip file so you can unzip it. Your code will be in a classes.dex file in the dalvik format. There are some tools you can use to convert it back from dex2jar, and then decompile the class files using jad but your source code will most likely be imcomplete.

Related

Duplicate a javaws application to edit

I use an javaws app that comes with a jnlp file. I want to launch it locally and be able to modify the source code on my computer to fit my exact needs. I use Eclipse as IDE.
I've opened the jnlp file and downloaded all the jar files, then I have used JD-GUI and CFR to decompile the app.
In Eclipse, I've imported all the different ressources jar and put the app decompiled source code within the src folder. I've tried to correct every mistake done by both softwares but the app still crashes due to their mistakes.
Note, if i just import the app as a jar file, it works as expected but i can't edit the files, indeed it's a class file.

how to decompile a .apk without errors?

I tried the apktool, and even the online version, http://www.decompileandroid.com/
But still can't get something that works in eclipse.
I want to decompile an app called bucket drops, which was made as part of an android course. I want to look at the source code and tweak it.
When I tried decompiling the .apk file it lacked the .classpath and .project files, so I made a new project in eclipse and copied the source code into it, but for some reason eclipse shows that the app is buggy!
What do I do?
How-To: Decompile/Recompile apk's with ApkTool
Requirements:
ApkTool
Java JDK/JRE 32 bit
Basic Cmd/terminal knowledge
Download ApkTool here
ApkTool.zip
first you need to extract that zip folder to anywhere you choose, preferably on root of c/drive ie: C:/android/apktool extracting the files to 'apktool' folder
Now place the STOCK framework-res.apk & whatever other apk's you would like to modify into the 'apktool' folder
Getting to CMD directory
Open up a Cmd Prompt (terminal) and get to the 'apktool' directory ie:
Your cmd will probly look like this..
C:\users\yourname>
so type in
cd.. (yes include the '..' and press enter after you type each command)
this will get you to back directory so now you will see
C:\users>
so type again
cd..
you should now see this:
C:>
now type in:
cd 'apktoo'l/'directory'
for me it looks like:
cd android/apktool
now you should see:
C:/android/apktool>
and you are in the apktool directory :D
Click to expand...
Installing Framework
Now that you are in directory we need to install the device's framework to your system for it to compile correctly so type this:
apktool if framework-res.apk
this will install the devices framework to your system (need to do this)
Decompiling
now to decompile the apk you want to edit.. type this:
apktool d framework-res.apk framework1
or
apktool d music.apk music
music.apk is the apk your decompiling
music is the folder you're creating for the decompiled apk
now make your edits :D DO NOT Change/Edit ANY PNG's
Recompiling/Finished Product
now to recompile your new apk type this:
apktool b music music-new.apk
or
apktool b framework1 framework-res-new.apk
framework1 is the folder with your edited files
framework-res-new.apk is your new apk file :D
Now we are NOT done... we cannot use the new apk's... we have to take what we did and add it back to the original apk file to keep proper signature :D
use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "-new" apk and copy them into Original apk
now the apk is ready to flash with your new changes :D :D
Hope this helped some of you new themers out there!!!
Source: AndroidForums
One of my colleague has written a ruby Gem to address this problem, It can decompile an Apk and open it's code in a friendly GUI.
apkToJava is the gem name. you should try it once.
It's an easy to use tool which just take two to three commands to get an Apk decompiled.
gem install apkToJava
apkToJava setup
apkToJava /path/to/apk/file.apk
As of now its support only two operating systems Mac OS and Linux.

How to edit .jar file in Android Studio

How can I edit code in a .class file in a .jar file using Android Studio? I have already tried to edit it of course. The class I am trying to edit is a read only for some reason.
Jar files are compressed archives (zipped files) of .class files( and few other resources). .class files are compiled .java files. You can not edit a compiled file in normal situation unless you decompile to get source code, edit the code and recompile again.
Decompiling is a tedious process, thus getting a source code is the best option here.
Note: You can rename the .jar file to a .zip file and can open it using any compression tool such as winrar or winzip to see the content.

Decompile an APK, modify it and then recompile it

I need to modify an existing APK, modify the sources and then recompile it.
I can decompile it using dex2jar or apktool, it's working great
From the jar file I can obtain the java sources (using jd-gui)
Then I can modify the java files
But now I would like to know how to recompile the java files and put them back into a jar file! (the jar part should be easy, the main problem seems to be how to recompile the java files for android)
I know that an other solution is to use apktool and then modify the smali files, but it seems to be really complicated when we want to add a lot of code!
My application is a basic a HelloWorld whitout obfuscation.
Thanks to Chris Jester-Young I managed to make it work!
I think the way I managed to do it will work only on really simple projects:
With Dex2jar I obtained the Jar.
With jd-gui I convert my Jar back to Java files.
With apktool i got the android manifest and the resources files.
In Eclipse I create a new project with the same settings as the old one (checking all the information in the manifest file)
When the project is created I'm replacing all the resources and the manifest with the ones I obtained with apktool
I paste the java files I extracted from the Jar in the src folder (respecting the packages)
I modify those files with what I need
Everything is compiling!
/!\ be sure you removed the old apk from the device an error will be thrown stating that the apk signature is not the same as the old one!
I know this question is answered still, I would like to pass an information how to get source code from apk with out dexjar.
There is an online decompiler for android apks
Upload apk from local machine
Wait some moments
Download source code in zip format
I don't know how reliable is this.
#darkheir Answer is the manual way to do decompile apk. It helps us to understand different phases in Apk creation.
Once you have source code , follow the step mentioned in the accepted answer
Report so many ads on this links
Another online Apk De-compiler #Andrew Rukin : http://www.javadecompilers.com/apk
Still worth. Hats Off to creators.
The answers are already kind of outdated or not complete. This maybe works for non-protected apks (no Proguard), but nowadays nobody deploys an unprotected apk. The way I was able to modify a (my) well-protected apk (Proguard, security check which checks for "hacking tools", security check, which checks if the app is repackaged with debug mode,...) is via apktool as already mentioned by other ones here. But nobody explained, that you have to sign the app again.
apktool d app.apk
//generates a folder with smali bytecode files.
//Do something with it.
apktool b [folder name] -o modified.apk
//generates the modified apk.
//and then
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore modified.apk androiddebugkey
//signs the app the the debug key (the password is android)
//this apk can be installed on a device.
In my test, the original release apk had no logging. After I decompiled with apktool I exchanged a full byte code file without logging by a full byte code file with logging, re-compiled and signed it and I was able to install it on my device.
Afterwards I was able to see the logs in Android Studio as I connected the app to it.
In my opinion, decompiling with dex2jar and JD-GUI is only helpful to get a better understanding what the classes are doing, just for reading purposes. But since everything is proguarded, I'm not sure that you can ever re-compile this half-baked Java code to a working apk. If so, please let me know. I think, the only way is to manipulate the byte code itself as mentioned in this example.
First download the dex2jar tool from Following link
http://code.google.com/p/dex2jar/downloads/list
Extract the file it create dex2jar folder
Now you pick your apk file and change its extension .apk to .zip after changing extension it seems to be zip file then extract this zip file you found classes.dex file
Now pick classes.dex file and put it into dex2jar folder
Now open cmd window and type the path of dex2jar folder
Now type the command dex2jar.bat classes.dex and press Enter
Now Open the dex2jar folder you found classes_dex2jar.jar file
Next you download the java decompiler tool from the following link
http://java.decompiler.free.fr/?q=jdgui
Last Step Open the file classes_dex2jar.jar in java decompiler tool now you can see apk code
I know this question has been answered and I am not trying to give better answer here. I'll just share my experience in this topic.
Once I lost my code and I had the apk file only. I decompiled it using the tool below and it made my day.
These tools MUST be used in such situation, otherwise, it is unethical and even sometimes it is illegal, (stealing somebody else's effort). So please use it wisely.
Those are my favorite tools for doing that:
javadecompilers.com
and to get the apk from google play you can google it or check out those sites:
apk-dl.com
apkpure.com
On the date of posting this answer I tested all the links and it worked perfect for me.
NOTE: Apk Decompiling is not effective in case of proguarded code. Because Proguard shrink and obfuscates the code and rename classes to nonsense names which make it fairly hard to understand the code.
Bonus:
Basic tutorial of Using Proguard:
dex2jar with jd-gui will give all the java source files but they are not exactly the same. They are almost equivalent .class files (not 100%).
So if you want to change the code for an apk file:
decompile using apktool
apktool will generate smali(Assembly version of dex) file for every java file with same name.
smali is human understandable, make changes in the relevant file,
recompile using same apktool(apktool b Nw.apk <Folder Containing Modified Files>)
I know this question is answered still and I am not trying to be smart here. I'll just want to share another method on this topic.
Download applications with apk grail
APK Grail providing the free zip file of the application.
This is a way:
Using apktool to decode:
$ apktool d -f {apkfile} -o {output folder}
Next, using JADX (at github.com/skylot/jadx)
$ jadx -d {output folder} {apkfile}
2 tools extract and decompiler to same output folder.
Easy way: Using Online APK Decompiler
https://apk.tools/tools/apk-decompiler/ (recommended)
http://www.javadecompilers.com/apk
https://www.apkdecompilers.com

how to Open source code from android apk created through adobe Air( coded in flash)?

I am trying to generate the source code from apk (which is created by adobe air, which is actually coded in flash)but It generates with no java classes and no images in res folder. The app actually a game app which has a 50 images in it. Can any body suggest me that, how to get the converted flash code into java files and the resource through the apk. I would be obliged if any suggests. Thanks in advance.
umm... you need to disassemble the APK. Did you check inside for .dex or .class files?
If yes, you might be able to use something like DJ Java Decompiler on those .class files. But android uses .DEX files instead of .class and .APK instead of .JARs.

Categories

Resources