启动画面错误phonegap

时间:2014-05-13 21:36:04

标签: android jquery html cordova

我试图在我的应用中添加启动画面,我将app.java修改为

 public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl("file:///android_asset/www/index.html");
    }

当我运行该应用时,我收到错误消息command failed with exit code 2

我按照phonegap - splash screen for Android app

的说明进行操作

2 个答案:

答案 0 :(得分:1)

您的说明非常过时。您现在可以运行:

cordova plugin add org.apache.cordova.splashscreen

然后您不必修改app.java

另外,请务必在config.xml中设置值:

<preference name="SplashScreen" value="splash" />
//splash is the name of the image without the extension
<preference name="SplashScreenDelay" value="20000" />
//delay is optional

此外,请确保对于android,图像位于/platforms/android/res/drawable文件夹中。

最后,确保在进行这些更改后运行cordova buildcordova run

Documentation here

答案 1 :(得分:1)

尝试将代码更改为:

public void onCreate(Bundle savedInstanceState)     {         super.onCreate(savedInstanceState);         super.init();         super.setIntegerProperty(“splashscreen”,R.drawable.splash);         //在config.xml中设置         super.loadUrl( “文件:///android_asset/www/index.html”,3000);     }