如何从 Android 设备获取 apk 文件?

发布于 2024-09-29 12:32:47 字数 52 浏览 7 评论 0 原文

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

How do I get the apk file from an android device? Or how do I transfer the apk file from device to system?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(26

转瞬即逝 2024-10-06 12:32:48

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

  1. 确定应用程序的包名称,例如“com.example.someapp”。如果出现以下情况则跳过此步骤
    您已经知道包名称。
adb shell pm list packages

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

  1. 获取所需包的 APK 文件的完整路径名。

    adb shell pm 路径 com.example.someapp
    

输出将类似于
包:/data/app/com.example.someapp-2.apk

package:/data/app/com.example.someapp-nfFSVxn_CTafgra3Fr_rXQ==/base.apk

  1. 使用步骤 2 中的完整路径名,将 APK 文件从 Android 设备拉取到开发环境框。

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

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name. On more recent versions of Android (Oreo and Pie), an unpredictable random string is appended. The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. "com.example.someapp". Skip this step if
    you already know the package name.
adb shell pm list packages

Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

  1. Get the full path name of the APK file for the desired package.

    adb shell pm path com.example.someapp
    

The output will look something like
package:/data/app/com.example.someapp-2.apk
or
package:/data/app/com.example.someapp-nfFSVxn_CTafgra3Fr_rXQ==/base.apk

  1. Using the full path name from Step 2, pull the APK file from the Android device to the development box.

    adb pull /data/app/com.example.someapp-2.apk path/to/desired/destination
    
水中月 2024-10-06 12:32:48

使用 adb。当设备通过 USB 连接时,使用 adb pull 您可以将文件从设备复制到系统。

当然,您还需要正确的权限才能访问文件所在的目录。如果没有,您将需要先root设备。


如果您发现许多 APK 名为“base.apk”,您还可以使用这一行命令从您可以访问的手机中提取所有 APK,同时将任何“base.apk”名称重命名为软件包名称。这还修复了名称后带有看似随机字符的 APK 路径的目录未找到问题:

for i in $(adb shell pm list packages | awk -F':' '{print $2}'); do 
  adb pull "$(adb shell pm path $i | awk -F':' '{print $2}')"
  mv base.apk $i.apk &> /dev/null 
done

如果您收到“adb:错误:无法统计远程对象”,则表明您没有所需的权限。我在未root的Moto Z2上运行了这个程序,并且能够下载除youtube之外的所有我未卸载的APK(见下文)。

Use adb. With adb pull you can copy files from your device to your system, when the device is attached with USB.

Of course you also need the right permissions to access the directory your file is in. If not, you will need to root the device first.


If you find that many of the APKs are named "base.apk" you can also use this one line command to pull all the APKs off a phone you can access while renaming any "base.apk" names to the package name. This also fixes the directory not found issue for APK paths with seemingly random characters after the name:

for i in $(adb shell pm list packages | awk -F':' '{print $2}'); do 
  adb pull "$(adb shell pm path $i | awk -F':' '{print $2}')"
  mv base.apk $i.apk &> /dev/null 
done

If you get "adb: error: failed to stat remote object" that indicates you don't have the needed permissions. I ran this on a NON-rooted Moto Z2 and was able to download ALL the APKs I did not uninstall (see below) except youtube.

所有深爱都是秘密 2024-10-06 12:32:48

不需要root:

此代码将获取带有名称的第3方包路径,以便您可以轻松识别您的APK,

adb shell pm list packages -f -3

输出将是

包:/data/app/XX.XX.XX.apk=YY.YY.YY

现在使用以下代码提取该包:

adb pull /data/app/XX.XX.XX.apk

如果您在 C:>\ 中执行上述 cmd,那么您将在那里找到那个包。

No root is required:

This code will get 3rd party packages path with the name so you can easily identify your APK

adb shell pm list packages -f -3

the output will be

package:/data/app/XX.XX.XX.apk=YY.YY.YY

now pull that package using below code:

adb pull /data/app/XX.XX.XX.apk

if you executed above cmd in C:>\ , then you will find that package there.

独留℉清风醉 2024-10-06 12:32:48

将 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/

Steps to Download APK from Device to Desktop

A) Make sure that your running (emulator/real Device). To check use this command

