1

Prerequisites:

  • a rooted Rockchip-based China tablet device running Android 6, patched to disable SystemUI

  • own-developed app which declares LAUNCHER category and is intended to take full conrol of the device

What am I trying to achieve:

install the app as a system app to avoid handling SDK 23+ permissions

What have I done so far:

  • installed the app regularly via Android Studio
  • moved the app to /system/priv-app:

(root)

ls /data/app/my.package.name-1
 base.apk
 lib
 oat
mount -o rw,remount /system
mv /data/app/my.package.name-1 /system/priv-app/AppName
ls -la /system/priv-app/AppName
 -rw-r--r-- system   system    2464934 2017-12-08 11:32 base.apk
 drwxr-xr-x system   system            2017-12-08 11:32 lib
 drwxrwx--x system   install           2017-12-08 11:32 oat
reboot

What is the problem?

It seems the system is not aware the app exists: it does not run on boot (which it perfectly does when installed as a regular app) and I am unable to launch it manually:

root@rk312x:/ # am start -n my.package.name/.ui.MainActivity
Starting: Intent { cmp=my.package.name/.ui.MainActivity }
Error type 3
Error: Activity class {my.package.name/my.package.name.ui.MainActivity} does not exist.

What am I missing?

  • thx, this solved the problem with starting the app. It is still not granted permissions automatically, I guess due to non-system signature. The question was about running the app however, so please post your comments as answer – Maver1ck Dec 8 '17 at 11:51
  • 1
    Are you trying to get runtime permissions granted automatically? Being in that directory won't grant it automatically. You would need to be whitelisted by the Google signed package manager. You could just target API 22or below and you'd get any permissions you wanted by just installing the APK. – DataDino Dec 8 '17 at 15:44
2

Changing the permissions to -rw-r--r-- and owner as root followed by reboot should fix

But as OP pointed out signature issues need to be sorted out

2

Moving an application from one space to another on Marshmallow and more superior will almost always result in that. The best way use the cp command, after that delete the source. An application at data has it's own set permissions which persist to the system and though even if you change them, since there's no new instance of file creation, the system just doesn't take care to trigger preparation of the app. The best way is

cp /data/app/[package.name]-1/app-name.apk /system/app/[app-folder-name]/app-name.apk

Repeat this for the libs in the app folder to the app folder. The folder should look like:

APPNAME containing .apk and LIB folder LIB folder containing type of lib like ARM folder ARM folder with all libraries eg libexample.so

set permission of all folders to chmod 0755 and all files to permission chmod 0644

They will work. To make life easier, stop using the shell commands. Look for a file manager to simplify your work but always remember of you're using TWRP or Terminal on a boot device always copy and delete source. Moving for many ROMs will actually lead to that

NOTE: The oat folder in that folder at /data/app/package.name/ is of no use. Dalvik will create it's new classes.dex at /data/dalvik-cache on install as system application

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.