Note that there are some explanatory texts on larger screens.

plurals
  1. POstupid error in android
    text
    copied!<p>I have a simple activity in android where I'm doing something like:</p> <pre><code>givepassw = (EditText) findViewById(R.id.txt_password); login = (Button) findViewById(R.id.login_button); sony = (ImageView) findViewById(R.id.sony1); orange = (ImageView) findViewById(R.id.orange1); sony.setImageResource(R.drawable.btn_sony); orange.setImageResource(R.drawable.btn_orange); </code></pre> <p>So...simple things.The problem is that sometimes I get <code>NullPointerException</code> at one of these lines but most of the time this works perfect.</p> <p>What could be the problem ???Cause everything is defined and simple to understand....</p> <pre><code>LOGCAT: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Xperiaproject/com.Xperiaproject.LoginPage}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675) at android.app.ActivityThread.access$1500(ActivityThread.java:121) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3701) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) at dalvik.system.NativeStart.main(Native Method) 08-30 12:18:49.605: ERROR/AndroidRuntime(1623): Caused by: java.lang.NullPointerException at com.Xperiaproject.LoginPage.onCreate(LoginPage.java:78) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623) </code></pre> <p>At this line: <code>login = (Button) findViewById(R.id.login_button);</code> but I also get at this line: <code>sony.setImageResource(R.drawable.btn_sony);</code></p> <p><code>IMPORTANT</code>: <code>Is not about setting properly the layout....cause 90% of the time this code works perfect.But sometimes the same code is not working!!!</code></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