Вопрос

I'm trying to create a new java command-line utility based on java input command from AOSP: (https://github.com/android/platform_frameworks_base/tree/master/cmds/input)

I've compiled the jar using mmm and pushed it over to the android device over ADB. I then used ADB shell to execute the command:

export CLASSPATH = /sdcard/input2.jar
exec app_process / com.android.commands.input.Input

Using a rooted device, this work perfectly, But when I tried to run it on non-rooted device I got this exception on LOGCAT:

E/dalvikvm(31966): Dex cache directory isn't writable: /data/dalvik-cache
I/dalvikvm(31966): Unable to open or create cache for /sdcard/input2.jar (/data/dalvik-cache/sdcard@input2.jar@classes.dex)
E/appproc(31966): ERROR: could not find class 'com.android.commands.input.Input'

Any ideas?

Thanks

Это было полезно?

Решение

With the ADB shell, you can set the dalvik-cache directory to other directory with write permissions.

Try this before executing your module:

  • mkdir /data/local/tmp/dalvik-cache
  • export ANDROID_DATA=/data/local/tmp

Другие советы

Your new command isn't being managed by the Android package manager, which means the VM will try to create the /data/dalvik-cache entry when the command is first run. You need to be root to do that.

One option would be to have the command installed like a normal app, with a main activity that doesn't really do anything, and just execute your command-line entry point class from wherever the package manager chooses to install the jar file. This would also allow you to manage and uninstall the app from the settings UI.

(If you're just running it yourself, and not distributing it widely to others, then this post has the solution.)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top