Note that there are some explanatory texts on larger screens.

plurals
  1. POThenewboston Lesson 21 crash. Finishing Listactivity
    primarykey
    data
    text
    <p>I am learning android application development using The New Boston tutorials. I completed lesson 21, but when i run my code, the application crashes after the splash screen (i.e the logo). Please help. I don't want to quit this tutorial. If there is anything else from eclipse u need except the data given below please let me know. Thanks in advance.</p> <p><strong>My manifest:</strong></p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.thenewboston.pok" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".Splash" android:label="@string/title_activity_the_new_boston" &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;activity android:name=".TheNewBostonActivity" android:label="@string/title_activity_the_new_boston" &gt; &lt;intent-filter&gt; &lt;action android:name="com.thenewboston.pok.THENEWBOSTONACTIVITY" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".MENU" android:label="@string/title_activity_the_new_boston" &gt; &lt;intent-filter&gt; &lt;action android:name="com.thenewboston.pok.MENU" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p><strong>My Menu.java:</strong></p> <pre><code>package com.thenewboston.pok; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; public class Menu extends ListActivity{ String classes[]={"TheNewBostonActivity", "example1", "example2", "example3", "example4", "example5", "example6"}; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(Menu.this, android.R.layout.simple_list_item_1, classes)); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); String cheese = classes[position]; try{ Class ourClass = Class.forName("com.thenewboston.pok." + cheese); Intent ourIntent = new Intent(Menu.this, ourClass); startActivity(ourIntent); } catch (ClassNotFoundException e){ e.printStackTrace(); } } } </code></pre> <p><strong>My Splash.java:</strong></p> <pre><code>package com.thenewboston.pok; import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class Splash extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.splash); Thread timer = new Thread(){ public void run() { try{ sleep(5000); }catch (InterruptedException e){ e.printStackTrace(); }finally{ Intent open1= new Intent ("com.thenewboston.pok.MENU"); startActivity(open1); } } }; timer.start(); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); } } </code></pre> <p><strong>My TheNewBostonActivity.java:</strong></p> <pre><code>package com.thenewboston.pok; import android.media.MediaPlayer; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.widget.Button; import android.widget.TextView; public class TheNewBostonActivity extends Activity { MediaPlayer ourSong; int counter; Button add, sub; TextView display; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ourSong = MediaPlayer.create(TheNewBostonActivity.this, R.raw.undisclosed_desires); ourSong.start(); counter = 0; add = (Button) findViewById(R.id.bAdd); sub = (Button) findViewById(R.id.bSub); display = (TextView) findViewById(R.id.tvDisplay); add.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub counter++; display.setText("Your Total Is " + counter); } }); sub.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub counter--; display.setText("Your Total Is " + counter); } }); } @Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); ourSong.release(); } } </code></pre> <p><strong>My log file:</strong></p> <pre><code>09-25 14:56:56.778: D/AndroidRuntime(336): Shutting down VM 09-25 14:56:56.778: W/dalvikvm(336): threadid=1: thread exiting with uncaught exception (group=0x40015560) 09-25 14:56:56.797: E/AndroidRuntime(336): FATAL EXCEPTION: main 09-25 14:56:56.797: E/AndroidRuntime(336): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.thenewboston.pok/com.thenewboston.pok.MENU}: java.lang.ClassNotFoundException: com.thenewboston.pok.MENU in loader dalvik.system.PathClassLoader[/data/app/com.thenewboston.pok-1.apk] 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.os.Handler.dispatchMessage(Handler.java:99) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.os.Looper.loop(Looper.java:123) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.ActivityThread.main(ActivityThread.java:3683) 09-25 14:56:56.797: E/AndroidRuntime(336): at java.lang.reflect.Method.invokeNative(Native Method) 09-25 14:56:56.797: E/AndroidRuntime(336): at java.lang.reflect.Method.invoke(Method.java:507) 09-25 14:56:56.797: E/AndroidRuntime(336): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 09-25 14:56:56.797: E/AndroidRuntime(336): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 09-25 14:56:56.797: E/AndroidRuntime(336): at dalvik.system.NativeStart.main(Native Method) 09-25 14:56:56.797: E/AndroidRuntime(336): Caused by: java.lang.ClassNotFoundException: com.thenewboston.pok.MENU in loader dalvik.system.PathClassLoader[/data/app/com.thenewboston.pok-1.apk] 09-25 14:56:56.797: E/AndroidRuntime(336): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 09-25 14:56:56.797: E/AndroidRuntime(336): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 09-25 14:56:56.797: E/AndroidRuntime(336): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 09-25 14:56:56.797: E/AndroidRuntime(336): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561) 09-25 14:56:56.797: E/AndroidRuntime(336): ... 11 more </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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