adb devices

B) Select all the available package list installed in your device. You can use grep command to select the specific package you intend to download.

adb shell pm list packages
adb shell pm list packages -f -3

Output (List of available packages )

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) Copy the package (which you like to download) from the above link. Form our case I choose this (com.example.myapplication) package

Syntax : adb shell pm path [your_package_name]
Command: adb shell pm path com.example.myapplication

Output

package:/data/app/com.example.myapplication-nd1I4FGnTZnQ9PyRbPDHhw==/base.apk

D) Finally, To download APK from your (emulator/real device)

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

Example: Trying to pull this CertInstaller.apk file in your local machine ( Mac )

adb pull /system/app/CertInstaller/CertInstaller.apk /Users/$(whoami)/Documents/APK/download_apk/

E) Confirm in your local directory

ls -la /Users/$(whoami)/Documents/
白龙吟 2024-10-06 12:32:48

我见过很多解决这个问题的方法,要么你必须root你的手机,要么你必须安装一个应用程序。然后,经过多次谷歌搜索,我得到了这个针对未root/root手机的解决方案。

列出您到目前为止获得的应用程序。

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

之后,您所要做的就是提取 tar 内容就完成了。

希望它对你们有用

I've seen that many solutions to this problem either you have to root your phone or you have to install an app. Then after much googling I got this solution for non rooted/rooted phones.

To list which apps you got so far.

adb shell pm list packages

Then you may select an app, for instance twitter

adb backup -apk com.twitter.android

An important thing here is to not set up a password for encrypt your backup

This is going to create a file named as backup.ap, but you still can't open it. For this you got to extract it again but using the dd command.

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

After this all you have to do is to extract the tar content and it's done.

Hope it works for you guys

初见你 2024-10-06 12:32:48
C:\Users\xyz>adb shell pm list packages -f | findstr whatsapp
package:/data/app/com.whatsapp-1/base.apk=com.whatsapp

C:\Users\xyz>adb pull /data/app/com.whatsapp-1/base.apk Desktop
/data/app/com.whatsapp-1/base.apk: 1 f.... 13.8 MB/s (32803925 bytes in 
2.269s)
C:\Users\xyz>adb shell pm list packages -f | findstr whatsapp
package:/data/app/com.whatsapp-1/base.apk=com.whatsapp

C:\Users\xyz>adb pull /data/app/com.whatsapp-1/base.apk Desktop
/data/app/com.whatsapp-1/base.apk: 1 f.... 13.8 MB/s (32803925 bytes in 
2.269s)
尐籹人 2024-10-06 12:32:48

一款适用于所有 Android 版本的衬垫:

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

One liner which works for all Android versions:

adb shell 'cat `pm path com.example.name | cut -d':' -f2`' > app.apk
陌路黄昏 2024-10-06 12:32:48

在 2023 年 6 月,使用:

adb shell pm list packages --user 0

列出软件包名称,然后:

adb shell pm path your.package.name
adb pull /data/app/your/path/to/package/foo.apk

获取软件包。

In June of 2023, use:

adb shell pm list packages --user 0

to list the package names, then:

adb shell pm path your.package.name
adb pull /data/app/your/path/to/package/foo.apk

to get the package(s).

忘东忘西忘不掉你 2024-10-06 12:32:48

在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 列出软件包

On unix systems, you can try this function:

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\""
}
  • Example: android_pull_apk com.android.contacts
  • Note: To identify the package: adb shell pm list packages
骑趴 2024-10-06 12:32:48

