Anbox安裝apk失敗(提示Failure res=-113等)的解決方法

zhangrelay發表於2018-12-06

詳細描述,如下(Anbox:如何安裝Google Play商店並啟用ARM(libhoudini)支援,簡單方法):

Failed to install PACKAGE.NAME.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]


具體現象:

解決方案:

安裝Google Play商店並啟用ARM(libhoudini)支援,最新為181205,如下。

#!/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_RELEASEDATE="20181205"
OPENGAPPS_FILE="open_gapps-x86_64-7.1-mini-$OPENGAPPS_RELEASEDATE.zip"
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"

COMBINEDDIR="/var/snap/anbox/common/combined-rootfs"
OVERLAYDIR="/var/snap/anbox/common/rootfs-overlay"
WORKDIR="$(pwd)/anbox-work"

# 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

# 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


if [ ! -d "$COMBINEDDIR" ]; then
  # enable overlay fs
  $SUDO snap set anbox rootfs-overlay.enable=true
  $SUDO snap restart anbox.container-manager

  sleep 20
fi

echo $OVERLAYDIR
if [ ! -d "$OVERLAYDIR" ]; then
    echo -e "Overlay no enabled ! Please check error messages!"
	exit 1
fi

echo $WORKDIR
if [ ! -d "$WORKDIR" ]; then
    mkdir "$WORKDIR"
fi

cd "$WORKDIR"

if [ -d "$WORKDIR/squashfs-root" ]; then
  $SUDO rm -rf squashfs-root
fi

# get image from anbox
cp /snap/anbox/current/android.img .
$SUDO $UNSQUASHFS android.img

# get opengapps and install it
cd "$WORKDIR"
if [ ! -f ./$OPENGAPPS_FILE ]; then
  $WGET -q --show-progress $OPENGAPPS_URL
  $UNZIP -d opengapps ./$OPENGAPPS_FILE
fi


cd ./opengapps/Core/
for filename in *.tar.lz
do
    $TAR --lzip -xvf ./$filename
done

cd "$WORKDIR"
APPDIR="$OVERLAYDIR/system/priv-app" 
if [ ! -d "$APPDIR" ]; then
	$SUDO mkdir -p "$APPDIR"
fi

$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"
if [ ! -f ./houdini.sfs ]; then
  $WGET -q --show-progress $HOUDINI_URL
  mkdir -p houdini
  $SUDO $UNSQUASHFS -f -d ./houdini ./houdini.sfs
fi

BINDIR="$OVERLAYDIR/system/bin"
if [ ! -d "$BINDIR" ]; then
   $SUDO mkdir -p "$BINDIR"
fi

$SUDO cp -r ./houdini/houdini "$BINDIR/houdini"

$SUDO cp -r ./houdini/xstdata "$BINDIR/"
$SUDO chown -R 100000:100000 "$BINDIR/houdini" "$BINDIR/xstdata"

LIBDIR="$OVERLAYDIR/system/lib"
if [ ! -d "$LIBDIR" ]; then
   $SUDO mkdir -p "$LIBDIR"
fi

$SUDO $WGET -q --show-progress -P "$LIBDIR" $HOUDINI_SO
$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')

if [ ! -d "$OVERLAYDIR/system/etc/permissions/" ]; then
  $SUDO mkdir -p "$OVERLAYDIR/system/etc/permissions/"
  $SUDO cp "$WORKDIR/squashfs-root/system/etc/permissions/anbox.xml" "$OVERLAYDIR/system/etc/permissions/anbox.xml"
fi

$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 $SUDO snap restart anbox.container-manager

安裝過程可能會出現失敗,請檢查網路,並確保安裝版本為最新。

失敗!!!

安裝成功!!!

這裡有商店了,繼續如下:

將services和store的許可權全部開啟!

然後,再使用adb安裝之前失敗的應用,發現全部成功了。

adb install Downloads/ROSAPPS/anki_cozmo_310.apk

這時候就可以使用任何手機上可以用的APP,愉快玩耍了。


具體安裝和配置流程如下(機器翻譯):

Anbox或Box中的Android是一個免費的開源工具,允許在Linux上執行Android應用程式。它的工作原理是在LXC容器中執行Android執行時環境,重新建立Android的目錄結構作為可安裝的迴圈映像,同時使用本機Linux核心來執行應用程式。

它的主要功能是安全性,效能,整合和融合(根據不同的外形尺寸),根據其網站。

