Android Apk to Pure Java files - android

I have developed an Android app in Android studio and have uploaded its apk in Google Play Store as well. But I had lost all the files(java+xml) of the app.
Now I only have the apk from play store and also the apk before uploading to Google Play Store (apk before performing encryption).
Now I want to get all the java files and xmls of the app for updating the app. I have tried all the steps mentioned by previous StackOverflow questions but I was not able to get the Java files properly. I was able to get the xmls properly. Java files I got was somewhat not understandable format (partially compiled/transformed)
So my question here is can I get all java files as normal java files without any compilation/transformation?
Please help guys. Thanks a ton in advance

Nope, you can't. Unless going through reverse engineering process, something like dex2jar...

The first step is to extract your APK archive and copy the file named classes.dex to some other directory. Next you need to convert your dex file into jar format.
For that you can use this library. Bear in mind that you have to build it first using gradle.
The final step is to decompile your java class files into proper java files. Use this tool.
Voila, you have your source code. That is if you haven't used Proguard to obfuscate your code.

Related

How to extract source code from installed app?

I was developing an Android app for more than a month, but my computer crashed and I lost all the code from it. I have a compiled app installed on a test phone and tablet. Is there any way to extract source code from it?
I followed some guide for game modders (they are probably doing something similar), and I have extracted .apk with an app called Total Commander. Now the guide states that I should extract it with the apktool. But all files are still in binary (when I opened them I got random chars). Now, is there any tool (for Linux) that can decompile .apk back to source code, or maybe some feature of apktool I miss?
Note: I also tried this answer from 10 but also without success.
EDIT: javadecompileonline also did not decompile binaries correctly,
so this should be .json file:
<m*/��%kي%jTƴ���69/�t��
č �Cx���Q�đš?������i�
ć���/��i�JRᙱg�.�s
First you go to Android studio's welcome page there is a option to extract source code from APKs.
Another way is to install this apk extractor application from play store then you can extract source code from APKs Link : https://play.google.com/store/apps/details?id=com.ext.ui

Can I convert Apk file back to android studio project?

I made my android project and run the app on my phone. I got the apk file and also app but accidentally deleted app. Can anyone Help me out please.
If your apk not obfuscated by proguard or other third party also not build by signed. Probably you can use an software like Dex2Jar. But i am not really sure about this, you can try it. There are tutorial here
Reverse engineering your app is theoretically possible but hard.
1) Use the Apktool which would help generate a little code and the resource files.
2) Use the jadx tool which helps to produce Java source code from Android Dex and Apk files.
Next is to open a new Android Studio project, copy the manifest file generated by the Apktool into the manifest of the new project, Copy the resource files generated by Apktool to the res section of your new project, Copy the java files generated by jadx and place them in the src folder of your new project.
Try to build the app but you'll definitely run into several errors. Try following the messages to fix them.
Reverse engineering your app is very tedious and you still might not be able to build the app.
Goodluck :)
Added 24th November 2019
Just found this awesome article on how to go about Reverse Engineering an Apk.

App Recovery - Decompiling Android Project Classes From APK

I am currently working on an android app but my hard drive unfortunately crashed and I lost all the data on it... I am trying to recover my source code from the debug APK I had installed on my phone (using dex2jar and jd-gui) however, it seems like the classes are not present in the classes.dex and classes2.dex (both files are tiny and do not contain any of the classes in my code, see photo).
I used apk extractor to get the apk from my installed app and I cant seem to get anything close to my original classes... I am wondering if I am doing something wrong to get the APK from the installed app; any help would be greatly appreciated.
Thanks.
For de-compiling your APK to Java classes you can go to this site -
http://www.javadecompilers.com/apk
Just upload your apk and click on decompile. It should work for you !

Encoding issue of AndroidManifest.xml file

I'm building phonegap app using phonegap-build.
I need to make some changes to the manifest of the android apk.
After i download the apk of my phonegap build, i rename it to .zip file to see the contents of the file.
When i open it, there i see the xml file there, and when i open that one, it has encoding problem.
This is what i see:
I understand it's a binary, but i need to see the content in plain english, if possible.
1) How can i encode it to see what is the content of this file properly?
2) After a change that i do on it, can i "decode" it back to binary?
So from what you wrote you wrote, you want to edit the AndroidManifest.xml from an APK file AFTER you built it, which is quite complicated. I suggest you editing the source AndroidManifest.xml and then re-building the APK. If you can't do this then please do the following.
(1) First, download and install Apktool. It is a free Android tool for decompiling and recompiling apps quickly. It provides access to .class files, resources and XML's. Here's a tutorial on how to install Apktool.
(2) Then you want to decompile your APK file (tutorial).
(3) Edit the AndroidManifest.xml file.
(4) Re-build the application (tutorial).
(5) Finally, you will have your APK file but it will be mostly useless as it is un-signed. You can't install un-signed apps as you will get an error (it may be possible to force-install it using root or adb tho) and you can't publish them. To sign it you can check out this link.
IMPORTANT INFORMATION: Your app will have to be signed with the same certificate with which it was signed the first time, otherwise it will be considered a different app. Not completely tho, you will have to un-install previous versions in order to install this one.
And yes, I know it's a very long and time-taking process but it is supposed to be, only if you have the source you should be able to edit the app.
As mentioned above, the tool you are looking for is Apktool.
You need to use --force-manifest flag when you decompile to decode AndroidmManifest.xml.

Build apk in c# application?

So im making a C# application which I want to be like a small configuration GUI where the user can input his own parameters and select some features, and according to those a xml file will be made and put in a prebuilt ready-to-build android project (in the asset folder). Now i'm struggling with the part where the C# application should compile the project and make a final apk. I tried to use ant but fail hard at understanding how to use it. Any help would be appreciated, but please be detailed im new to this kind of stuff.
This is a rather old question, but I'm going to answer it with my final solution.
I created a builder in C# by including the free apktool (and required files) in my project, which could decompile and compile an apk.
So what I did was after making my app, decompile it with apk tool, and then include the decompiled project with my c# project. The user generated a config file using the C# application, and it was deployed in the /assets/ folder of my app since my app expected it to be there.
Then I builded it again with apktool and signed using a debug keystore. (debug keystore is default if the user has no idea what that is, another keystore can be selected)
Keep in mind that, for this to work, the end user has to have java SE installed, I listed these 2 as "required" in my application (PC restart after installation recommended):
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html
Hope this helps anyone finding this, rather old, post!

Categories

Resources