Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root permission for apps #118

Open
daryl0 opened this Issue Apr 15, 2017 · 72 comments

Comments

Projects
None yet
@daryl0
Copy link

daryl0 commented Apr 15, 2017

I want install gapps from apk. For install it is necessary root permission.

With command adb shell and then SU I Take root permission but I stop it.

Help me.

@dispicio

This comment has been minimized.

Copy link

dispicio commented Apr 18, 2017

We need to modify android.img for this.
Extract the image (sudo to preserve permission/owner/groups):
sudo unsquashfs android.img
Then make your desired modifications (like cp su to /system/bin. Mind permissions/owner/groups of the new files).
Finally "repack" the image:
mksquashfs squashfs-root android.img -b 131072 -comp xz -Xbcj x86

Get the Google apps here (cp to /var/lib/anbox/rootfs/system/app): http://opengapps.org/
Latest SuperSU-zip (cp to /var/lib/anbox/rootfs/system/bin): http://www.supersu.com/download

I haven't been able to get GApps running though.. 😒
Maybe someone else is luckier?

@daryl0

This comment has been minimized.

Copy link
Author

daryl0 commented Apr 18, 2017

android image (android.img) I found in /snap/anbox/current ?

cd /snap/anbox/current and then you command? sudo unsquashfs android.img and then repack android image is ok?

@daryl0

This comment has been minimized.

Copy link
Author

daryl0 commented Apr 19, 2017

I try Extract android.img from /snap/anbox/current but it is read only.

