6
  1. Put in the .apk file which you want to decode
  2. Download the latest version of apktool AND apktool install window (both can be downloaded from the same link) and place them in the same folder
  3. Now run a command like apktool if framework-res.apk and next apktool d myApp.apk (where myApp.apk denotes the filename that you want to decode)

Can I perform the above steps of apktool in an android project? Let me know if anyone can help me. I want to make an application similar to apkEditor.

  • 1
    Maybe you should make your question / requirements be much more clear so that it will be easier to offer help. – shizhen Nov 27 '18 at 07:48

1 Answers1

1

The answer is yes, you can perform the steps you mentioned.

I'm not going to write the application for you but here are some guidelines. First, apktool is written in Java so you can download the latest release packaged from here. Make sure you read the license first. Then import it into you Android studio project. There is a specific class that is called Main with a main method that is responsible for the CLI. For example:

import brut.apktool.Main;
try {
    Main.main(new String[]{"if", "/sdcard/...your_path.../framework-res.apk"});
    Main.main(new String[]{"d", "myApp.apk"});
} catch (IOException | InterruptedException | BrutException e) {
    e.printStackTrace();
}

PS: In case I misunderstood your question. If you want every time the program runs to download the newest version of apktool jar from Github you can use JarURLConnection to fetch the remote jar file and reflection to invoke the Main.main() with your parameterers. A comprehensive example of which can be found here.

tur1ng
  • 1,082
  • 1
  • 10
  • 24
  • if I want to build that file again, then? – Akash Mishra Nov 29 '18 at 07:09
  • If I understand your question, after decompilation you ll have the source code, not an Android Studio project. You can try importing it into Android Studio via "Import from existing sources" but probably errors will still exist. – tur1ng Nov 29 '18 at 08:19
  • not that, I am asking to build that source again in a apk. When I decompiled the source by using the code provided by you, I want to build that source again in a apk from that app. – Akash Mishra Nov 29 '18 at 10:01
  • Is it possible to use ApkTool library on Android to just parse the APKs instead of creating new files ? Given an InputStream of an APK, to parse it and get information about it? – android developer May 01 '20 at 07:15