如何从android设备获取apk文件?或者如何将apk文件从设备传输到系统?


当前回答

还有另一个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\""

其他回答

适用于所有Android版本的一行代码:

adb shell 'cat `pm path com.example.name | cut -d':' -f2`' > app.apk

不需要Root和ADB工具的方法。 从游戏商店安装MyAppSharer应用程序。

你可以这样做:

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/

我没有使用代码从移动设备中提取。apk文件,但我一直在使用软件从移动设备中提取。apk文件,我使用的软件如下:谷歌播放链接:

ES文件管理器文件管理器 ASTRO云和文件管理器 3.软件数据线

希望它能帮助你。

这些建议对我都不起作用,因为Android在包名后面附加了一个序列号来生成最终的APK文件名。在最新版本的Android (Oreo和Pie)上,会追加一个不可预测的随机字符串。下面的命令序列是我在非root设备上使用的:

1)确定应用程序的包名。“com.example.someapp”。如果存在以下情况,请跳过此步骤 您已经知道包的名称。

adb shell pm list packages

查看包名列表,并尝试在有问题的应用程序和包名之间找到匹配项。这通常很简单,但请注意,包的名称可以与应用程序的名称完全无关。如果您无法从包名列表中识别该应用程序,请尝试使用浏览器在谷歌Play中找到该应用程序。谷歌Play中应用程序的URL包含包名。

2)获取所需包的APK文件的完整路径名称。

adb shell pm path com.example.someapp

输出看起来像这样 包:/数据/应用/ com.example.someapp apk——2. 或 包:/数据/ app / com.example.someapp-nfFSVxn_CTafgra3Fr_rXQ = = / base.apk

3)使用步骤2中的完整路径名称,将APK文件从Android设备拉到开发箱中。

adb pull /data/app/com.example.someapp-2.apk path/to/desired/destination