如何从android设备获取apk文件?或者如何将apk文件从设备传输到系统?
当前回答
这里列出的程序不适用于Android 7 (Nougat)[可能也不适用于Android 6,但我无法验证]。你不能直接在Nougat下拉。apk文件(除非在根模式下,但这需要一个根手机)。但是,您可以使用adb shell将.apk复制到电话上的备用路径(例如/sdcard/Download),然后您可以从备用路径进行adb拉取。
其他回答
APK从设备下载到桌面的步骤
A)确保您的运行(模拟器/真实设备)。使用该命令检查
adb devices
B)选择设备中安装的所有可用软件包列表。可以使用grep命令选择要下载的软件包。
adb shell pm list packages
adb shell pm list packages -f -3
输出(可用包的列表)
package:/data/app/com.example.mytestapplication-sOzKi5USzfbYLPNDmaaK6g==/base.apk=com.example.mytestapplication
package:/data/app/com.example.myapplication-nd1I4FGnTZnQ9PyRbPDHhw==/base.apk=com.example.myapplication
C)从上面的链接复制包(你喜欢下载的)。在我们的案例中,我选择这个(com.example.myapplication)包
Syntax : adb shell pm path [your_package_name]
Command: adb shell pm path com.example.myapplication
输出
package:/data/app/com.example.myapplication-nd1I4FGnTZnQ9PyRbPDHhw==/base.apk
D)最后,从您的(模拟器/真实设备)下载APK
Syntax : adb pull /data/app/[your_package_name]-1/base.apk [your_destination_path]
Command: adb pull /data/app/com.example.myapplication-3j4CVk0Tb2gysElgjz5O6A==/base.apk /Users/$(whoami)/Documents/your_apk.apk
示例:试图将CertInstaller.apk文件拉到本地机器(Mac)
adb pull /system/app/CertInstaller/CertInstaller.apk /Users/$(whoami)/Documents/APK/download_apk/
E)在您的本地目录中确认
ls -la /Users/$(whoami)/Documents/
还有另一个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\""
试试这个bash命令来备份你所有的应用程序:
for package in $(adb shell pm list packages -3 | tr -d '\r' | sed 's/package://g'); do apk=$(adb shell pm path $package | tr -d '\r' | sed 's/package://g'); echo "Pulling $apk"; adb pull -p $apk "$package".apk; done
这个命令来自于Firelord的脚本。我只是将所有apks重命名为它们的包名,以解决elcuco的脚本问题,即相同的base.apk文件被覆盖在Android 6.0“棉花糖”及以上。
注意,这个命令只备份第三方应用,因为我不认为备份内置应用有什么意义。但如果你也想备份系统应用程序,只需省略-3选项。
适用于所有Android版本的一行代码:
adb shell 'cat `pm path com.example.name | cut -d':' -f2`' > app.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 Studio, logcat在应用程序关闭后清理
- 在android中从上下文获取活动
- 无法解析主机"<URL here>"没有与主机名关联的地址
- getActivity()在Fragment函数中返回null
- 按钮背景是透明的
- 在Mac OS X上哪里安装Android SDK ?
- 我如何获得图像缩放功能?
- 在Android应用程序中显示当前时间和日期
- BottomSheetDialogFragment的圆角
- 在应用程序启动时出现“无法获得BatchedBridge,请确保您的bundle被正确打包”的错误
- 我如何改变默认对话框按钮的文本颜色在安卓5
- 更改单选按钮的圆圈颜色
- 如何在android中复制一个文件?
- adb找不到我的设备/手机(MacOS X)
- 如何在新的材质主题中改变背面箭头的颜色?