使用Anbox,每個Android應用程式或遊戲都在一個單獨的視窗中啟動,就像系統應用程式一樣,它們的行為或多或少類似於常規視窗,顯示在啟動器中,可以平鋪等等。預設情況下,Anbox不發貨使用Google Play商店或支援ARM應用程式。要安裝應用程式,您必須下載每個應用APK並使用adb手動安裝。此外,安裝ARM應用程式或遊戲預設情況下不能使用Anbox - 嘗試安裝ARM應用程式會導致顯示以下錯誤:

Failed to install PACKAGE.NAME.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]

您可以在Box中手動為Android應用程式(通過libhoudini)設定Google Play商店和支援ARM應用程式,但這是一個非常複雜的過程。為了更容易在Anbox上安裝Google Play商店和Google Play服務,並讓它支援ARM應用程式和遊戲(使用libhoudini),geeks-r-us.de(連結文章是德語)的人建立了一個自動執行這些任務的指令碼。

在使用它之前,我想明確指出,即使在整合libhoudini用於ARM支援之後,並非所有Android應用程式和遊戲都能在Anbox中執行。某些Android應用程式和遊戲可能根本不會出現在Google Play商店中,而其他應用程式和遊戲可能無法安裝但無法使用。此外,某些應用程式可能無法使用某些功能。

安裝Google Play商店並在Anbox上啟用ARM應用程式/遊戲支援(Android in a Box)

如果您的Linux桌面上尚未安裝Anbox,這些說明顯然不起作用。如果您還沒有,請按照此處的安裝說明安裝Anbox 。此外,請確保anbox.appmgr在安裝Anbox之後和使用此指令碼之前至少執行一次,以避免遇到問題。另外,確保在執行下面的指令碼時Anbox沒有執行(我懷疑這是導致評論中提到的這個問題的原因)。

1.安裝所需要的依賴(wget,lzip,unzip和squashfs-tools)。

在Debian,Ubuntu或Linux Mint中,使用此命令安裝所需的依賴項:

sudo apt install wget lzip unzip squashfs-tools

2.下載並執行指令碼,在Box安裝中自動下載並安裝Android Play上的Google Play商店(和Google Play服務)和libhoudini(用於ARM應用/遊戲支援)。

警告:永遠不要在不知道它做什麼的情況下執行你沒寫過的指令碼。在執行此指令碼之前,請檢視其程式碼。 

要下載指令碼並使其可執行,請在終端中使用以下命令:

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

更新2018年11月29日:該install-playstore.sh指令碼會下載舊的open-gapps版本,因此,Google Play商店會在啟動後立即關閉。修復方法是修改指令碼以下載更新版本的open-gapps。您可以使用install-playstore.sh文字編輯器開啟指令碼,並將OPENGAPPS_RELEASEDATE值更改為更新的日期,您可以從此處獲取,或執行以下命令自動執行此操作(它將使用20181129日期):

sed -i 's/^OPENGAPPS_RELEASEDATE.*/OPENGAPPS_RELEASEDATE="20181129"/' install-playstore.sh

3.現在您可以執行指令碼:

sudo ./install-playstore.sh

4.要讓Google Play商店在Anbox中執行,您需要為Google Play商店和Google Play服務啟用所有許可權

為此,請執行Anbox:

anbox.appmgr

然後轉到Settings > Apps > Google Play Services > Permissions並啟用所有可用許可權。為Google Play商店做同樣的事情!

Anbox Google Play許可權

您現在應該可以使用Google帳戶登入Google Play商店。

如果未啟用Google Play商店和Google Play服務的所有許可權,則在嘗試登入Google帳戶時可能會遇到問題,並顯示以下錯誤訊息:“ 無法登入。與Google伺服器通訊時出現問題。請嘗試再次 “,你可以在這個截圖中看到:

Anbox與Google伺服器通訊時出現問題

登入後,您可以停用某些Google Play商店/ Google Play服務許可權。

如果您在Anbox上登入Google帳戶時遇到一些連線問題,請確保其anbox-bride.sh正在執行:

開始吧:
sudo /snap/anbox/current/bin/anbox-bridge.sh start

重啟它:
sudo /snap/anbox/current/bin/anbox-bridge.sh restart

根據該使用者的說法,如果繼續與Anbox存在連線問題,您可能還需要安裝dnsmasq軟體包。但是在我的Ubuntu 18.04桌面上不需要這樣做。


----

Fin

----

相關文章