我不知道为什么会出现这个错误,我花了大约两个小时试图找到源头,但我一直在兜圈子。你能快速看一下,看看有什么问题吗?
唤醒锁代码:-
wakeLock = powerManager.newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, "GLGame");
这是 LogCat 输出:-
11-02 22:07:19.114: D/SensorGUI(517): SensorChannel(const Parcel& data): mSendFd = -1, mReceiveFd = 55
11-02 22:07:19.114: D/SensorManager(517): [SensorManager] registerListener: delay = 20000
11-02 22:07:19.565: D/AndroidRuntime(517): Shutting down VM
11-02 22:07:19.565: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x40abf228)
11-02 22:07:19.615: E/AndroidRuntime(517): FATAL EXCEPTION: main
11-02 22:07:19.615: E/AndroidRuntime(517): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.an.chess/com.an.chess.ChessGame}: java.lang.IllegalArgumentException
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.ActivityThread.access$600(ActivityThread.java:139)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:99)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:154)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4945)
11-02 22:07:19.615: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
11-02 22:07:19.615: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:511)
11-02 22:07:19.615: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-02 22:07:19.615: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-02 22:07:19.615: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
11-02 22:07:19.615: E/AndroidRuntime(517): Caused by: java.lang.IllegalArgumentException
11-02 22:07:19.615: E/AndroidRuntime(517): at android.os.PowerManager$WakeLock.<init>(PowerManager.java:250)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.os.PowerManager.newWakeLock(PowerManager.java:446)
11-02 22:07:19.615: E/AndroidRuntime(517): at com.an.framework.impl.AndroidGame.onCreate(AndroidGame.java:50)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.Activity.performCreate(Activity.java:4531)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
11-02 22:07:19.615: E/AndroidRuntime(517): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
11-02 22:07:19.615: E/AndroidRuntime(517): ... 11 more
这是我的清单文件:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.an.chess"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/ic_launcher" android:label="Chester" android:debuggable="true">
<activity android:name=".ChessGame"
android:label="Chess"
android:configChanges="keyboard|keyboardHidden|orientation"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"/>
预先感谢您一直以来的友好支持!