Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to start activity - ComponentInfo error
    text
    copied!<p>This are the errors I get when I try to start my app. Can somebody see what I'm doing wrong?</p> <p><strong>The LogCat</strong></p> <pre><code>11-19 14:01:39.993: E/AndroidRuntime(4046): FATAL EXCEPTION: main 11-19 14:01:39.993: E/AndroidRuntime(4046): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zimzux.soundapprhk/com.zimzux.soundapprhk.Start}: java.lang.NullPointerException 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.ActivityThread.access$600(ActivityThread.java:123) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.os.Handler.dispatchMessage(Handler.java:99) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.os.Looper.loop(Looper.java:137) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.ActivityThread.main(ActivityThread.java:4424) 11-19 14:01:39.993: E/AndroidRuntime(4046): at java.lang.reflect.Method.invokeNative(Native Method) 11-19 14:01:39.993: E/AndroidRuntime(4046): at java.lang.reflect.Method.invoke(Method.java:511) 11-19 14:01:39.993: E/AndroidRuntime(4046): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 11-19 14:01:39.993: E/AndroidRuntime(4046): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 11-19 14:01:39.993: E/AndroidRuntime(4046): at dalvik.system.NativeStart.main(Native Method) 11-19 14:01:39.993: E/AndroidRuntime(4046): Caused by: java.lang.NullPointerException 11-19 14:01:39.993: E/AndroidRuntime(4046): at com.zimzux.soundapprhk.Start.onCreate(Start.java:269) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.Activity.performCreate(Activity.java:4492) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 11-19 14:01:39.993: E/AndroidRuntime(4046): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) 11-19 14:01:39.993: E/AndroidRuntime(4046): ... 11 more 11-19 14:01:40.213: I/dalvikvm(4046): threadid=3: reacting to signal 3 11-19 14:01:40.213: I/dalvikvm(4046): Wrote stack traces to '/data/anr/traces.txt' 11-19 14:01:40.503: I/dalvikvm(4046): threadid=3: reacting to signal 3 11-19 14:01:40.513: I/dalvikvm(4046): Wrote stack traces to '/data/anr/traces.txt' 11-19 14:02:38.883: I/Process(4046): Sending signal. PID: 4046 SIG: 9 </code></pre> <p><strong>Here is my Manifest</strong></p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.zimzux.soundapprhk" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" &gt; &lt;activity android:name=".Opstart" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="com.zimzux.soundapprhk.OPSTART" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Start" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="com.zimzux.soundapprhk.MAIN" /&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>Here is my XML</strong></p> <p>I'm using mostly include, it's easier for me to have an overview.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00A2E8" android:gravity="center_vertical" android:orientation="vertical" android:scrollbars="vertical|horizontal" tools:context=".MainActivity" tools:ignore="SpUsage" &gt; &lt;LinearLayout android:id="@+id/top" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="20" android:layout_gravity="top" android:background="#00A2E8" android:gravity="center_horizontal" android:layout_marginLeft="100dp" android:orientation="vertical" &gt; &lt;include android:id="@+id/topbanner" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/topbanner_xml" /&gt; &lt;include android:id="@+id/topbannerindstil" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/topbanner_indstil_xml" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/main" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="100" android:layout_gravity="center" android:gravity="center" android:layout_marginTop="5dp" android:orientation="horizontal" &gt; &lt;include android:id="@+id/start" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/mainstart_xml" /&gt; &lt;include android:id="@+id/afspilmain" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/afspil_main_xml" /&gt; &lt;include android:id="@+id/spilstopmain" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/afspil_spilstop_xml" /&gt; &lt;include android:id="@+id/indstil" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/indstil_xml" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/bund" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="25" android:layout_gravity="center_horizontal" android:layout_marginBottom="5dp" android:layout_marginTop="10dp" android:gravity="center" android:orientation="horizontal" &gt; &lt;include android:id="@+id/bundbanner" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/bundbanner_xml" /&gt; &lt;include android:id="@+id/bundbannerindstil" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/bundbanner_indstil_xml" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>Here is my Java</strong></p> <p>There is a lot of findViewById's for all the others XML.</p> <pre><code>package com.zimzux.soundapprhk; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; public class Start extends Activity { MediaPlayer mp1; MediaPlayer mp2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.start_xml); final LinearLayout top = (LinearLayout) findViewById(R.id.top); final LinearLayout bund = (LinearLayout) findViewById(R.id.bund); final LinearLayout topbannerafspil = (LinearLayout) findViewById(R.id.topbanner); final LinearLayout bundbannerafspil = (LinearLayout) findViewById(R.id.bundbanner); final LinearLayout start = (LinearLayout) findViewById(R.id.start); final LinearLayout afspil = (LinearLayout) findViewById(R.id.afspilmain); final LinearLayout spilstop = (LinearLayout) findViewById(R.id.spilstopmain); final LinearLayout indstil = (LinearLayout) findViewById(R.id.indstil); final LinearLayout topbannerindstil = (LinearLayout) findViewById(R.id.topbannerindstil); final LinearLayout bundbannerindstil = (LinearLayout) findViewById(R.id.bundbannerindstil); ImageView btnstart = (ImageView) findViewById(R.id.btnstart); ImageView btnindstil = (ImageView) findViewById(R.id.btnindstil); @SuppressWarnings("unused") TextView textnowpl = (TextView) findViewById(R.id.textnowpl); Button btnscor = (Button) findViewById(R.id.btnscor); Button btntimeout = (Button) findViewById(R.id.btntimeout); Button btnudvisning = (Button) findViewById(R.id.btnudvisning); Button btnstraffe = (Button) findViewById(R.id.btnstraffe); Button btnindlob = (Button) findViewById(R.id.btnindlob); Button btnopvarmning = (Button) findViewById(R.id.btnopvarmning); Button btnhalvleg = (Button) findViewById(R.id.btnhalvleg); Button btnnextsong = (Button) findViewById(R.id.btnnextsong); Button btnspilstop = (Button) findViewById(R.id.btnspilstop); Button btnbasic = (Button) findViewById(R.id.btnbasic); Button btnspilswitchstop = (Button) findViewById(R.id.btnspilswitchstop); Button btnfadeud = (Button) findViewById(R.id.btnfadeud); Button btnstop = (Button) findViewById(R.id.btnstop); Button spilstop1 = (Button) findViewById(R.id.spilstop1); Button spilstop2 = (Button) findViewById(R.id.spilstop2); Button spilstop3 = (Button) findViewById(R.id.spilstop3); Button spilstop4 = (Button) findViewById(R.id.spilstop4); Button spilstop5 = (Button) findViewById(R.id.spilstop5); Button spilstop6 = (Button) findViewById(R.id.spilstop6); Button spilstop7 = (Button) findViewById(R.id.spilstop7); Button spilstop8 = (Button) findViewById(R.id.spilstop8); Button spilstop9 = (Button) findViewById(R.id.spilstop9); Button spilstop10 = (Button) findViewById(R.id.spilstop10); Button spilstop11 = (Button) findViewById(R.id.spilstop11); Button spilstop12 = (Button) findViewById(R.id.spilstop12); Button spilstop13 = (Button) findViewById(R.id.spilstop13); Button spilstop14 = (Button) findViewById(R.id.spilstop14); Button spilstop15 = (Button) findViewById(R.id.spilstop15); Button spilstop16 = (Button) findViewById(R.id.spilstop16); top.setVisibility(View.GONE); topbannerafspil.setVisibility(View.GONE); topbannerindstil.setVisibility(View.GONE); bund.setVisibility(View.GONE); bundbannerafspil.setVisibility(View.GONE); bundbannerindstil.setVisibility(View.GONE); start.setVisibility(View.VISIBLE); afspil.setVisibility(View.GONE); spilstop.setVisibility(View.GONE); indstil.setVisibility(View.GONE); btnstart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ topbannerafspil.setVisibility(View.VISIBLE); bundbannerafspil.setVisibility(View.VISIBLE); start.setVisibility(View.GONE); afspil.setVisibility(View.VISIBLE); spilstop.setVisibility(View.GONE); indstil.setVisibility(View.GONE); topbannerindstil.setVisibility(View.GONE); bundbannerindstil.setVisibility(View.GONE); top.setVisibility(View.VISIBLE); bund.setVisibility(View.VISIBLE); }}); btnindstil.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ topbannerafspil.setVisibility(View.GONE); bundbannerafspil.setVisibility(View.GONE); start.setVisibility(View.GONE); afspil.setVisibility(View.GONE); spilstop.setVisibility(View.GONE); indstil.setVisibility(View.VISIBLE); topbannerindstil.setVisibility(View.VISIBLE); bundbannerindstil.setVisibility(View.VISIBLE); top.setVisibility(View.VISIBLE); bund.setVisibility(View.VISIBLE); }}); btnbasic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ afspil.setVisibility(View.VISIBLE); spilstop.setVisibility(View.GONE); }}); btnspilswitchstop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){ afspil.setVisibility(View.GONE); spilstop.setVisibility(View.VISIBLE); }}); }} </code></pre>
 

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