前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Anbox安装apk失败(提示Failure res=-113等)的解决方法

Anbox安装apk失败(提示Failure res=-113等)的解决方法

作者头像
zhangrelay
发布2019-01-31 15:59:48
7.6K0
发布2019-01-31 15:59:48
举报

详细描述,如下(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,如下。

代码语言:javascript
复制
#!/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

----

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年12月06日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 具体现象:
  • 解决方案:
相关产品与服务
机器翻译
机器翻译(Tencent Machine Translation,TMT)结合了神经机器翻译和统计机器翻译的优点,从大规模双语语料库自动学习翻译知识,实现从源语言文本到目标语言文本的自动翻译,目前可支持十余种语言的互译。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档