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


当前回答

我已经见过很多解决这个问题的方法,要么你必须在你的手机上安装根程序,要么你必须安装一个应用程序。然后在谷歌搜索了很多之后,我找到了这个解决方案,适用于非根/根手机。

列出你目前获得的应用程序。

adb shell pm list packages

然后你可以选择一个应用程序,比如twitter

adb backup -apk com.twitter.android

这里很重要的一点是不要为加密备份设置密码

这将创建一个名为backup的文件。Ap,但你还是打不开。为此,您必须再次提取它,但使用dd命令。

dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar

在此之后,你所要做的就是提取焦油含量,这就完成了。

希望这对你们有用

其他回答

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

完成@Yojimbo的回答,这是我所做的(只适用于Linux/Mac,不会在Windows上开箱工作……可能在git的bash shell中):

for i in $(adb shell pm list packages -f -3 | cut -d= -f 1 | cut -d ":" -f 2); do adb pull $i; done

这是一个丑陋的bash,但工作:)

编辑: 它不再适用于AndroidM:所有文件都命名为“base.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/

试试这个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选项。

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

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

希望它能帮助你。