如何从android设备获取apk文件?或者如何将apk文件从设备传输到系统?
当前回答
你可以这样做:
Download and install APK Extractor in your device. It is free, and is compatible in almost all of the Android devices. Another plus point is it does not even require root or anything to work. After you have it installed, launch it. There you will see a list of apps which are in your device, which include the apps you’ve installed later, along with the system apps. Long press any app you want to extract (you can select multiple or all apps at once), and click on the extract option you see in the top. You will also have the option to share via Bluetooth or messaging. You’re done, you will see the extracted apps as AppName_AppPackage_AppVersionName_AppVersionCode.apk, which will be saved in the path /sdcard/ExtractedApks/ by default.
android中如何提取apk文件的详细说明,请访问:http://appslova.com/how-to-extract-apk-files-in-android/
其他回答
这里列出的程序不适用于Android 7 (Nougat)[可能也不适用于Android 6,但我无法验证]。你不能直接在Nougat下拉。apk文件(除非在根模式下,但这需要一个根手机)。但是,您可以使用adb shell将.apk复制到电话上的备用路径(例如/sdcard/Download),然后您可以从备用路径进行adb拉取。
适用于所有Android版本的一行代码:
adb shell 'cat `pm path com.example.name | cut -d':' -f2`' > app.apk
最简单的是: 在手机上安装“ShareIt”应用。 现在在PC或其他手机上安装shareIt应用程序。 现在,在安装了应用程序的手机上,打开ShareIt并发送。 在其他手机或电脑上打开ShareIt并接收。
还有另一个bash脚本(即可以用于大多数基于unix的系统)。基于佩德罗·罗德里格斯的回答,但更容易使用。
对佩德罗版本的改进:
Original approach did not work for me on Android 7: adb pull kept complaining about no such file or directory while adb shell could access the file. Hence I used different approach, with temporary file. When launched with no arguments, my script will just list all available packages. When partial package name is provided, it will try to guess the full package name. It will complain if there are several possible expansions. I don't hardcode destination path; instead APKs are saved to current working directory.
保存到一个可执行文件:
#!/bin/bash
# Obtain APK file for given package from the device connected over ADB
if [ -z "$1" ]; then
echo "Available packages: "
adb shell pm list packages | sed 's/^package://'
echo "You must pass a package to this function!"
echo "Ex.: android_pull_apk \"com.android.contacts\""
exit 1
fi
fullname=$(adb shell pm list packages | sed 's/^package://' | grep $1)
if [ -z "$fullname" ]; then
echo "Could not find package matching $1"
exit 1
fi
if [ $(echo "$fullname" | wc -l) -ne 1 ]; then
echo "Too many packages matched:"
echo "$fullname"
exit 1
fi
echo "Will fetch APK for package $fullname"
apk_path="`adb shell pm path $fullname | sed -e 's/package://g' | tr '\n' ' ' | tr -d '[:space:]'`"
apk_name="`basename ${apk_path} | tr '\n' ' ' | tr -d '[:space:]'`"
destination="${fullname}.apk"
tmp=$(mktemp --dry-run --tmpdir=/sdcard --suffix=.apk)
adb shell cp "${apk_path}" "$tmp"
adb pull "$tmp" "$destination"
adb shell rm "$tmp"
[ $? -eq 0 ] && echo -e "\nAPK saved in \"$destination\""
使用亚行。当设备连接USB时,adb可以将文件从设备复制到系统中。
当然,您还需要正确的权限来访问文件所在的目录。如果没有,则需要先对设备进行根操作。
如果您发现许多apk命名为“base.apk”,您还可以使用这一行命令从您可以访问的电话中提取所有apk,同时将任何“base.apk”名称重命名为包名。这也修复了名称后看似随机字符的APK路径找不到目录的问题:
for i in $(adb shell pm list packages | awk -F':' '{print $2}'); do
adb pull "$(adb shell pm path $i | awk -F':' '{print $2}')"
mv base.apk $i.apk &> /dev/null
done
如果你得到“adb: error: failed to stat remote object”,这表明你没有所需的权限。我在一台非根Moto Z2上运行了这个程序,并且能够下载所有我没有卸载的apk(见下文),除了youtube。
adb shell pm uninstall --user 0 com.android.cellbroadcastreceiver <--- kills presidential alert app!
(查看用户运行adb shell PM列表用户) 这是一种删除/卸载(不是从手机出厂复位)几乎任何没有根的应用程序,包括系统应用程序(提示,烦人的更新应用程序更新你的电话线它或不可以通过grepping“ccc”找到)
推荐文章
- ImageView -有高度匹配宽度?
- 如何确定在android文件的MIME类型?
- 这是在Android中获取用户位置的好方法
- Android从左到右幻灯片动画
- 如何检索视图的维度?
- 如何改变菜单项的文本颜色在安卓?
- Android选择器和文本颜色
- 视图绑定-我如何获得包含布局的绑定?
- 在Android Studio中改变矢量资产的填充颜色
- 在构建中编写注释的语法是什么?gradle文件?
- 如何以编程方式添加按钮色调
- 用Android Studio进行调试永远停留在“等待调试器”状态
- Openssl不被视为内部或外部命令
- 无法执行dex:在Eclipse中超过GC开销限制
- 如何以编程方式将视图添加到视图