如何通过.apk传递dalvik命令行参数? [英] How to pass dalvik command line parameters through .apk?

查看:163
本文介绍了如何通过.apk传递dalvik命令行参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以通过以下方式在Android中启动java程序:

I know that it is possible to launch java program in Android in a such way:

adb push "hello_world.zip" $REMOTE_PATH/
adb shell mkdir $REMOTE_PATH/dalvik-cache
adb shell dalvikvm -cp "$REMOTE_PATH/hello_world.zip" -Xint:portable -Xdexopt:none -Xverify:none hello_world

非常好!

但现在我想要创建Android .apk文件。我希望这个应用程序能够使用相同的命令行参数 - Xint:portable -Xdexopt:none -Xverify:none自动启动。

But now I want to create Android .apk file. And I want this application to be launched with the same command line parameters "-Xint:portable -Xdexopt:none -Xverify:none" automatically.

我假设参数名称可能不同于此 - Xint:portable -Xdexopt:none -Xverify:none,但功能必须相同。我不知道我要做什么,谷歌不想帮我解决这个问题。
我们非常感谢任何帮助!

I assume that parameters names may differ from this "-Xint:portable -Xdexopt:none -Xverify:none", but functionality must be the same. I have no idea what I have to do and google doesn't want to help me to solve this issue. Any help would be much appreciated!

推荐答案

我有理由相信你不能。您可以使用 setprop dalvik.vm.execution-mode int:portable 更改系统范围的解释器模式,但您需要root。我不知道有什么方法可以为您的进程禁用 dexopt (这会带来安全风险!)。你肯定无法触及bootclasspath(这是你的app最初运行的类路径)。

I'm reasonably certain that you can't. You can change the system-wide interpreter mode with setprop dalvik.vm.execution-mode int:portable but you would need root. I don't know of any way to disable dexopt for your process only (that would be a security risk!). You most certainly can't touch the bootclasspath (which is the classpath that your app initially runs under).

我相信你可以为你的流程禁用 jnicheck ,但就是这样。

I believe you can disable jnicheck for your process but that's about it.

设备上的应用程序通过 app_process 和zygote运行,您可以将它们视为Dalvik周围的限制包装器。除了最初的zygote之外没有 dalvikvm 调用 - 每个未来的进程都以 fork()开头,所以你如果不弄乱合子,就无法真正改变这些参数。 (我正在简化,但我很确定我是对的)

Apps on the device run via app_process and the zygote, you can think of them as restricted wrappers around Dalvik. There are no dalvikvm invocations apart from the initial zygote one - every future process starts with a fork(), so you can't actually change those parameters without messing with the zygote. (I'm simplifying but I'm pretty sure I'm right)

这篇关于如何通过.apk传递dalvik命令行参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