如何从android设备获取apk文件?或者如何将apk文件从设备传输到系统?
当前回答
在unix系统上,您可以尝试这个函数:
function android_pull_apk() {
if [ -z "$1" ]; then
echo "You must pass a package to this function!"
echo "Ex.: android_pull_apk \"com.android.contacts\""
return 1
fi
if [ -z "$(adb shell pm list packages | grep $1)" ]; then
echo "You are typed a invalid package!"
return 1
fi
apk_path="`adb shell pm path $1 | sed -e 's/package://g' | tr '\n' ' ' | tr -d '[:space:]'`"
apk_name="`adb shell basename ${apk_path} | tr '\n' ' ' | tr -d '[:space:]'`"
destination="$HOME/Documents/Android/APKs"
mkdir -p "$destination"
adb pull ${apk_path} ${destination}
echo -e "\nAPK saved in \"$destination/$apk_name\""
}
例如:android_pull_apk com.android.contacts 注意:识别包:adb shell pm列表包
其他回答
你可以这样做:
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/
还有另一个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\""
不需要Root和ADB工具的方法。 从游戏商店安装MyAppSharer应用程序。
适用于所有Android版本的一行代码:
adb shell 'cat `pm path com.example.name | cut -d':' -f2`' > app.apk
我得到了一个不存在的错误
我是这么做的
adb shell pm list packages -f | findstr zalo
package:/data/app/com.zing.zalo-1/base.apk=com.zing.zalo
adb shell
mido:/ $ cp /data/app/com.zing.zalo-1/base.apk /sdcard/zalo.apk
mido:/ $ exit
adb pull /sdcard/zalo.apk Desktop
/sdcard/zalo.apk: 1 file pulled. 7.7 MB/s (41895394 bytes in 5.200s)
推荐文章
- Android Studio, logcat在应用程序关闭后清理
- 在android中从上下文获取活动
- 无法解析主机"<URL here>"没有与主机名关联的地址
- getActivity()在Fragment函数中返回null
- 按钮背景是透明的
- 在Mac OS X上哪里安装Android SDK ?
- 我如何获得图像缩放功能?
- 在Android应用程序中显示当前时间和日期
- BottomSheetDialogFragment的圆角
- 在应用程序启动时出现“无法获得BatchedBridge,请确保您的bundle被正确打包”的错误
- 我如何改变默认对话框按钮的文本颜色在安卓5
- 更改单选按钮的圆圈颜色
- 如何在android中复制一个文件?
- adb找不到我的设备/手机(MacOS X)
- 如何在新的材质主题中改变背面箭头的颜色?