2012-10-23 94 views
4

我使用PhoneGap的“2.0”与Android SDK 15,我只是想嵌入的WebView科尔多瓦在Android prject,我一步一步使用指南Links,在github上Links 我的应用程序也是另一个例子我跑步时自动崩溃并停止。 logcat的错误:嵌入科尔多瓦的WebView在Android

android.view.InflateException: Binary XML file line #6: Error inflating class org.apache.cordova.CordovaWebView 

我的XML文件 “main.xml中”:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <org.apache.cordova.CordovaWebView android:id="@+id/phoneGapView" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 
</LinearLayout > 

THX提前.. :)

回答

20

像我一样你可能有同样的错误。一旦我在我的活动中实现了从CordovaInterface派生的方法,特别是getActivity方法,应用程序就开始了。

@Override 
public Activity getActivity() { 
    return this; 
} 

注意,默认实现返回null而CordovaWebView最有可能需要初始化一个适当的活动实例。

注意:我正在使用PhoneGap 2.1.0

+0

其工作原理,感谢您的帮助。 – jigspatel

+0

当Eclipse自动生成它时,发生了这种情况。 – Josh

+1

它的作品像魅力,谢谢!有人可以解释一下为什么科尔多瓦为我们这些开发人员将这些地雷全部留下来? – Josh