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


当前回答

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

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

希望它能帮助你。

其他回答

在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列表包

我真的很喜欢这些答案。 大多数用于导出和重命名的脚本都是用Bash编写的。 我做了一个小Perl脚本,它可以做同样的事情(它应该在windows和linux的Perl中都可以工作,只在Ubuntu上测试)。

这使用ADB: https://developer.android.com/studio/command-line/adb

download-apk.pl

#!/usr/bin/perl -w
# Automatically export all available installed APK's using adb
use strict;
print "Connect your device...\n";
system("adb", "wait-for-device");
open(my $OUT, '-|', 'adb', 'shell', 'pm', 'list', 'package', '-f');
my $count = 0;
while(my $line = <$OUT>) {
        $line =~ s/^\s*|\s*$//g;
        my ($type, $path, $package) = $line =~ /^(.*?):(.*)=(.*)$/ ? ($1,$2,$3) : die('invalid line: '.$line);
        my $category = $path =~ /^\/(.*?)\// ? $1 : 'unknown';
        my $baseFile = $path =~ /\/([^\/]*)$/ ? $1 : die('Unknown basefile in path: '.$path);
        my $targetFile = "$category-$package.apk";
        print "$type $category $path $package $baseFile >> $targetFile\n";
        system("adb", "pull", $path);
        rename $baseFile, $targetFile;
}

确保adb(.exe)在您的路径或相同目录中 连接你的手机 运行download-apk.pl

输出类似于:

# ./download-apk.pl
Connect your device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
package system /system/app/YouTube/YouTube.apk com.google.android.youtube YouTube.apk >> system-com.google.android.youtube.apk
5054 KB/s (11149871 bytes in 2.154s)
package data /data/app/com.ghostsq.commander-1/base.apk com.ghostsq.commander base.apk >> data-com.ghostsq.commander.apk
3834 KB/s (1091570 bytes in 0.278s)
package data /data/app/de.blinkt.openvpn-2/base.apk de.blinkt.openvpn base.apk >> data-de.blinkt.openvpn.apk
5608 KB/s (16739178 bytes in 2.914s)
etc.

你可以这样做:

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文件,所有这些答案都需要多个步骤。1. 2.确定包名。找到文件,然后3。下载它。我构建了一个简单的apk_grabber python脚本,用于匹配给定正则表达式的任何应用程序,然后将这些apks反编译到jar文件中。

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