尝试这个 liner 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 的脚本。我刚刚将所有 apk 重命名为其包名称,以解决 elcuco 的脚本,即相同的 base.apk 文件在 Android 6.0“Marshmallow”及更高版本上被覆盖。

请注意,此命令仅备份第 3 方应用程序,因为我不认为备份内置应用程序有什么意义。但如果您也想备份系统应用程序,只需省略 -3 选项即可。

Try this one liner bash command to backup all your apps:

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

This command is derived from Firelord's script. I just renamed all apks to their package names for solving the issue with elcuco's script, i.e the same base.apk file getting overwritten on Android 6.0 "Marshmallow" and above.

Note that this command backs up only 3rd party apps, coz I don't see the point of backing up built-in apps. But if you wanna backup system apps too, just omit the -3 option.

以为你会在 2024-10-06 12:32:48

完成@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”。修复起来应该是“微不足道”的。

Completing @Yojimbo 's answer, this is what I did (Linux/Mac only, will not work out of the box on Windows... maybe in git's 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

This is ugly bash, but works :)

EDIT:
It no longer works on AndroidM: all files are named "base.apk" under another dir. Should be "trivial" to fix.

ζ澈沫 2024-10-06 12:32:48

如上所述,您可以通过 adb 中的 pull 命令获取 apk。

既然您正在谈论已安装的应用程序,请继续查看 Android 文件系统的 /data/app 目录。您会在那里找到 APK。

然后使用adb命令 - adb pull /data/data/appname.apk

As said above, you can get the apk by using the pull command in adb.

Since, you are talking about your installed applications, go ahead and look in the /data/app directory of your Android filesystem. You will find the APK's there.

Then use the adb command - adb pull /data/data/appname.apk

╭⌒浅淡时光〆 2024-10-06 12:32:48
  1. 在手机上打开您想要从中提取 apk 的应用。

  2. 获取当前打开的应用程序:

    adb shell dumpsys 活动 活动 | grep mFocusedActivity
    
  3. 获取包名称的路径

    adb shell pm 路径 ;
    

4.将您获得的路径复制到 sdcard 目录

adb shell cp /data/app/<packagename.apk> /sdcard

5.拉出 apk

adb pull /sdcard/base.apk

编辑

如果第 2 步不起作用,请使用以下命令:

adb shell dumpsys window windows | grep mCurrentFocus
  1. Open the app you wish to extract the apk from on your phone.

  2. Get the currently opened app with:

    adb shell dumpsys activity activities | grep mFocusedActivity
    
  3. Get the path to the package name

    adb shell pm path <packagename.apk>
    

4.Copy the path you got to the sdcard directory

adb shell cp /data/app/<packagename.apk> /sdcard

5.Pull the apk

adb pull /sdcard/base.apk

Edit

If step no 2 doesn't work use this:

adb shell dumpsys window windows | grep mCurrentFocus
多情出卖 2024-10-06 12:32:48

