简体   繁体   English

怎么运行apk应用程序没有安装(本机)

[英]How run apk application without installing(native)

Is there any way to run an apk without installing? 有没有办法在没有安装的情况下运行apk? Just like in windows running an exe. 就像在运行exe的Windows中一样。 Does being a native apk change anything in relation to this? 作为本机apk是否会改变与此相关的任何内容?

Short answer is: 简短的回答是:

You can't. 你不能。

Long answer(TL;DR): 答案很长(TL; DR):

If compared to Windows's .exe file, which is binary, and can be executed , .apk is not a binary, and can't be executed . 如果与Windows的.exe文件( 二进制文件)进行比较,并且可以执行 ,则.apk 不是二进制文件,也不能执行 .apk in fact is a zip archive, just named with .apk instead of .zip . .apk实际上是一个zip存档,只用.apk而不是.zip命名。
For Android .apk is an application package, which has the executable code + resources + assets + whatever else it needs. 对于Android .apk是一个应用程序包,它具有可执行代码+资源+资产+其他任何需要的东西。 This means that the .apk file is not being run itself. 这意味着.apk文件本身没有运行。

How it works (simplified): 工作原理(简化):
When you start an application on Android, system extracts .apk file, opens the manifest file, finds a launcher activity you have selected to start, and executes it's Activity.class code on the Java VM. 当您在Android上启动应用程序时,系统会提取.apk文件,打开manifest文件,找到您选择启动的启动器活动,并在Java VM上执行它的Activity.class代码。

So in fact you can do that having root access by manually extracting APK, starting a virtual machine and running .class code in it, but IMHO it is not worth to do. 所以实际上你可以通过手动提取APK,启动虚拟机并在其中运行.class代码来实现root访问权限,但恕我直言,这是不值得的。

What you can run is most part of arm compiled Linux binaries. 可以运行的是arm编译的Linux二进制文件的大部分内容。 If they don't require access to the system-owned files, or other data, or you have root access on your device, you can use arm binaries. 如果他们不需要访问系统拥有的文件或其他数据,或者您的设备上具有root访问权限,则可以使用arm二进制文件。 But you still need some APK installed to run them. 但是你仍然需要安装一些APK来运行它们。


Note that the answer is simplified for easier understanding, and in fact everything is more complicated with APKs, Java VM, etc. 请注意,答案是简化的,以便于理解,事实上,APK,Java VM等等一切都更复杂。

During apk installation (even via adb), managed by the android Package Manager on the device, various processes are executed such as: 在apk安装期间(甚至通过adb),由设备上的android Package Manager管理,执行各种过程,例如:

  • Determine the appropriate location of the package installation 确定软件包安装的适当位置
  • Copying a copy of the apk file to a given directory (usually /data/app/) 将apk文件的副本复制到给定目录(通常是/ data / app /)
  • Create the application directory and set permissions to store database and shared preference, native library (usually /data/data//) 创建应用程序目录并设置存储数据库和共享首选项的权限,本机库(通常是/ data / data //)
  • Extraction of dex code to the cache directory 将dex代码提取到缓存目录

There is no way an apk can run on an android device if it's resources and configuration are not on the same device. 如果它的资源和配置不在同一设备上,则apk无法在Android设备上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM