你好WebView示例:java.lang.SecurityException:拒绝权限

7

我正在尝试运行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"”在我的清单中具有正确的语法和位置。 - 清除模拟器 - 重新启动eclipse、笔记本电脑等 - 禁用我的互联网安全
非常感谢您提供任何帮助。
谢谢。 Tim
我的主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启动!
[2010-06-04 07:57:06 - HelloWebView] adb正常运行。
[2010-06-04 07:57:06 - HelloWebView] 执行com.example.hellowebview.HelloWebView活动启动。
[2010-06-04 07:57:06 - HelloWebView] 自动目标模式:使用兼容AVD“AndroidGM2.1”启动新仿真器。
[2010-06-04 07:57:06 - HelloWebView] 使用虚拟设备“AndroidGM2.1”启动新仿真器。
[2010-06-04 07:57:08 - HelloWebView] 发现新的仿真器:emulator-5554
[2010-06-04 07:57:08 - HelloWebView] 等待HOME('android.process.acore')启动...
[2010-06-04 07:57:34 - HelloWebView] 警告:应用程序未指定API级别要求!
[2010-06-04 07:57:34 - HelloWebView] 设备API版本为7(Android 2.1)
[2010-06-04 07:57:34 - HelloWebView] HOME已在设备'emulator-5554'上启动
[2010-06-04 07:57:34 - HelloWebView] 正在将HelloWebView.apk上传到设备'emulator-5554'
[2010-06-04 07:57:35 - HelloWebView] 正在安装HelloWebView.apk...
[2010-06-04 07:57:46 - HelloWebView] 成功!
[2010-06-04 07:57:47 - HelloWebView] 在设备上启动com.example.hellowebview.HelloWebView活动
[2010-06-04 07:57:55 - HelloWebView] ActivityManager:正在启动: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:权限拒绝:从null(pid = -1,uid = -1)需要null启动Intent { act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] flg = 0x10000000 cmp = com.example.hellowebview / .HelloWebView }
2个回答

43

你的清单文件中针对 HelloWebView 活动存在两个条目。尝试移除第二个条目。


0

嗨,Tim,这个异常与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"

我更新了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] Killed am start -n com.... - wide-angle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接