1

I'm making a flashable zip for TWRP, to debloat my phone. I also want to install apps in the same script.

However, when I do "pm install /path/to.apk" (whether in a script or through the terminal) I get the following error:

Error: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder android.os.IServericeManager.getService(java.lang.String)' on a null object reference

I get the same error when I try other pm commands, but when I input only "pm" I do get the help message.

Is it not possible to install .apks this way or is something else wrong?

Thanks!

1

Use script to place the APK file at the correct place in /data/app instead.

mkdir,mv,chown and chmod are to be used.

While pm binary is there, it cannot do it's work from recovery that is a completely different system. See this as someone trying to install a game on his Windows system while booted on Ubuntu.

0

While @Zulgrib has already described why pm wouldn't work, I'll supply a bit of extra info on integrating apps into the flashable zip.

Basically, you put the apps' APKs in the correct location in the zip, and have the updater-script extract it to where it belongs. The script usually does this by executing:

package_extract_dir("data", "/data");

Thus for an APK with package name com.abc, usually it should be placed in /data/app/com.abc-1/base.apk for it to properly install. Unlike what @Zulgrib said, no shell commands are needed - the extraction script does everything for you.

Do note that:

  • If you already have this app installed and subsequently updated, there might be a folder like com.abc-2 which your flashable zip can't overwrite, and installation will fail. My suggestion is only use such flashable zips to update apps contained inside, so that the folder names will always have -1 behind and will be updated properly.
  • Some apps require more than the APK in the directory to be able to run. In my case, I observed Jackpal's Terminal Emulator requires its libraries to be extracted, but I never got how to do so right, so in the end I resorted to installing it manually.
  • Extracting libs is as simple as issuing an unzip command. Then chmod & chown correctly and it'll work. – iBug May 15 '17 at 2:06
  • @iBug Problem is, I have both ARM and ARM64 devices which need different sets of libs, but from the log output of the app, it seems to look for the libs in the same folder regardless of arch. Can't bother figuring out how to pre-determine the arch just to install such one minor app. If you have surefire details on how to do it, just edit it in, I'm open to experiment. – Andy Yan May 15 '17 at 2:22
  • Extract lib/armeabi and lib/armeabi-v8a for ARM and ARM64 devices, respectively. – iBug May 15 '17 at 2:26
  • Thanks for the info. I'm working from a clean install so updates aren't an issue, but it's probably easier to write a batch script for adb in cmd than to figure out which apps need libraries extracted etc. I can at least install a launcher and a file manager right away so that I have a working barebone install to work from. – bur May 15 '17 at 7:57
  • I have included tens of apps in my own flashable zip and Terminal Emulator seems to be the only anomaly. That said, when I intend to add apps into the zip, I always first assume that they don't need the libs, and expel the anomaly afterwards (the anomaly will force close upon being opened, a good sign something's wrong). – Andy Yan May 15 '17 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.