PhoneGap 1.8.1 - super.loadUrl(“file:///android_asset/www/index.html")”问题 [英] PhoneGap 1.8.1 - super.loadUrl("file:///android_asset/www/index.html") issue
问题描述
我只是像往常一样下载并使用最新版本的phonegap:v.1.8.1
I'd just download and use latest version of phonegap : v.1.8.1
,我替换了 setContentView .layout.main)
行与 super.loadUrl(file:///android_asset/www/index.html);
当我测试我的hello world应用程序时,它总是强制关闭。应用程序无法正常运行。但如果我改回到 setContentView(R.layout.main)
,应用程序将正常运行,没有问题(对于应用程序)。真正的问题是,应用程序没有加载index.html,因为没有 super.loadUrl(file:///android_asset/www/index.html);
When I test my "hello world" application, it will always force close. The app can't run properly. But if i change back the line into setContentView(R.layout.main)
, the app will run properly and there is no problem (for the application). The real problem is, the application not load the index.html because there is no super.loadUrl("file:///android_asset/www/index.html");
line.
这里是我的代码:
package com.urfinder.android;
import android.os.Bundle;
import org.apache.cordova.DroidGap;
public class URFinderActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}`
任何人都可以给我一些建议对这个?
谢谢:)
Anyone can give me some advise about this? Thank you :)
推荐答案
1)在你的html文件中, c>< head> ?
1) In your html file, have u put this line in <head>
?
<script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>
2)在活动上添加此行
2) Add this line on top of your activity
import org.apache.cordova.*;
3)您是否复制 cordova-1.8.1.jar
从您的Cordova下载到 / libs
3) Have you copy cordova-1.8.1.jar
from your Cordova download earlier into folder /libs
4)您是否配置项目构建路径?
4) Have you configure project Build Path?
右键单击
/ libs
文件夹,然后转到构建路径/>配置
Build Path ....然后,在Libraries选项卡中,将cordova-1.8.1.jar
添加到
项目
Right click on the
/libs
folder and go to Build Paths/ > Configure Build Path.... Then, in the Libraries tab, addcordova-1.8.1.jar
to the project
5)是否复制 cordova.xml
和 plugins.xml
文件从您的Cordova下载到文件夹 / res / xml
5) Have you copy cordova.xml
and plugins.xml
file from your Cordova download earlier into folder /res/xml
这是您的检查清单。希望它帮助。
This is your check list. Hope it help.
这篇关于PhoneGap 1.8.1 - super.loadUrl(“file:///android_asset/www/index.html")”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!