Why my android application stopped when I run it in Emulator?

199 views Asked by At

Unfortunately, app has stopped.

I get this error when I'm running my application in the emulator. Why? My program doesn't contain any error, but it's not running.

I use Eclipse with SDK.

Here is my manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.jvstgs"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="3"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Tetris"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

And my LogCat

06-09 07:30:20.989: D/AndroidRuntime(627): Shutting down VM
06-09 07:30:20.989: W/dalvikvm(627): threadid=1: thread exiting with uncaught exception (group=0x40a122a0)
06-09 07:30:21.049: E/AndroidRuntime(627): FATAL EXCEPTION: main
06-09 07:30:21.049: E/AndroidRuntime(627): java.lang.RuntimeException: Unable to resume activity {com.example.jvstgs/com.example.jvstgs.Tetris}: java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2575)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2089)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread.access$600(ActivityThread.java:130)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.Looper.loop(Looper.java:137)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread.main(ActivityThread.java:4745)
06-09 07:30:21.049: E/AndroidRuntime(627): at java.lang.reflect.Method.invokeNative(Native Method)
06-09 07:30:21.049: E/AndroidRuntime(627): at java.lang.reflect.Method.invoke(Method.java:511)
06-09 07:30:21.049: E/AndroidRuntime(627): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-09 07:30:21.049: E/AndroidRuntime(627): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-09 07:30:21.049: E/AndroidRuntime(627): at dalvik.system.NativeStart.main(Native Method)
06-09 07:30:21.049: E/AndroidRuntime(627): Caused by: java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK.
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.Parcel.readException(Parcel.java:1425)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.Parcel.readException(Parcel.java:1379)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:288)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:309)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.os.PowerManager$WakeLock.acquire(PowerManager.java:288)
06-09 07:30:21.049: E/AndroidRuntime(627): at com.example.framework.impl.GLGame.onResume(GLGame.java:66)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.Activity.performResume(Activity.java:5082)
06-09 07:30:21.049: E/AndroidRuntime(627): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2565)
06-09 07:30:21.049: E/AndroidRuntime(627): ... 12 more

3

There are 3 answers

0
hungryghost On BEST ANSWER

It looks like the problem is with your permissions:

java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK

Update your manifest to include this line:

<uses-permission android:name="android.permission.WAKE_LOCK" />

Your Stack Trace

Btw, the reason everyone is able figure out your problem so quickly, is because your logcat clearly shows what your error is.

Read this post to learn more about how to read a stack trace.

0
AudioBubble On

If you read your logs, you'll see this:

java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK

Which means you need to add android.permission.WAKE_LOCK to your AndroidManifest.xml

Please read this: https://developer.android.com/training/scheduling/wakelock.html

To use a wake lock, the first step is to add the WAKE_LOCK permission to your application's manifest file:

0
reidzeibel On

Try adding WAKE_LOCK_PERMISSION to your manifest uses-permission.

More info here : http://developer.android.com/reference/android/Manifest.permission.html#WAKE_LOCK