2010-06-04 78 views
7

我试图让HelloWebView样品和运行(如,没有cuustomizations)在HelloWebView样品:java.lang.SecurityException异常:权限拒绝

http://developer.android.com/resources/tutorials/views/hello-webview.html

我继续得到爪哇发现。 lang.SecurityException:尽管做了所有努力,权限被拒绝。在我看来,这是我的一些基本缺乏理解(我是一个新手),或者对我的开发环境(Windows XP)来说可能是本地的。

我在下面包含了我的main.xml,AndroidManifest.xml和控制台输出。

事情试过至今:

  • 不同的API(6,7)
  • 添加/验证(我认为:))说: “使用许可权的android:name =” android.permission.INTERNET对” “ 在我的清单中有正确的语法和位置。
  • 擦模拟器
  • 。重新启动Eclipse,笔记本电脑等
  • 禁用我的互联网安全

任何帮助将不胜感激。

谢谢。 添

我的主要XML是:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
<WebView 
    android:id="@+id/webview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"/> 
</LinearLayout> 

我的清单文件是:

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

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <activity android:name=".HelloWebView" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".HelloWebView" android:label="@string/app_name" 
android:theme="@android:style/Theme.NoTitleBar"> 
    </activity> 

</application> 

实际控制台输出:

 
------------------------------ 
[2010-06-04 07:57:06 - HelloWebView] Android Launch! 
[2010-06-04 07:57:06 - HelloWebView] adb is running normally. 
[2010-06-04 07:57:06 - HelloWebView] Performing com.example.hellowebview.HelloWebView activity launch 
[2010-06-04 07:57:06 - HelloWebView] Automatic Target Mode: launching new emulator with compatible AVD 'AndroidGM2.1' 
[2010-06-04 07:57:06 - HelloWebView] Launching a new emulator with Virtual Device 'AndroidGM2.1' 
[2010-06-04 07:57:08 - HelloWebView] New emulator found: emulator-5554 
[2010-06-04 07:57:08 - HelloWebView] Waiting for HOME ('android.process.acore') to be launched... 
[2010-06-04 07:57:34 - HelloWebView] WARNING: Application does not specify an API level requirement! 
[2010-06-04 07:57:34 - HelloWebView] Device API version is 7 (Android 2.1) 
[2010-06-04 07:57:34 - HelloWebView] HOME is up on device 'emulator-5554' 
[2010-06-04 07:57:34 - HelloWebView] Uploading HelloWebView.apk onto device 'emulator-5554' 
[2010-06-04 07:57:35 - HelloWebView] Installing HelloWebView.apk... 
[2010-06-04 07:57:46 - HelloWebView] Success! 
[2010-06-04 07:57:47 - HelloWebView] Starting activity com.example.hellowebview.HelloWebView on device 
[2010-06-04 07:57:55 - HelloWebView] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellowebview/.HelloWebView } 
[2010-06-04 07:57:55 - HelloWebView] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.hellowebview/.HelloWebView } from null (pid=-1, uid=-1) requires null 

回答

0

添你好,这会异常有关API版本,例如我用的是Android 1.5,所以我添加到我的AndroidManifest.xml文件

<uses-sdk android:minSdkVersion="3" /> 

检查您的消息输出...

[2010-06-04 07:57:34 - HelloWebView] WARNING: Application does not specify an API level requirement! 
[2010-06-04 07:57:34 - HelloWebView] Device API version is 7 (Android 2.1) 

我已经意识到问题在于你已经在你的Manifest.xml中定义了两个活动(HelloWebView),你必须删除其中的一个。

<activity android:name=".HelloWebView" 
+0

我更新了minSdkVersion,但仍然有同样的问题。我决定退出最近的SDK,并尝试版本3接地。 使用版本3我仍然无法运行应用程序,现在得到以下控制台输出: [2010-06-05 08:45:23 - HelloWebView3] ActivityManager:启动:Intent {action = android.intent.action .MAIN categories = {android.intent.category.LAUNCHER} comp = {com.example.hellowebview3/com.example.hellowebview3.HelloWebView3}} [2010-06-05 08:45:23 - HelloWebView3] ActivityManager:[1 ]已经开始杀了-n com .... – 2010-06-05 13:02:56

43

您的清单文件中有两个条目用于HelloWebView活动。尝试删除第二个。

+1

这对我有效。 – 2011-05-18 18:26:51

+1

@Jack BeNimble:怎么样接受这个答案;) – anticafe 2011-07-04 08:38:53

+1

答案必须被@广角接受。 – 2011-10-13 17:41:53

相关问题