如果您知道(或者您可以“猜测”).apk 的路径(似乎的格式为 /data/app/com. example.someapp-{1,2,..}.apk 到 ,然后您也可以从 /data/app 复制它,这甚至在我的非 root 上也有效。 只需使用普通的 Android 手机

即可(例如这个)并运行:

# step 1: confirm path
ls /data/app/com.example.someapp-1.apk
# if it doesn't show up, try -2, -3. Note that globbing (using *) doesn't work here.
# step 2: copy (make sure you adapt the path to match what you discovered above)
cp /data/app/com.example.someapp-1.apk /mnt/sdcard/

然后您可以将其从 SD 卡移动到您想要的任何位置(或将其附加到电子邮件等)。与 .apk 文件相关的内容。

If you know (or if you can "guess") the path to the .apk (it seems to be of the format /data/app/com.example.someapp-{1,2,..}.apk to , then you can just copy it from /data/app as well. This worked even on my non-rooted, stock Android phone.

Just use a Terminal Emulator app (such as this one) and run:

# step 1: confirm path
ls /data/app/com.example.someapp-1.apk
# if it doesn't show up, try -2, -3. Note that globbing (using *) doesn't work here.
# step 2: copy (make sure you adapt the path to match what you discovered above)
cp /data/app/com.example.someapp-1.apk /mnt/sdcard/

Then you can move it from the SD-card to wherever you want (or attach it to an email etc). The last bit might be technically optional, but it makes your life a lot easier when trying to do something with the .apk file.

筱武穆 2024-10-06 12:32:48

此处概述的过程不适用于 Android 7 (Nougat) [可能也适用于 Android 6,但我无法验证]。您无法直接在 Nougat 下提取 .apk 文件(除非在 root 模式下,但这需要 root 的手机)。但是,您可以使用 adb shell 将 .apk 复制到手机上的备用路径(例如 /sdcard/Download),然后您可以从备用路径执行 adb pull。

The procedures outlined here do not work for Android 7 (Nougat) [and possibly Android 6, but I'm unable to verify]. You can't pull the .apk files directly under Nougat (unless in root mode, but that requires a rooted phone). But, you can copy the .apk to an alternate path (say /sdcard/Download) on the phone using adb shell, then you can do an adb pull from the alternate path.

下壹個目標 2024-10-06 12:32:48

对于从设备检索的每个 apk 文件,所有这些答案都需要多个步骤。 1. 确定包名称,2. 找到文件,3. 下载。我构建了一个简单的 apk_grabber python 脚本 来为任何与给定正则表达式,然后将这些 apk 反编译成 jar 文件。

All these answers require multiple steps for each apk file retrieved from the device. 1. determine package name, 2. find the file, and 3. download it. I built a simple apk_grabber python script to do this for any app that matches a given regex, and then decompiles those apks into jar files.

妄司 2024-10-06 12:32:48

操作方法如下:

在您的设备中下载并安装 APK Extractor。它是免费的,并且兼容几乎所有 Android 设备。另一个优点是它甚至不需要 root 或任何东西就可以工作。
安装后,启动它。在那里,您将看到设备中的应用程序列表,其中包括您稍后安装的应用程序以及系统应用程序。长按您想要提取的任何应用程序(您可以一次选择多个或所有应用程序),然后单击顶部看到的提取选项。您还可以选择通过蓝牙或消息传递进行共享。
完成后,您将看到提取的应用程序为 AppName_AppPackage_AppVersionName_AppVersionCode.apk,默认保存在路径 /sdcard/ExtractedApks/ 中。

有关如何在android中提取apk文件的详细说明,访问:http://appslova.com/how-to-extract- apk-files-in-android/

Here's how you do it:

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.

For detailed description for how to extract apk files in android, visit: http://appslova.com/how-to-extract-apk-files-in-android/

尽揽少女心 2024-10-06 12:32:48

我收到不存在错误

这是我如何让它工作的

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)

I got a does not exist error

Here is how I make it works

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)
晨光如昨 2024-10-06 12:32:48

我没有使用代码从手机中提取 .apk 文件,但我一直在使用软件从手机中提取 .apk 文件,我使用的软件在下面带有 google play 链接:

  1. ES File Explorer 文件管理器
  2. ASTRO 云 &文件管理器
    3.软件数据线

希望可以帮助你。

I haven't used code to pull .apk file from mobile but i have been using software to extract .apk file from mobile and software i have used are below with google play link:

  1. ES File Explorer File Manager
  2. ASTRO Cloud & File Manager
    3.Software Data Cable

Hope it helps You.

一江春梦 2024-10-06 12:32:48

无需 Root 且无需 ADB 工具的方法。
安装MyAppSharer 应用程序。

No Root and no ADB tools required method.
Install MyAppSharer app from the play store.

叹沉浮 2024-10-06 12:32:48

我真的很喜欢所有这些答案。
大多数导出和重命名的脚本都是用 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;
}
  1. 确保 adb(.exe) 在您的路径或同一目录中
  2. 连接您的手机
  3. 运行 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.

