Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Unexpected Shutdown
    primarykey
    data
    text
    <p>I've tried to get some data from the nasa rss ( I'm following Android HeadFirst book ) using the Simple Framework. The problem that I face is that the application closes down automatically when the main activity is loaded. </p> <p>Here is the code :</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { print(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>and here is the print method:</p> <pre><code>public void print() throws Exception { Rss rss = new Rss(); Serializer serializer = new Persister(); File source = new File("http://www.nasa.gov/rss/dyn/image_of_the_day.rss"); serializer.read(rss, source); TextView text = (TextView) this.findViewById(R.id.imageTitle); text.setText(rss.channel.title); } </code></pre> <p>logcat:</p> <pre><code>&gt; 12-11 18:27:03.459: D/AndroidRuntime(20621): Shutting down VM 12-11 18:27:03.459: W/dalvikvm(20621): threadid=1: thread exiting with uncaught exception (group=0x400205a0) 12-11 18:27:03.469: E/AndroidRuntime(20621): FATAL EXCEPTION: main 12-11 18:27:03.469: E/AndroidRuntime(20621): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.nasadailyimage/com.example.nasadailyimage.MainActivity}: java.lang.ClassNotFoundException: com.example.nasadailyimage.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.nasadailyimage-1.apk] 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1743) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.os.Handler.dispatchMessage(Handler.java:99) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.os.Looper.loop(Looper.java:150) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.ActivityThread.main(ActivityThread.java:4277) 12-11 18:27:03.469: E/AndroidRuntime(20621): at java.lang.reflect.Method.invokeNative(Native Method) 12-11 18:27:03.469: E/AndroidRuntime(20621): at java.lang.reflect.Method.invoke(Method.java:507) 12-11 18:27:03.469: E/AndroidRuntime(20621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 12-11 18:27:03.469: E/AndroidRuntime(20621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 12-11 18:27:03.469: E/AndroidRuntime(20621): at dalvik.system.NativeStart.main(Native Method) 12-11 18:27:03.469: E/AndroidRuntime(20621): Caused by: java.lang.ClassNotFoundException: com.example.nasadailyimage.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.nasadailyimage-1.apk] 12-11 18:27:03.469: E/AndroidRuntime(20621): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 12-11 18:27:03.469: E/AndroidRuntime(20621): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 12-11 18:27:03.469: E/AndroidRuntime(20621): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.Instrumentation.newActivity(Instrumentation.java:1040) 12-11 18:27:03.469: E/AndroidRuntime(20621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735) 12-11 18:27:03.469: E/AndroidRuntime(20621): ... 11 more </code></pre> <p>Here is the manifest file</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.nasadailyimage" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.nasadailyimage.MainActivity" 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; &lt;/manifest&gt; </code></pre> <p>I've create a brand new android project. And it works</p> <p>However even if I remove all the libraries I added ( simple.org) and if I comment out everything that I've added in MainActivity.java is <strong>still</strong> makes the application close down</p> <p>I have been able to observe that the line:</p> <pre><code>Serializer serialezer = new Persister(); </code></pre> <p>causes the error. Is the framework simple used for android applications? Does it usually cause these kind of errors?</p> <p><strong>Update</strong></p> <p>I have also tried different versions of the jar. None seem to work</p> <p>Closing Eclipse does not help whatsoever</p> <p>The program only runs when the Serializer line is <em>commented</em> out</p>
    singulars
    1. This table or related slice is empty.
    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.
    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