Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.lang.RuntimeException with android application
    text
    copied!<p>I'm having problems with my application. Shortly after compiling, the application randomly closes. Checking LogCat shows that it is a java.lang.RuntimeException. I've been through all of the forum posts on this, and have changed my code accordingly, but the problem still persists. Help?</p> <p>Code:</p> <pre><code>public class DroidzActivity extends Activity implements OnGesturePerformedListener { /** Called when the activity is first created. */ private GestureLibrary mLibrary; private static final String TAG = MainThread.class.getSimpleName(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new MainGamePanel(this)); //requesting to turn the title OFF //requestWindowFeature(Window.FEATURE_NO_TITLE); //make it full screen //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // set the MainGamePanel as the View Log.d(TAG, "View added"); mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures); if (!mLibrary.load()) { finish(); } GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures); gestures.addOnGesturePerformedListener(this); } @Override protected void onDestroy() { Log.d(TAG, "Destroying..."); super.onDestroy(); } @Override protected void onStop() { Log.d(TAG, "Stopping..."); super.onStop(); } public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) { ArrayList&lt;Prediction&gt; predictions = mLibrary.recognize(gesture); if (predictions.size() &gt; 0) { if (predictions.get(0).score &gt; 1.0) { String action = predictions.get(0).name; if ("action_add".equals(action)) { Toast.makeText(this, "Adding a contact", Toast.LENGTH_SHORT).show(); } else if ("action_delete".equals(action)) { Toast.makeText(this, "Removing a contact", Toast.LENGTH_SHORT).show(); } else if ("action_refresh".equals(action)) { Toast.makeText(this, "Reloading contacts", Toast.LENGTH_SHORT).show(); } } } } </code></pre> <p>LogCat:</p> <pre><code>02-08 23:16:54.898: D/MainThread(3027): View added 02-08 23:16:54.937: D/AndroidRuntime(3027): Shutting down VM 02-08 23:16:54.937: W/dalvikvm(3027): threadid=1: thread exiting with uncaught exception (group=0x40015578) 02-08 23:16:54.949: E/AndroidRuntime(3027): FATAL EXCEPTION: main 02-08 23:16:54.949: E/AndroidRuntime(3027): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.obviam.droidz/net.obviam.droidz.DroidzActivity}: java.lang.NullPointerException 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.os.Handler.dispatchMessage(Handler.java:99) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.os.Looper.loop(Looper.java:130) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.ActivityThread.main(ActivityThread.java:3687) 02-08 23:16:54.949: E/AndroidRuntime(3027): at java.lang.reflect.Method.invokeNative(Native Method) 02-08 23:16:54.949: E/AndroidRuntime(3027): at java.lang.reflect.Method.invoke(Method.java:507) 02-08 23:16:54.949: E/AndroidRuntime(3027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 02-08 23:16:54.949: E/AndroidRuntime(3027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 02-08 23:16:54.949: E/AndroidRuntime(3027): at dalvik.system.NativeStart.main(Native Method) 02-08 23:16:54.949: E/AndroidRuntime(3027): Caused by: java.lang.NullPointerException 02-08 23:16:54.949: E/AndroidRuntime(3027): at net.obviam.droidz.DroidzActivity.onCreate(DroidzActivity.java:42) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 02-08 23:16:54.949: E/AndroidRuntime(3027): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 02-08 23:16:54.949: E/AndroidRuntime(3027): ... 11 more </code></pre> <p>Manifest:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.obviam.droidz" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:debuggable="true"&gt; &lt;activity android:name=".DroidzActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload