8

I planned to change the package name through smali(reverse)

when I open up apktool.yml, I saw this

forced-package-id: '127'

I have tried to change it but it crash why should i do?

Daniel Nugent
  • 42,295
  • 14
  • 109
  • 134
Simon Ang
  • 103
  • 1
  • 1
  • 5

2 Answers2

30

Assuming your goal is to rename the package name of the apk, the package names used for the classes are irrelevant. The package name of the apk is mostly unrelated to the package names of any classes in the apk. And there's no reason you need to touch the package id.

I would recommend unpacking the apk with apktool, and then edit the apktool.yml, setting renameManifestPackage to the new package name. Then when you rebuild the apk with apktool, it should use aapt's --rename-manifest-package functionality to change the package name.

After that, just resign the new apk and you should be good to go.

apktool d app.apk
// change "renameManifestPackage: null" in app/apktool.yml
// to "renameManifestPackage: my.new.package"
apktool b app -o new_app.apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/my.keystore new_app.apk mykeyname

And just to reiterate, you don't need to modify the package names of any classes.

JesusFreke
  • 19,004
  • 5
  • 62
  • 66
  • 5
    I admit that your answer might be more helpful than mine. +1. – Luca D'Amico Apr 24 '16 at 12:49
  • I have just changed package name in apktool.yml but it didn't generated new apk – Muhammad Muazzam Apr 13 '17 at 12:12
  • After using this method and signing, the app will not install – cascading-style Dec 16 '17 at 18:43
  • 1
    @cascading-style you probably need to delete the existing signature first. If you need more help, feel free to create a question. Make sure you include any errors from adb install, including any errors that show up in logcat during the install. – JesusFreke Dec 16 '17 at 22:06
  • What about when the app contains a binary? – cascading-style Dec 17 '17 at 07:09
  • This worked for me: I had to get around a program blocking NewPipe, so I just changed the `renameManifestPackage` property from `null` to `org.duolabs.newpipe` and it allowed it to run. +1! – DUO Labs Jun 26 '21 at 23:57
  • Can use [uber-apk-signer](https://github.com/patrickfav/uber-apk-signer) to quickly sign the apk. Found it from this [so answer](https://stackoverflow.com/a/40064149/8608146). – Phani Rithvij Jul 06 '21 at 15:44
6

To my knowledge there are no fast ways to change the package name. You have to change the package="com.mycompany.myapp" in Manifest.xml and then manually replace all the package name occurrences in smali files (and folders). Finally edit apktool.yml replacing the old package name, with your new package name.

A full detailed tutorial can be found here: http://forum.xda-developers.com/showthread.php?t=2760965

Luca D'Amico
  • 3,026
  • 1
  • 23
  • 36
  • there are also may be **custom views** so it's needed to change package names in xml – Vlad Apr 28 '18 at 06:53