2010-06-04 80 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

相關問題