gpt4 book ai didi

java - 启动时崩溃: "requestFeature() must be called before adding content"

转载 作者:行者123 更新时间:2023-12-01 12:04:17 25 4
gpt4 key购买 nike

Android Eclipse 应用程序在启动时崩溃

我是 Android 开发新手,在启动项目时遇到问题。每当我启动它时,它就会崩溃

以下是 LogCat 的输出:

01-02 17:31:45.803: E/Trace(1788): error opening trace file: No such file or directory (2)
01-02 17:31:56.222: E/AndroidRuntime(1788): FATAL EXCEPTION: main
01-02 17:31:56.222: E/AndroidRuntime(1788): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gonga.ShootingParrots/com.gonga.ShootingParrots.Game}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.os.Looper.loop(Looper.java:137)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.ActivityThread.main(ActivityThread.java:5041)
01-02 17:31:56.222: E/AndroidRuntime(1788): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 17:31:56.222: E/AndroidRuntime(1788): at java.lang.reflect.Method.invoke(Method.java:511)
01-02 17:31:56.222: E/AndroidRuntime(1788): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-02 17:31:56.222: E/AndroidRuntime(1788): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-02 17:31:56.222: E/AndroidRuntime(1788): at dalvik.system.NativeStart.main(Native Method)
01-02 17:31:56.222: E/AndroidRuntime(1788): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
01-02 17:31:56.222: E/AndroidRuntime(1788): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:229)
01-02 17:31:56.222: E/AndroidRuntime(1788): at org.anddev.andengine.util.ActivityUtils.requestFullscreen(ActivityUtils.java:54)
01-02 17:31:56.222: E/AndroidRuntime(1788): at org.anddev.andengine.ui.activity.BaseGameActivity.applyEngineOptions(BaseGameActivity.java:228)
01-02 17:31:56.222: E/AndroidRuntime(1788): at org.anddev.andengine.ui.activity.BaseGameActivity.onCreate(BaseGameActivity.java:65)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.Activity.performCreate(Activity.java:5104)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-02 17:31:56.222: E/AndroidRuntime(1788): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-02 17:31:56.222: E/AndroidRuntime(1788): ... 11 more

这是我的 AndroidManifest.xml,如果您需要的话:

<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14"/>

<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application android:icon="@drawable/icone" android:installLocation="auto" android:label="@string/app" android:launchMode="singleInstance">
<activity android:configChanges="keyboard|keyboardHidden|orientation" android:name=".Game" android:screenOrientation="portrait" android:theme="@style/Theme.NoBackground">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Amazon Ads -->
<activity android:name="com.amazon.device.ads.AdActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

<!-- Admob Ads -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

谢谢。

最佳答案

logcat 说:

Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

换句话说,您在 Activity 中调用 setContentView() 后才调用 requestFeature()。但这是不可能的。您必须在调用 setContentView() 之前调用 requestFeature()。您还没有发布任何代码,所以我无法给您更具体的答案。

关于java - 启动时崩溃: "requestFeature() must be called before adding content",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27746476/

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