I download android.img from here (http://build.anbox.io/android-images/2017/04/12/android_1_amd64.img)
Then i follow you command:

I try it and report here result.

@subjectdenied

This comment has been minimized.

Copy link

subjectdenied commented Apr 19, 2017

everytime i tried to change something in the unsquashed image, after squashing it again, the image is running for me. however adb won't see the emulator device anymore

@morphis

This comment has been minimized.

Copy link
Member

morphis commented Apr 19, 2017

@subjectdenied the ADB connection is a bit flawky. Something we should rework. Can you open a separate issue for that?

@dispicio

This comment has been minimized.

Copy link

dispicio commented Apr 19, 2017

Another try. Got play store starting, but as there is no network connection (another problem #51), it's pretty useless. I did not get root working! (tried to put su in /system/xbin with suid and symlink it from /system/bin). Anyhow, here's what I did for the play store:

  1. sudo unsquashfs android.img
  2. Download & extract http://opengapps.org/ (x86_64, 7.1, mini)
  3. Extract Core/vending-all.tar.lz, Core/gsflogin-all.tar.lz, Core/gsfcore-all.tar.lz, Core/gmscore-x86_64.tar.lz
  4. Find and copy the folders Phonesky, GoogleLoginService, GoogleServicesFramework, PrebuiltGmsCore you extracted in 3. to squashfs-root/system/priv-app/
  5. sudo chown -R 100000:100000 Phonesky GoogleLoginService GoogleServicesFramework PrebuiltGmsCore inside squashfs-root/system/priv-app
  6. sudo mksquashfs squashfs-root android.img -b 131072 -comp xz -Xbcj x86

[Edit: Got network running after installing dnsmasq and getting anbox-bridge.sh from this repo. sudo ./anbox-bridge.sh start. On Arch Linux]
[Edit 2: Google Play Store launches, I'm able to login. There are no apps available though, now fiddling with system/build.prop.]
[Edit 3: Has anyone a x86 chromebook and is willing to provide its build.prop?]

@subjectdenied

This comment has been minimized.

Copy link

subjectdenied commented Apr 19, 2017

@dispicio : session-manager is crashing for me after using the image modified as you explain, also the new image is 4x the size of the original one

@dispicio

This comment has been minimized.

Copy link

dispicio commented Apr 19, 2017

I guess the crashing is normal; this software is pre-alpha. You can try to fiddle around with the -comp compression parameters in mksquashfs in order to make the image smaller (I get a roughly 15% bigger image than the original though, not 4x).

@subjectdenied

This comment has been minimized.

Copy link

subjectdenied commented Apr 19, 2017

@dispicio : size was my fault, crash is gone too. seems like the "device" is configured for tablets only. i see some new apps, also can see some i own

@daryl0

This comment has been minimized.

Copy link
Author

daryl0 commented Apr 19, 2017

@dispicio sorry I am exhausted. Kindly write me exactly all the steps, but especially the working directory in question as well as at the controls? On Linux I work with Android but I have a lot of practice.

Thanks and excuse me. :-(

@oleid

This comment has been minimized.

Copy link

oleid commented Apr 21, 2017

@dispicio Thanks for letting me know how to get PlayStore working.

FYI: I had a little trouble getting DNS working in the container (pinging was successfully tested via adb shell ). The anbox-bridge.sh script didn't work for me, however specifying a DNS server in /usr/lib/systemd/network/80-anbox-bridge.network successfully passed it down to the container.

The only problem now is that phone-only apps like Threema, WhatsApp or TomTom Go are not installable since my device isn't compatible with this version -- according to PlayStore.

@asharptech

This comment has been minimized.

Copy link

asharptech commented Apr 22, 2017

@oleid install them from apkmirror.com ?

@oleid

This comment has been minimized.

Copy link

oleid commented Apr 23, 2017

Thanks for the hint. It would seem, as if the TomTom app is only available for ARM. That's a pity. I guess one would have to hook up the runtime with qemu, as they did with the ASUS Zenphone.

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented Apr 29, 2017

@dispicio
After step 6, where do i save generated android.img file?

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented Apr 29, 2017

dear @dispicio

thanks a lot, your tip worked. But I had to change the google service and play store in [settins / apps] permissions, granting these apps all permissions. I did not need to change the build.prop

[Edit 2: Google Play Store launches, I'm able to login. There are no apps available though, now fiddling with system/build.prop.]

@markmcwong

This comment has been minimized.

Copy link

markmcwong commented Apr 30, 2017

Hi I followed the step by dispicio and unsquashfs the android.img,
I also extracted those 4 folders in the correct place and i sudo chown them and squashing them again.
Then I use sudo anbox container-manager --android-image=/home/mark/anbox-work/anbox/android.img --data-path=/home/mark/anbox-data and restart my computer.

I tried to use playstore it opens and close immediately (youtube requires google play services), any suggestion?
(Is su necessary in this case?)

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented Apr 30, 2017

Have you ever tried to change the permissions of google play store? Go in settings-->apps-->play store and choose permissions to play store.

@markmcwong

This comment has been minimized.

Copy link

markmcwong commented Apr 30, 2017

I allow all permissions for play store and allows modify system settings but still no luck

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented Apr 30, 2017

@markmcwong You have to do the same with google play service.

ex

@markmcwong

This comment has been minimized.

Copy link

markmcwong commented Apr 30, 2017

@gilzamir thank you for your help, it works and now youtube wont ask for google play framework and play store doesnt close after open but playstore just remain as a blank screen and when I clear data/cache and restart it spinner appears for like 5s and disappear and remain blank screen

@subjectdenied

This comment has been minimized.

Copy link

subjectdenied commented Apr 30, 2017

@gilzamir : do you see all play store apps, or just a fraction of it? cause when i tried this days ago, i only saw about 4 apps available, that i didn't have installed yet on any of my devices before. i could get more apps shown by changing system/build.props, however never got the same pool as my phone would give me

@markmcwong

This comment has been minimized.

Copy link

markmcwong commented Apr 30, 2017

@subjectdenied I cant see any play store apps as it remains a white blank screen.
I researched about the problem as people suggested to clear cache and data + remove google account

However when I tried to add my Google Account in Settings > Account it just close immediately

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented Apr 30, 2017

@subjectdenied @markmcwong I can see a few apps. It must be because the image android.img architecture is x86 and most of the apps just support arm. In addition, the build.prop file does not seem to be well configured. You can solve some of the problem by changing the build.prop file.

I've downloaded several apps from the appmirror site and they're working fine.

image

I can not find youtube, but I can grab a few apps.

image

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented Apr 30, 2017

Dear, the internet is necessary for the play store works. Run the following command to internet to work in the container

sudo /snap/anbox/current/bin/anbox-bridge.sh start

@ktp420

This comment has been minimized.

Copy link

ktp420 commented May 2, 2017

Anyone here build an arm android image and got arm apps running inside it?

@seanlano

This comment has been minimized.

Copy link

seanlano commented May 2, 2017

@ktp420 that would require an ARM CPU. Anbox doesn't emulate a CPU, it uses the host computer hardware.

@ktp420

This comment has been minimized.

Copy link

ktp420 commented May 2, 2017

Yes I know but was just wondering if something tried it

@gilzamir

This comment has been minimized.

Copy link

gilzamir commented May 7, 2017

@ktp420 It may be more helpful to try to get a image of the AndroidX86 project. I think AndroidX86 has arm support, even though it's x86.

@ktp420

This comment has been minimized.

Copy link

ktp420 commented May 13, 2017

I build the arm image for sources...just didn't want to download 40 gb if didn't need to.

@lemrm

This comment has been minimized.

Copy link

lemrm commented Feb 22, 2018

@step21

Unmount the snap ... Replace the android.img there with the new one

How to do this? I can't get it.

@Rehazen

This comment has been minimized.

Copy link

Rehazen commented Apr 10, 2018

@geeks-r-us i just literally start using linux 3 days ago, what must i do with script step by step in your blog? copy-paste in terminal?
something i did is copying your full script, and try to run in terminal, after that my anbox just in the "starting" screen (can't go in menu)

@datamaskinen

This comment has been minimized.

Copy link

datamaskinen commented Apr 23, 2018

it would be good if someone could put up a done .img file on github instead maybe

@shawe

This comment has been minimized.

Copy link

shawe commented Jun 17, 2018

@step21 Your external link works for me. This page contains this script https://github.com/geeks-r-us/anbox-playstore-installer/raw/master/install-playstore.sh

On Antergos I need to replace line 106, with cp /var/lib/anbox/android.img .
And from line 203 to the end with (this part seems to be very different):

#cd /var/lib/snapd/snaps
cp $WORKDIR/android.img /var/lib/anbox/android.img
$SUDO systemctl restart anbox-container-manager.service

Not works perfect, but is a step closer. Maybe as @morphis say, is needed a beeter https://github.com/anbox/device_anbox/blob/master/anbox.xml

@morphis

This comment has been minimized.

Copy link
Member

morphis commented Jun 25, 2018

For everyone interested, there is now a much easier way to modify the Android rootfs without touching the android.img. See #774 and https://docs.anbox.io/userguide/advanced/rootfs_overlay.html (wait with trying it out until the PR has landed)

@Shotman

This comment has been minimized.

Copy link

Shotman commented Jun 27, 2018

@morphis I've used the command listed on the official doc but I can't run any app as root, am I missing something ?
For instance I've sucessfuly installed the opengapps apk app, and ran anbox with the --rootfs=android-rootfs option but I can't check the "Use Root Permission" option in the app settings, I get a toast message saying : "Your device must be rooted in order to activate"

@LWJGLRobot

This comment has been minimized.

Copy link

LWJGLRobot commented Jul 16, 2018

it is easy to root anbox
1)unpack android.img
2)read and use this SuperSU.apk/META-INF/com/google/android/update-binary line:85
or do this (approximately same as update-binary script at lines 85-114):
cp common/Superuser.apk system/app/SuperSU/SuperSU.apk
cp x64/su system/xbin/su
cp x64/su system/bin/.ext/.su
cp x64/su system/xbin/daemonsu
cp x64/supolicy system/xbin/supolicy
cp x64/libsupol.so system/lib64/libsupol.so
cp system/bin/app_process64 system/bin/app_process_init
cp system/bin/app_process64 system/bin/app_process64_original
cp system/xbin/daemonsu system/bin/app_process
cp system/xbin/daemonsu system/bin/app_process64
chmod +x all-files-you-changed
3)pack android.img and put it to anbox folder, where from it taken.
4)restart container-manager
5)restart session-manager

i got supersu work.
screenshot from 2018-07-16 19-21-11

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Jul 16, 2018

Ok @morphis already commented, that should be easily achievable with the --use-rootfs-overlay option... however, I was unable to make supersu work properly.
The overlaid /system/xbin/su just doesn't mask the existing one, which lacks exec permissions.

How is this, why are only those files in rootfs-overlay not already in rootfs visible in combined-rootfs ?
Here's my attempt at overlaying SuperSU v2.82 ...
rootfs-overlay.tar.gz

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Jul 29, 2018

OK @morphis according to kernel docs:

mount -t overlay overlay -olowerdir=/lower1:/lower2:/lower3 /merged

As the example shows, "upperdir=" and "workdir=" may be omitted.  In
that case the overlay will be read-only.

The specified lower directories will be stacked beginning from the
rightmost one and going left.  In the above example lower1 will be the
top, lower2 the middle and lower3 the bottom layer.

So the stacking order of the lowerdirs should be reversed as in:
lowerdir=/var/lib/anbox/rootfs-overlay:/var/lib/anbox/rootfs

@morphis

This comment has been minimized.

Copy link
Member

morphis commented Jul 30, 2018

@eMPee584 That got fix with one of the latest PRs. See #811

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Sep 7, 2018

Wohoo! Seems to work now, with the files I posted earlier placed in the rootfs overlay. 🤠

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 6, 2018

I'm on Debian unstable and I got Anbox running by sudo apt install anbox, no PPA or drivers, and that's great. But there's no F-Droid, and according to this thread, I need to fiddle with some script in the snap directory for GApps. Any idea where I can find those in the Debian repo's package?

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 6, 2018

I went through the thread again, and I realized I've no idea what I'm talking about. I'll go through this all tomorrow, good night.

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Oct 6, 2018

@oxwivi the gapps thing is quite a mission, infusing the houdini libs into the local image and such... I actually got the play store & f.e. maps to work with geeks-r-us/anbox-playstore-installer#14 , albeit with a "slight" rendering issue (using proprietary nvidia x11 driver)...
image

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 7, 2018

@oxwivi the gapps thing is quite a mission, infusing the houdini libs into the local image and such... I actually got the play store & f.e. maps to work with geeks-r-us/anbox-playstore-installer#14 , albeit with a "slight" rendering issue (using proprietary nvidia x11 driver)...
image

I've a couple of questions:

  • with the premise it's not a snap install, why doesn't it check for android.img at /var/lib/anbox/android.img or attempting to download from https://build.anbox.io/android-images as specified in the file:///usr/share/doc/anbox/README.Debian?
  • Is there anything I can do to the script to let it install F-Droid in it?

The GApps scripts aside, why is there no way to just plop in an .apk into the root of the container where we can navigate to using Files and installing it like a normal device?

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 8, 2018

EDIT
Never mind, I logged in as expected now. I forgot the step to grant permissions to Google Play Services. I wonder if there's a bare minimum permission grants that'll get it working or if it absolutely requires all permissions for getting it to run.

screenshot_20181008_135652
I used @eMPee584's script, got Anbox running, logged in with my credentials, accepted terms and conditions and was greeted with this. What did you do to deal with this? I think it's to do with the lacking device specifications some of the comments mentioned.

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Oct 8, 2018

Not sure what fails for you (adb logcat -sv color \*:E); I've just adapted the playstore-installer to play a bit nicer with non-snap anbox.
Or you just throw APKs into /var/lib/anbox/data/media/0 which is the "internal sdcard" and install them from there..

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 8, 2018

The failure was because of permissions, I didn't give permissions to Google Play Store and Services. After that, it's logging in just fine, but the problem is it crashes before I can do anything. At some times, opening the menu on the Store will freeze it, others, I was able to go to My Apps and Games where the loading animation ran perpetually until I interacted with it and it crashed. Scrolling down for a few seconds also crashes Play Store.

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 8, 2018

I was able to install apps from the home screen of Google Play Store. Trying to do anything else crashes it. No idea what's at fault and how to go about debugging either.

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Oct 8, 2018

adb logcat -sv color \*:E

@oxwivi

This comment has been minimized.

Copy link

oxwivi commented Oct 9, 2018

adb logcat -sv color \*:E

I didn't want to install adb, but now I went ahead and did it. However, this command causes a veritable ejaculation on my terminal. With Anbox session running but no app, not even the manager is running, the constant output is already making it impossible to follow, let alone anything specific due to my actions.

@ShapeShifter499

This comment has been minimized.

Copy link

ShapeShifter499 commented Oct 20, 2018

@eMPee584 Do you think your overlay supersu could be modified for Magisk? This would possibly be good when running apps that don't like root or other non-approved system properties.

@ningacoding

This comment has been minimized.

Copy link

ningacoding commented Oct 29, 2018

Play Store crashing for me :(

i have installed Play Store with:

wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
chmod +x install-playstore.sh
sudo ./install-playstore.sh

Granted all permissions to Service and Store app, and logged in, but app closes alone.

playstore_crash_anbox

Ubuntu 18.04.1LTS
Fresh Anbox install

EDIT:
It fixed it by updating the oppengapps file to latest (29 October 2018) in the script install-playstore.sh

@eMPee584

This comment has been minimized.

Copy link
Contributor

eMPee584 commented Oct 29, 2018

Do you think your overlay supersu could be modified for Magisk?

Magisk has its own su and "Magisk Hide" mechanism ..
but Magisk itself would be a candidate for the root overlay.

@ShapeShifter499

This comment has been minimized.

Copy link

ShapeShifter499 commented Nov 4, 2018

@eMPee584 I tried poking around to getting it installed but I don't know which file to patch since there is no bootloader. I'm guessing that a img file for Magisk needs to be put at /data/magisk.img inside of the installed Android image. Then Anbox needs to be pointed at the one of the included magisk binaries to be loaded when it starts. But I wasn't 100% sure how to do this.

@gggauravgandhi

This comment has been minimized.

Copy link

gggauravgandhi commented Dec 27, 2018

Ok @morphis already commented, that should be easily achievable with the --use-rootfs-overlay option... however, I was unable to make supersu work properly.
The overlaid /system/xbin/su just doesn't mask the existing one, which lacks exec permissions.

How is this, why are only those files in rootfs-overlay not already in rootfs visible in combined-rootfs ?
Here's my attempt at overlaying SuperSU v2.82 ...
rootfs-overlay.tar.gz

This works now, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.