2013-09-28 53 views
0

我想開始我的科爾多瓦3應用程序,但似乎我遇到了一些問題。科爾多瓦3,無法啓動活動

錯誤日誌:

09-28 18:03:05.538: E/AndroidRuntime(25370): FATAL EXCEPTION: main 
09-28 18:03:05.538: E/AndroidRuntime(25370): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fourgamers.reader/com.fourgamers.reader.FourGamers}: java.lang.NullPointerException 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.ActivityThread.access$600(ActivityThread.java:140) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.os.Handler.dispatchMessage(Handler.java:99) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.os.Looper.loop(Looper.java:137) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.ActivityThread.main(ActivityThread.java:4898) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at java.lang.reflect.Method.invokeNative(Native Method) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at java.lang.reflect.Method.invoke(Method.java:511) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at dalvik.system.NativeStart.main(Native Method) 
09-28 18:03:05.538: E/AndroidRuntime(25370): Caused by: java.lang.NullPointerException 
09-28 18:03:05.538: E/AndroidRuntime(25370): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:374) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:338) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:451) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at com.fourgamers.reader.FourGamers.onCreate(FourGamers.java:31) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.Activity.performCreate(Activity.java:5206) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083) 
09-28 18:03:05.538: E/AndroidRuntime(25370): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064) 
09-28 18:03:05.538: E/AndroidRuntime(25370): ... 11 more 

FourGamers.java

/* 
     Licensed to the Apache Software Foundation (ASF) under one 
     or more contributor license agreements. See the NOTICE file 
     distributed with this work for additional information 
     regarding copyright ownership. The ASF licenses this file 
     to you under the Apache License, Version 2.0 (the 
     "License"); you may not use this file except in compliance 
     with the License. You may obtain a copy of the License at 

     http://www.apache.org/licenses/LICENSE-2.0 

     Unless required by applicable law or agreed to in writing, 
     software distributed under the License is distributed on an 
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
     KIND, either express or implied. See the License for the 
     specific language governing permissions and limitations 
     under the License. 
*/ 

package com.fourgamers.reader; 

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

public class FourGamers extends DroidGap 
{ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.setIntegerProperty("splashscreen", R.drawable.splash); 
     super.loadUrl(Config.getStartUrl(), 10000); 

     super.onCreate(savedInstanceState); 
     // Set by <content src="index.html" /> in config.xml 
     super.loadUrl(Config.getStartUrl()); 
     //super.loadUrl("file:///android_asset/www/index.html") 

    } 
} 

的AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?> 
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" android:windowSoftInputMode="adjustPan" package="com.fourgamers.reader" xmlns:android="http://schemas.android.com/apk/res/android"> 
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="FourGamers" android:theme="@android:style/Theme.Black.NoTitleBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="18" /> 
</manifest> 

不限ħ艾爾普將不勝感激。

謝謝。

+2

代碼你已經給FourGamers.java只有20行,但異常表明行31 ... –

+0

對不起,我刪除了默認標題:)現在增加了一個完整的。 –

回答

3

看着爲CordobaActivity的源代碼,我懷疑的問題是,你正在使用loadUrl你叫super.onCreate之前,這意味着活動的各個方面不勾搭上了呢。我建議您切換輪線,這一點:

super.onCreate(savedInstanceState); 
super.setIntegerProperty("splashscreen", R.drawable.splash); 
super.loadUrl(Config.getStartUrl(), 10000); 

(爲什麼你調用super.loadUrl(Config.getStartUrl())兩次,順便目前尚不清楚 - 沒有一次因超時而一旦...)

+0

這似乎解決了它。謝謝你,喬恩。 –