gpt4 book ai didi

java - Cordova 3,无法开始 Activity

转载 作者:行者123 更新时间:2023-12-01 23:32:59 26 4
gpt4 key购买 nike

我正在尝试启动我的 Cordova 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>

任何帮助将不胜感激。

谢谢。

最佳答案

查看 CordobaActivity 的源代码,我怀疑问题在于您在调用 之前使用了 loadUrl >super.onCreate,这意味着 Activity 的各个方面尚未连接起来。我建议您将线路切换为:

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

(顺便说一下,不清楚为什么您要调用 super.loadUrl(Config.getStartUrl()) 两次 - 一次有超时,一次没有...)

关于java - Cordova 3,无法开始 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19065725/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com