UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Edit Anbox System

    Scheduled Pinned Locked Moved Support
    11 Posts 5 Posters 3.5k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • M Offline
        mmm648
        last edited by advocatux

        I'm trying to follow a guide anbox: how to install google play store

        I've edited the script to match the anbox on my ubuntu touch but I'm encountering the error "cp: cannot create directory '/home/phablet/anbox-data/rootfs/system/priv-app/PrebuiltGmsCore': read-only file system" even after running "sudo anbox-tool disable" and "sudo mount -o rw,remount /".

        Wondering how to proceed without destroying my anbox, should I change file permissions or something? Would I be able to change all the file permissions and then switch back?

        Below is my modified script I'm trying to run from /home/phablet.

        #!/bin/bash
        
        # Copyright 2018 root@geeks-r-us.de
        
        # Permission is hereby granted, free of charge, to any person obtaining a copy
        # of this software and associated documentation files (the "Software"), to deal
        # in the Software without restriction, including without limitation the rights to
        # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
        # of the Software, and to permit persons to whom the Software is furnished to do so,
        # subject to the following conditions:
        
        # The above copyright notice and this permission notice shall be included in all
        # copies or substantial portions of the Software.
        
        # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
        # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
        # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
        # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
        # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
        # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
        # For further information see: http://geeks-r-us.de/2017/08/26/android-apps-auf-dem-linux-desktop/
        
        # If you find this piece of software useful and or want to support it's development think of 
        # buying me a coffee https://www.buymeacoffee.com/YdV7B1rex
        
        # die when an error occurs
        set -e
        
        
        #OPENGAPPS_URL="https://github.com/opengapps/x86_64/releases/download/$OPENGAPPS_RELEASEDATE/$OPENGAPPS_FILE"
        #HOUDINI_URL="http://dl.android-x86.org/houdini/7_y/houdini.sfs"
        #HOUDINI_SO="https://github.com/Rprop/libhoudini/raw/master/4.0.8.45720/system/lib/libhoudini.so"
        
        OPENGAPPS_RELEASEDATE="20190203"
        OPENGAPPS_FILE="open_gapps-x86_64-7.1-mini-$OPENGAPPS_RELEASEDATE.zip"
        
        ####SWITCH FOR TESTING#####
        OVERLAYDIR="/home/phablet/anbox-data/rootfs"
        SYSTEMDIR="/home/phablet/anbox-data"
        WORKDIR="/home/phablet/anbox-work"
        ######
        APPDIR="$OVERLAYDIR/system/priv-app" 
        BINDIR="$OVERLAYDIR/system/bin"
        LIBDIR="$OVERLAYDIR/system/lib"
        PERMDIR="$OVERLAYDIR/system/etc/permissions/"
        
        
        
        
        #SETUP "Create $WORKDIR with houdini.sfs,libhoudini.so,$OPENGAPPS_FILE", recreate anbox-data+anbox-work for new tests using new files+new device files, run anbox.appmgr once(both through settings and anbox-tool), install required dependencies, check guide updates, set opengapps release date
        
        # check if script was started with BASH
        if [ ! "$(ps -p $$ -oargs= | awk '{print $1}' | grep -E 'bash$')" ]; then
           echo "Please use BASH to start the script!"
        	 exit 1
        fi
        
        # check if user is root
        if [ "$(whoami)" != "root" ]; then
        	echo "Sorry, you are not root. Please run with sudo $0"
        	exit 1
        fi
        
        if [ ! -d "$WORKDIR" ]; then
        	echo -e "Create $WORKDIR with houdini.sfs,libhoudini.so,$OPENGAPPS_FILE"
        	exit 1
        fi
        
        if [ ! -d "$APPDIR" ]; then
        	echo -e "$OVERLAYDIR doesn't contain $APPDIR!"
        	exit 1
        fi
        
        if [ ! -d "$BINDIR" ]; then
        	echo -e "$OVERLAYDIR doesn't contain $BINDIR!"
        	exit 1
        fi
        
        if [ ! -d "$PERMDIR" ]; then
        	echo -e "$OVERLAYDIR doesn't contain $PERMDIR!"
        	exit 1
        fi
        
        if [ ! -d "$LIBDIR" ]; then
        	echo -e "$OVERLAYDIR doesn't contain $LIBDIR!"
        	exit 1
        fi
        
        if [ ! -f "$WORKDIR/houdini.sfs" ]; then
        	echo -e "Place houdini.sfs in $WORKDIR"
        	exit 1
        fi
        
        if [ ! -f "$WORKDIR/libhoudini.so" ]; then
        	echo -e "Place libhoudini.so in $WORKDIR"
        	exit 1
        fi
        
        if [ ! -f "$WORKDIR/$OPENGAPPS_FILE" ]; then
        	echo -e "Place $OPENGAPPS_FILE in $WORKDIR"
        	exit 1
        fi
        
        if [ ! -d "$OVERLAYDIR" ]; then
        	echo -e "Anbox-data/rootfs folder not found at $OVERLAYDIR"
        	exit 1
        fi
        
        # check if lzip is installed
        if [ ! "$(which lzip)" ]; then
        	echo -e "lzip is not installed. Please install lzip.\nExample: sudo apt install lzip"
        	exit 1
        fi
        
        # check if squashfs-tools are installed
        if [ ! "$(which mksquashfs)" ] || [ ! "$(which unsquashfs)" ]; then
        	echo -e "squashfs-tools is not installed. Please install squashfs-tools.\nExample: sudo apt install squashfs-tools"
        	exit 1
        else
        	MKSQUASHFS=$(which mksquashfs)
        	UNSQUASHFS=$(which unsquashfs)
        fi
        
        # check if wget is installed
        if [ ! "$(which wget)" ]; then
        	echo -e "wget is not installed. Please install wget.\nExample: sudo apt install wget"
        	exit 1
        else
        	WGET=$(which wget)
        fi
        
        # check if unzip is installed
        if [ ! "$(which unzip)" ]; then
        	echo -e "unzip is not installed. Please install unzip.\nExample: sudo apt install unzip"
        	exit 1
        else
        	UNZIP=$(which unzip)
        fi
        
        # check if tar is installed
        if [ ! "$(which tar)" ]; then
        	echo -e "tar is not installed. Please install tar.\nExample: sudo apt install tar"
        	exit 1
        else
        	TAR=$(which tar)
        fi
        
        # use sudo if installed
        if [ ! "$(which sudo)" ]; then
        	SUDO=""
        else
        	SUDO=$(which sudo)
        fi
        
        $SUDO anbox-tool disable
        sudo mount -o rw,remount /
        
        cd "$WORKDIR"
        
        if [ -d "$WORKDIR/squashfs-root" ]; then
          $SUDO rm -rf squashfs-root
        fi
        
        # get image from anbox
        cp "$SYSTEMDIR/android.img" .
        $SUDO $UNSQUASHFS android.img
        
        # get opengapps and install it
        cd "$WORKDIR"
        $UNZIP -d opengapps ./$OPENGAPPS_FILE
        
        cd ./opengapps/Core/
        for filename in *.tar.lz
        do
            $TAR --lzip -xvf ./$filename
        done
        
        cd "$WORKDIR"
        
        $SUDO cp -r ./$(find opengapps -type d -name "PrebuiltGmsCore")					$APPDIR
        $SUDO cp -r ./$(find opengapps -type d -name "GoogleLoginService")				$APPDIR
        $SUDO cp -r ./$(find opengapps -type d -name "Phonesky")						$APPDIR
        $SUDO cp -r ./$(find opengapps -type d -name "GoogleServicesFramework")			$APPDIR
        
        cd "$APPDIR"
        $SUDO chown -R 100000:100000 Phonesky GoogleLoginService GoogleServicesFramework PrebuiltGmsCore
        
        # load houdini and spread it
        cd "$WORKDIR"
        
        mkdir -p houdini
        $SUDO $UNSQUASHFS -f -d ./houdini ./houdini.sfs
        
        $SUDO cp -r ./houdini/houdini "$BINDIR/houdini"
        
        $SUDO cp -r ./houdini/xstdata "$BINDIR/"
        $SUDO chown -R 100000:100000 "$BINDIR/houdini" "$BINDIR/xstdata"
        
        $SUDO cp "$WORKDIR/libhoudini.so" "$LIBDIR"
        $SUDO chown -R 100000:100000 "$LIBDIR/libhoudini.so"
        
        $SUDO mkdir -p "$LIBDIR/arm"
        $SUDO cp -r ./houdini/linker "$LIBDIR/arm"
        $SUDO cp -r ./houdini/*.so "$LIBDIR/arm"
        $SUDO cp -r ./houdini/nb "$LIBDIR/arm"
        
        $SUDO chown -R 100000:100000 "$LIBDIR/arm"
        
        # add houdini parser
        $SUDO mkdir -p "$OVERLAYDIR/system/etc/binfmt_misc"
        echo ":arm_dyn:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x28::/system/bin/houdini:" >> "$OVERLAYDIR/system/etc/binfmt_misc/arm_dyn"
        echo ":arm_exe:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28::/system/bin/houdini:" >> "$OVERLAYDIR/system/etc/binfmt_misc/arm_exe"
        $SUDO chown -R 100000:100000 "$OVERLAYDIR/system/etc/binfmt_misc"
        
        # add features
        C=$(cat <<-END
          <feature name="android.hardware.touchscreen" />\n
          <feature name="android.hardware.audio.output" />\n
          <feature name="android.hardware.camera" />\n
          <feature name="android.hardware.camera.any" />\n
          <feature name="android.hardware.location" />\n
          <feature name="android.hardware.location.gps" />\n
          <feature name="android.hardware.location.network" />\n
          <feature name="android.hardware.microphone" />\n
          <feature name="android.hardware.screen.portrait" />\n
          <feature name="android.hardware.screen.landscape" />\n
          <feature name="android.hardware.wifi" />\n
          <feature name="android.hardware.bluetooth" />"
        END
        )
        
        
        C=$(echo $C | sed 's/\//\\\//g')
        C=$(echo $C | sed 's/\"/\\\"/g')
        
        
        $SUDO sed -i "/<\/permissions>/ s/.*/${C}\n&/" "$OVERLAYDIR/system/etc/permissions/anbox.xml"
        
        # make wifi and bt available
        $SUDO sed -i "/<unavailable-feature name=\"android.hardware.wifi\" \/>/d" "$OVERLAYDIR/system/etc/permissions/anbox.xml"
        $SUDO sed -i "/<unavailable-feature name=\"android.hardware.bluetooth\" \/>/d" "$OVERLAYDIR/system/etc/permissions/anbox.xml"
        
        if [ ! -x "$OVERLAYDIR/system/build.prop" ]; then
          $SUDO cp "$WORKDIR/squashfs-root/system/build.prop" "$OVERLAYDIR/system/build.prop"
        fi
        
        # set processors
        ARM_TYPE=",armeabi-v7a,armeabi"
        $SUDO sed -i "/^ro.product.cpu.abilist=x86_64,x86/ s/$/${ARM_TYPE}/" "$OVERLAYDIR/system/build.prop"
        $SUDO sed -i "/^ro.product.cpu.abilist32=x86/ s/$/${ARM_TYPE}/" "$OVERLAYDIR/system/build.prop"
        
        $SUDO echo "persist.sys.nativebridge=1" >> "$OVERLAYDIR/system/build.prop"
        
        # enable opengles
        $SUDO echo "ro.opengles.version=131072" >> "$OVERLAYDIR/system/build.prop"
        
        sudo mount -o ro,remount /
        $SUDO anbox-tool enable
        
        advocatuxA 1 Reply Last reply Reply Quote 0
        • advocatuxA Offline
          advocatux @mmm648
          last edited by

          @mmm648 hi, I've edited your post to make it more readable. I hope that's fine for you.

          Tip: you can also use a pastebin service (like e.g. https://paste.ubuntu.com/) and just paste the resulting link here when you need to post a lot of text 🙂

          1 Reply Last reply Reply Quote 0
          • M Offline
            mmm648
            last edited by

            Ah ok, thanks.

            1 Reply Last reply Reply Quote 0
            • IngoI Offline
              Ingo
              last edited by Ingo

              Haven't tried this myself yet, but the first thing that comes to my mind: do you need the libhoudini stuff on a smartphone at all? From what I understood, this is needed for anbox running on Intel/AMD platform (i.e. a PC).

              About the read-only filesystem I would guess that you have to remount the android image as read-write, not the UT root FS.

              Edit: wanted to try it out but the opengapps repositories are disabled by github due to excessive use of resources...

              1 Reply Last reply Reply Quote 0
              • IngoI Offline
                Ingo
                last edited by

                Found an older version of the 7.1 opengapps pico on my laptop and then followed the German instructions on https://geeks-r-us.de/2017/08/26/android-apps-auf-dem-linux-desktop/ (the English instructions/script are based on this).

                So I was able to add the gapps to the android.img on my PC, then transferred the image to the phone (don't forget to anbox-tool disable before the transfer and anbox-tool enable after it's finished) and saw the Play Store icon on the app scope 😉

                The apps that said they would not run properly without gapps now said I need to update my Play Services (by backup only contained the gapps from Dec. 2017). That unfortunately failed. Also opening the Play Store didn't work. Guess it also found the play services to be outdated and then failed to update them.

                I guess it only makes sense when using up-to-date opengapps (once their repos are back up).

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tigerpro
                  last edited by

                  Has anyone tried to do something like this with microg instead of opengapps? I am curious if that's work.

                  Whether you think you can, or you can't, if you do not try, you will never truly know. So give it a Go.

                  1 Reply Last reply Reply Quote 0
                  • IngoI Offline
                    Ingo
                    last edited by

                    Tried microG as well. Didn't work much better. The apps I checked claimed there were no gapps installed.

                    When I opened the microG settings they claimed I need to grant permissions first. After I granted them, everything just crashed.

                    Now that the opengapps repos are up again I'll try with a new version of those.

                    1 Reply Last reply Reply Quote 0
                    • IngoI Offline
                      Ingo
                      last edited by

                      With current opengapps pico it's similar to my microG experience: everything gets more unstable and apps seem to start but then close unexpectedly.

                      For now I'm back to unmodified anbox.

                      Maybe this is device related. I'm on Fairphone 2 and I've read about frequent crashes that don't happen on other phones. Maybe better luck with those. But then, maybe I overlooked something and someone with an FP2 has more luck (or time to dig deeper...).

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        mmm648
                        last edited by

                        Ya my attempt made everything unstable as well(oneplusone), only thing I noticed was you need to add "-no-xattrs" to mksquashfs to match the current android.img, also switch to "-Xbcj arm" ofc.

                        On one attempt I managed to disable google play services by rushing before settings crashed lol, didn't help with other apps that require google play though.

                        xsetiadiX 1 Reply Last reply Reply Quote 1
                        • xsetiadiX Offline
                          xsetiadi @mmm648
                          last edited by

                          @mmm648 said in Edit Anbox System:

                          -no-xattrs

                          hello sir, im trying to unpack and repack android.img on anbox using mksquash, but always get error (eg) source directory vendor already in use, trying venror_1

                          so now on my android.img there arae 2 vendor folder. any idea why this is happen?

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            mmm648
                            last edited by

                            Well did you remember to
                            "sudo anbox-tool disable
                            sudo mount -o rw,remount /"

                            like in the script?(and reverse afterwards)

                            I never got opengapps to work but I think to edit the system I ended up copying the android.img to another directory, running unsquashfs on it, modifying it, resquashing it (mksquashfs) and then overwrite the original image.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post