2

I want to install 2 different versions of an app. I researched a little and found that I need to change APK's package name with APK Editor. I decompiled the APK with APK Editor and changed everything related to the package name. For example, the app's package name was com.oldapk.filee, which I changed to com.newapk.file. Then I compiled it again and installed the new APK file. But I was unable to launch the new APK file.

I enabled USB Debugging on my phone and started to looking crash logs. I saw that the package name was mentioned as com.oldapk.filee, and I started thinking about what could be wrong. I used ack on Linux to check which files have the com.oldapk.filee string and saw that 2 libraries (.so files) was including the old package name. I changed them in NotePad++ (Hex Editor Addon) to the new package name, but this time when the app launched, I was able to see starting screen, but it was crashing in 0.5 seconds after I launched it. I checked the crash logs again and then I saw that the package name was still old. Maybe the changes that I made didn't affect it.

How can I edit these files?

5
  • why do you want to edit a .so file for which apparently you do not have the source? this sounds like repackaging of the app
    – kampias
    Dec 1, 2022 at 19:58
  • Welcome to Android Enthusiasts! This seems to be an XY problem. Instead of trying to get your supposed solution working: Would a different approach be welcome if it lead to the wanted result? You could e.g. use an app like Shelter to have an isolated workspace (Shelter actually uses Android's Work Profiles). Or you could simply create a separate user-profile and install the second version there.
    – Izzy
    Dec 2, 2022 at 1:11
  • @kampias I already described why I have to edit .so file.
    – Erikli
    Dec 2, 2022 at 14:38
  • @Izzy yes I can but honestly I don't want to deal with user-profiles and to be honest, I don't have a storage for it. So, I need to edit .so file.
    – Erikli
    Dec 2, 2022 at 14:45
  • 1
    Just in case you might be interested, we also have a sister site specifically for Reverse Engineering.
    – Andrew T.
    Dec 3, 2022 at 3:18

1 Answer 1

1

Editing the package name of an existing app that you are not a developer can be a challenge. Also, unlike editing the Smali code, editing binary files can indeed break the app.

Here is some points that should be considered :

  • The ack commands will only list strings and the name of the package can be encoded.

  • Both APKs can use a same directory/file (e.g. in external storage), that maybe does not contains the package name, will lead to a crash due to permissions issue as the file/directory will be owned by the UUID of the com.oldapk.filee and cannot be accessed. To list the folders/files that are used by the application, these commands ADB shell commands can be used:

    • Get the user of the app com.oldapk.filee
    > ps -A | grep com.oldapk.filee
    u0_a230       10259    899 16984024 74060 0                   0 S 
    com.oldapk.filee
    
    • Get the list of files owned by the user of the app (u0_a230) on the /sdcard
    > find /sdcard/ -user u0_a230 
    
  • In the binary, changing the package name with a another one that the length is not equal to the length of com.oldapk.filee will break the library (ensure that the '\0' 0x00 is the last byte of the string).

  • Application can have an anti-tampering protection, it can be installed but crash if the app is tampered.

  • Adding the flag android:debuggable="true" to the tag <application> on the "AndroidManifest.xml" can help debugging the tampered APK.

Hope that can help and good luck.

3
  • 1
    Completely agree. Beyond ASCII, try searching UTF16-encoded equivalent, but even then, there could be some other encoding. Using a package name with the exact same length is mandatory. If you have external & internal storage, maybe installing one on internal and the other on external will limit the risk of namespace conflict, just a wild guess here…
    – NovHak
    Dec 3, 2022 at 5:31
  • I thinked about the length of the library too. I will check today, thanks anyways!
    – Erikli
    Dec 3, 2022 at 7:21
  • I tried today and nothing changed :(
    – Erikli
    Dec 3, 2022 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .