2012-07-03 75 views
0

我按照此Phonegap guide。當我運行我自己的android應用程序時,它什麼也不顯示,只是空白頁面。爲什麼它顯示空白頁?
我使用的科爾多瓦 - 1.8.1爲什麼我的phonegap android顯示黑色空白頁?

這裏是我的android活動:

package report.weeklyflash; 

import android.os.Bundle; 
import org.apache.cordova.*; 

public class MenuPhonegap extends DroidGap { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     super.loadUrl("file:///android_asset/www/index.html"); 
    } 
} 

這裏是我的index.html

<!DOCTYPE HTML> 
<html> 

    <head> 
     <title>PhoneGap</title> 
     <script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script> 
    </head> 

    <body> 
     <h1>Hello PhoneGap</h1> 
    </body> 

</html> 

這裏是我的目錄結構和截圖當我運行此項目:
enter image description here enter image description here

更新:當我嘗試刪除index.html文件時,它仍然不顯示任何錯誤消息,只是空白頁。並在日誌站上DroidGap.onCreate()

+0

在你的項目的目錄結構中,哪裏存在index.html?我覺得這裏有什麼不對勁。如果您的應用程序缺少index.html或者它位於錯誤的位置,則會顯示錯誤,並提示如此。 – jlafay

+0

是不是給出任何錯誤?因爲我沒有看到你的代碼有什麼問題。可能是你的建設路徑,嘗試清理你的項目,看看是否有幫助。 – 0gravity

+0

@jlafay我已經更新我的線程來顯示我的目錄結構。並沒有顯示任何錯誤信息。 – blankon91

回答

1

我找到解決方案,我在我的android清單上放錯了一個活動的名稱。

所以我通過將Android清單上的活動名稱更改爲正確的名稱來解決此問題。這裏是我解決它之後的Android清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest package="report.weeklyflash" 
    android:versionCode="1" 
    android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android"> 

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

    <supports-screens 
     android:largeScreens="true" 
     android:normalScreens="true" 
     android:smallScreens="true" 
     android:resizeable="true" 
     android:anyDensity="true" /> 

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

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 

     <activity android:name="MenuActivity" android:label="@string/app_name"></activity> 

     <activity android:name=".WeeklyFlashIdActivity"></activity> 

     <activity 
      android:name="MenuPhonegap" 
      android:label="@string/app_name" 
      android:configChanges="orientation|keyboardHidden"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 
+0

那麼你的項目中清單文件圖標上的黃色警告圖標是什麼?我從來沒有錯誤的活動名稱,所以我不確定eclipse是否足夠聰明以找到它並在錯誤時抱怨。 – jlafay

+0

@jlafay好吧,它只是無用的警告..我有3個活動,我只想使用1個活動,而我給了錯誤的活動名稱,所以eclipse找不到錯誤,因爲它是一個有效的活動名稱。基本上,這是我的錯:p – blankon91

相關問題