Dalvikvm运行与舱单用户许可的jar文件 [英] Dalvikvm to run jar files with Manifest user permission

查看:146
本文介绍了Dalvikvm运行与舱单用户许可的jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想移植到了Android平台的一个非常简单的命令行Java应用程序。什么应用程序确实是访问互联网上的网页,并通过打印的System.out.println一些输出。

I have a very simple command line Java application that I wish to port to the Android platform. What the application does is to access a webpage on the Internet and print some output via System.out.println.

的http:// davanum.word press.com / 2007/12/04 /命令行-java的上dalvikvm / 的,我知道我可以将我的Java应用程序的jar文件到Android DEX格式,并随后到Android然后可以使用dalvikvm运行jar文件。

From http://davanum.wordpress.com/2007/12/04/command-line-java-on-dalvikvm/, I realise that I can convert my Java application's jar file to Android dex format and subsequently to Android jar file which can then be run using dalvikvm.

不过,我做到了这一点,并已成功执行了我的Andr​​oid手机上的程序后,我得到了以下错误:

However, after I've done that and have successfully executed the program on my Android phone, I got the following error:

java.net.SocketException: Permission denied

我估计一定是由于应用程序无权限访问互联网,作为一个典型的Andr​​oid APK应用程序将含有可以指定权限,如AndroidManifest.xml文件:

I reckoned it must be due to the application having no permission to access the Internet, as a typical Android apk application would contain a AndroidManifest.xml file which can specify permissions such as:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

所以我在这里,寻找我是否能避免不知何故指定我通过dalvikvm准备了android jar文件或在执行过程中所需要的网络访问权限的地方?建立一个全面的APK应用程序的答案

So here I am, seeking answers on whether I can avoid building a full-fledged apk application by somehow specifying that I need the internet access permission somewhere during the process of getting ready the android jar file or at execution via dalvikvm?

推荐答案

我认为这个问题是默认的shell用户(这是你是什么,如果你正在运行亚行外壳)可能没有INTERNET权限。因为我不认为有一个简单的方法来权限添加到命令行我不知道你能做到这一点在所有的用户。

I think the issue is that the default shell user (which is what you are if you are running adb shell) may not have INTERNET permission. Since I don't think there's a simple way to add permissions to a user on the command line I'm not sure you'll be able to do this at all.

这篇关于Dalvikvm运行与舱单用户许可的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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