How to recover Gradle files from APK file? - java

I've succeeded in recovering the Java files and XML files from an APK file using this tutorial but I cannot find the Gradle scripts( build.gradle, settings gradle, local.properties, etc.)
I've created a new project and I had imported the Java and XML files but the project doesn't work, I guess because of the Gradle.
Does anyone know how to do this?

The gradle file is not compiled into the APK, it is only for the actual android studio project for fetching dependencies and app configuration. There is no way to get a gradle file from an APK

Try creating your own folders in the studio and try copying the code into the studio....that should work...and about gradle files? android studio will build it with gradle...as much as i know studio uses gradle build system to build app

you can’t . when you compile apk it will merge all the file into single file . An APK file contains all of that program's code (such as .dex files), resources, assets, certificates, and manifest file.
So When You decompile it . you can not file gradle file .

From what I've read in terms of Apktool vs JADX: Pros and Cons, JADX apparently decompiles APK files to Java Code and also has the option to allow you to save said Decompiled APK as a Gradle project, it has CLI version as well as a GUI version.
however I noticed that one of the Cons of JADX comes from when the APK that JADX is being used on, contains some non-ASCII characters, causing the Decompiling process to fail.
Maybe this could work for you, not sure if it will give you exactly what you want in terms of original Gradle files but it might be a step in the right direction.
You can find more information about JADX, from the creators Jadx GitHub repository, Note that it doesn't work on every APK you use it on.
Hope this helps.

Related

How to run .jar in Android and see the results in Android

How can I Run a .jar file in Java so that I can see the results? I this I will need to use Android Studio but I have no idea on how to do it. Please help.
To use class and method in .jar library file in android you have to use it as a module.To do this follow below steps
copy .jar file
navigate to android studio "project" folder
paste copied .jar to libs folder
right click on pasted file and click add as library
Android uses ART not JRE. So it can't run .jar files.
It is possible to run jar files in Android. But the problem is, it's possible using command execution and Root is needed to do that. A perfect example is this Apktool (Android) with Source Code

How to install jinput in eclipse?

The last days I searched how to use Controllers like DS4 in java and it got me to jinput. After downloading the zip file. I added the two JARs to the project and tryed to run a test code, that I found in an installtion guide.
The problem is that it says
no jinput-dx8_64 in java.library.path".
I know there is another Thread for this problem, but I didn't understand it, maybe because of my bad English, maybe because of my knowledge. I tried to fix it by adding the directory of the files to the jre native library in eclipse, but it keeps saying the same errors.
This is only one of the many possible way of including external library
Frist you have to download the library jar
Download from maven
Then you download the natives library for the desired os
Download from maven
Finally you link both the library (jar) and the natives (dll for windows) in the project

Using ndk project/library with drivers

I have this demo project: http://www73.zippyshare.com/v/74674979/file.html which I got for using http://www.aclas.tw/Products/AO1X/ .
My problem for using this is in the documentation. Which does not exist.
I understand how the Java part of the code works but I don't know how to implement this in my project.
I downloaded and installed ndk hoping I would be able to run the project but it crashed at the most important part:
System.loadLibrary("AclasArmPos");
I don't know what to do and there is no description on how to use it. Except the code itself which I cannot run.
Place the .so files under jni/libs. If you have .so files for multiple architectures, create folders like x86, armv7a within the jni folder and place the .so files in the corresponding folder. If you are using Android studio, the steps to follow are slightly different. Can you provide more details?

Can't open a .jar file on my mac

I'm trying to download jsoup on my mac (Mountain Lion). I've downloaded the jsoup.jar file and installed the last java 7 from the site. But here is the problem, when I double click the .jar file it tells to me:
The Java JAR file “jsoup-1.7.2.jar” could not be launched. Check the
console.
I can't find even the console! Someone can help me? I read a lot of answers about this topic, but they all talk about Java 6 and it has different settings that can't find.
EDIT
i also tried from the terminal with this command:
java -jar /Users/Ben/Downloads/jsoup-1.7.2.jar
but it tells me:
Failed to load Main-Class manifest attribute from
/Users/Ben/Downloads/jsoup-1.7.2.jar
The JSoup JAR is not executable, so you are not going to be able to 'run' it in any of the ways you described. You are supposed to include it in your project classpath and use classes from it to do your parsing (after importing them of course).
You might want to refer to the JSoup Guide for examples on using the library.
I guess you are trying to run the jsoup library as a standalone application assuming it to be an executable jar. All indicates that the jar file you are using is NOT an executable jar hence it wont work.
jsoup.jar is supposed to be used as a java library and you will need to write java code to be able to use the HTML parsing capabilities.
If you are using an IDE like IntelliJ, you can open the module settings for a particular project and select Libraries. There'll be an option to add a particular external library from the Maven repository after which you can download the JAR and include it in your project's dependencies.

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

Categories

Resources