I really liked all these answers.
Most scripts to export and rename all of them were written in Bash.
I made a small Perl script which does the same (which should work both in Perl for windows and linux, only tested on Ubuntu).

This uses 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;
}
  1. Make sure adb(.exe) is in your path or same directory
  2. Connect your phone
  3. Run download-apk.pl

The output is something similar to:

# ./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.
梦一生花开无言 2024-10-06 12:32:48

想要非常非常舒适的 1 分钟解决方案吗?

只有您这个应用 https://play.google.com/ store/apps/details?id=com.cvinfo.filemanager(来自 Google Play 的智能文件管理器)。

点击“应用程序”,选择一个并点击“备份”。它将最终出现在您的文件系统中的 app_backup 文件夹中;)

wanna very, very comfortable 1 minute solution?

just you this app https://play.google.com/store/apps/details?id=com.cvinfo.filemanager (smart file manager from google play).

tap "apps", choose one and tap "backup". it will end up on your file system in app_backup folder ;)

屌丝范 2024-10-06 12:32:48

另一个 bash 脚本(即适用于大多数基于 UNIX 的系统)。基于Pedro Rodrigues 的答案,但稍微更容易使用。

对 Pedro 版本的改进:

  1. 原始方法在 Android 7 上对我不起作用:adb pull 一直抱怨 没有这样的文件或目录,而 adb shell可以访问该文件。因此我使用了不同的方法,使用临时文件。
  2. 当不带参数启动时,我的脚本将仅列出所有可用的包。当提供部分包名称时,它将尝试猜测完整的包名称。如果有多个可能的扩展,它会抱怨。
  3. 我没有硬编码目标路径;相反,APK 会保存到当前工作目录。

将其保存到可执行文件:

#!/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\""

Yet another bash script (i.e. will work for most unix-based systems). Based on the answer by Pedro Rodrigues, but is slightly easier to use.

Improvements over Pedro's version:

  1. 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.
  2. 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.
  3. I don't hardcode destination path; instead APKs are saved to current working directory.

Save this to an executable file:

#!/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\""
青衫负雪 2024-10-06 12:32:48

就我个人而言,使用非 root 设备 Samsung Android 13 我更喜欢名为“Apk Extractor”,因为应用程序的使用是一键操作,您将在内部存储 -> 中提取 APK 文件。下载-> apk-> your_apk.apk

Personally, using the non-rooted device Samsung Android 13 I prefer the open-source 3rd party application named "Apk Extractor" from F-Droid as the application's usage is a one-click action and you would have extracted the APK file in the Internal storage -> Downloads -> apk -> your_apk.apk

怎会甘心 2024-10-06 12:32:48

这将对正在寻找非技术性答案的人有所帮助

这是简单的黑客

从 Google Play 商店下载应用程序App Share/Send Pro 。选择您要发送的应用程序和发送应用程序的方法。

我通常使用蓝牙将应用程序发送到我的电脑或其他手机。

This will help for someone who is looking for a non technical answer

This is simple hack

Download the application App Share/Send Pro from google play store. Select the app you want to send and method send application.

I usually use Bluetooth to send applications to my pc or another phone.

夏日落 2024-10-06 12:32:48

最简单的一种是:
在手机上安装“ShareIt”应用程序。
现在在电脑或其他手机上安装 shareIt 应用程序。
现在,从安装了该应用程序的手机上,打开 ShareIt 并发送。
在其他手机或电脑上,打开 ShareIt 并接收。

Simplest one is:
Install "ShareIt" app on phone.
Now install shareIt app in PC or other phone.
Now from the phone, where the app is installed, open ShareIt and send.
On other phone or PC, open ShareIt and receive.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文