1

I have an apk file. I converted it to jar file using dex2jar tool in order to obtain a jar file. I opened the jar file with java decompiler. In the code (mainactivity.java) there is a piece of code like

ContentValues localContentValues = new ContentValues();
localContentValues.put("title", "testtesttest");
localContentValues.put("url", getApplicationContext().getString(2131034115));
localContentValues.put("bookmark", Integer.valueOf(1));
getContentResolver().insert(Browser.BOOKMARKS_URI, localContentValues);

what does this mean actually and how i obtain the actual value of getApplicationContext().getString(2131034115) with java decompiler. There is no resource file such as .xml after decompilation. R.java contains an information like

public static final class string
  {
    public static final int action_settings = 2131034114;
    public static final int app_name = 2131034112;
    public static final int baseurl = 2131034115;
    public static final int hello_world = 2131034113;
  }

what is the actual string value of baseurl?

2 Answers2

4

After decompiling using APKTOOL

Go to the output folder where decompiled files are generated,

Inside that folder, Open ./res/values/public.xml file. Inside the file, you will get all the resources hex code along with their ids in string format.

Thanks.

Nadir Laskar
  • 4,012
  • 2
  • 16
  • 33
  • Welcome to Stackoveflow. Would you mind extending your answer bit more for fellow programmers to understand how it helps to solve the problem. – Nagama Inamdar Oct 26 '15 at 13:14
1

There are two paths you might take here depending on what you want to accomplish:

The one you have already taken i.e. decompile the Dalvik bytecode (dex) into readable Java source. The next step is to use jd-gui. The resulting source is useful to read and understand the functionality of an app, but will likely not produce 100% usable code. In other words, you can read the source, but you can't really modify and repackage it. Note that if the source has been obfuscated with proguard, the resulting source code will be substantially more difficult to untangle.

The other major alternative is to disassemble the bytecode to smali, an assembly language designed for precisely this purpose. I've found that the easiest way to do this is with apktool. Once you've got apktool installed, you can just point it at an apk file, and you'll get back a smali file for each class contained in the application. You can read and modify the smali or even replace classes entirely by generating smali from new Java source (to do this, you could compile your .java source to .class files with javac, then convert your .class files to .dex files with Android's dx compiler, and then use baksmali (smali disassembler) to convert the .dex to .smali files, as described in this question. There might be a shortcut here). Once you're done, you can easily package the apk back up with apktool again. Note that apktool does not sign the resulting apk, so you'll need to take care of that just like any other Android application.

In short, your choices are pretty much either to decompile into Java, which is more readable but likely irreversible, or to disassemble to smali, which is harder to read but much more flexible to make changes and repackage a modified app. Which approach you choose would depend on what you're looking to achieve.

Community
  • 1
  • 1
Tushar Nallan
  • 784
  • 6
  • 16
  • 1
    In fact, I do not want to use the code or debug it.. I just want to obtain a readable code and i achieved that. With this readable code, I want to obtain a link which is the result of arrayOfString[0] = (getApplicationContext().getString(2131034115) + str5 + str6 + (String)localObject2 + str7); this line. I have each string variable but not getApplicationContext().getString(2131034115). I think i need to Access this resource 2131034115, probably a static string is assigned to it. But i couldn't Access it. – Tolgahan TÜRKER Nov 21 '14 at 14:29
  • @TolgahanTÜRKER Did you ever find out? I have the same issue. – Sam Apr 19 '18 at 00:29