HelloWebView示例:java.lang.SecurityException:Permission Denial

wid*_*gle 7 permissions android

我正在尝试启动和运行HelloWebView示例(因为没有自定义)

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

我继续得到java.lang.SecurityException:Permission Denial尽管付出了很多努力.在我看来,我必须对我的一些基本缺乏理解(我是新手)或者我的开发环境(Windows XP)可能是本地的.

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

迄今为止尝试的事情:

  • 不同的api(6,7)
  • 添加/验证(我认为:))"uses-permission android:name ="android.permission.INTERNET""在我的清单中具有正确的语法和位置.
  • 擦拭模拟器
  • 重启日食,笔记本电脑等
  • 禁用我的互联网安全

任何帮助将不胜感激.

谢谢.蒂姆

我的主要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> 
Run Code Online (Sandbox Code Playgroud)

我的清单文件是:

<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>
Run Code Online (Sandbox Code Playgroud)

实际控制台输出:

 ------------------------------
[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

Cor*_*old 43

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


Jor*_*sys 0

嗨,蒂姆,这个异常与 API 版本有关,例如我使用 Android 1.5,所以我添加到我的 AndroidManifest.xml 文件

<uses-sdk android:minSdkVersion="3" />
Run Code Online (Sandbox Code Playgroud)

检查您的消息输出...

[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)
Run Code Online (Sandbox Code Playgroud)

我意识到问题是您在Manifest.xml中定义了两个活动(HelloWebView) ,您必须删除其中之一。

  <activity android:name=".HelloWebView"
Run Code Online (Sandbox Code Playgroud)