I am getting a NullPointerException after the build but once my phone tries to launch the app. I do not understand where the problem is. Im just learning to code and this app is simply supposed to make a toast pop up Long if the checkbox is clicked and short if it isnt.
LogCat:
02-08 12:48:34.718 6684-6684/universaltruth.toastee D/AndroidRuntime﹕ Shutting down VM
02-08 12:48:34.718 6684-6684/universaltruth.toastee W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4191bda0)
02-08 12:48:34.718 6684-6684/universaltruth.toastee E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: universaltruth.toastee, PID: 6684
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{universaltruth.toastee/universaltruth.toastee.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2408)
at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
at android.app.ActivityThread.access0(ActivityThre ad.java:174)
at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:10 2)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.jav a:5748)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.Activity.findViewById(Activity.java:20 14)
at universaltruth.toastee.MainActivity.<init>(MainAct ivity.java:19)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrument ation.java:1067)
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2399)
************at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
************at android.app.ActivityThread.access0(ActivityThre ad.java:174)
************at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
************at android.os.Handler.dispatchMessage(Handler.java:10 2)
************at android.os.Looper.loop(Looper.java:146)
************at android.app.ActivityThread.main(ActivityThread.jav a:5748)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
************at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
************at dalvik.system.NativeStart.main(Native Method)
02-08 13:00:50.672 9121-9121/universaltruth.toastee I/SELinux﹕ Function: selinux_android_load_priority , priority [3] , priority version is VE=SEPF_SM-N910F_4.4.4_A024
02-08 13:00:50.672 9121-9121/universaltruth.toastee E/SELinux﹕ [DEBUG] get_category: variable seinfocat: default sensitivity: NULL, cateogry: NULL
02-08 13:00:50.672 9121-9121/universaltruth.toastee E/dalvikvm﹕ >>>>> Normal User
02-08 13:00:50.672 9121-9121/universaltruth.toastee E/dalvikvm﹕ >>>>> universaltruth.toastee [ userId:0 | appId:10384 ]
02-08 13:00:50.682 9121-9121/universaltruth.toastee E/SELinux﹕ [DEBUG] get_category: variable seinfocat: default sensitivity: NULL, cateogry: NULL
02-08 13:00:50.682 9121-9121/universaltruth.toastee D/dalvikvm﹕ Late-enabling CheckJNI
02-08 13:00:50.682 9121-9121/universaltruth.toastee I/libpersona﹕ KNOX_SDCARD checking this for 10384
02-08 13:00:50.682 9121-9121/universaltruth.toastee I/libpersona﹕ KNOX_SDCARD not a persona
02-08 13:00:50.752 9121-9121/universaltruth.toastee D/TimaKeyStoreProvider﹕ in addTimaSignatureService
02-08 13:00:50.762 9121-9121/universaltruth.toastee D/TimaKeyStoreProvider﹕ Cannot add TimaSignature Service, License check Failed
02-08 13:00:50.762 9121-9121/universaltruth.toastee D/ActivityThread﹕ Added TimaKesytore provider
02-08 13:00:50.922 9121-9121/universaltruth.toastee D/AndroidRuntime﹕ Shutting down VM
02-08 13:00:50.922 9121-9121/universaltruth.toastee W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4191bda0)
02-08 13:00:50.922 9121-9121/universaltruth.toastee E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: universaltruth.toastee, PID: 9121
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{universaltruth.toastee/universaltruth.toastee.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2408)
at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
at android.app.ActivityThread.access0(ActivityThre ad.java:174)
at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:10 2)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.jav a:5748)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.Activity.findViewById(Activity.java:20 14)
at universaltruth.toastee.MainActivity.<init>(MainAct ivity.java:16)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrument ation.java:1067)
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2399)
************at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
************at android.app.ActivityThread.access0(ActivityThre ad.java:174)
************at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
************at android.os.Handler.dispatchMessage(Handler.java:10 2)
************at android.os.Looper.loop(Looper.java:146)
************at android.app.ActivityThread.main(ActivityThread.jav a:5748)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
************at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
************at dalvik.system.NativeStart.main(Native Method)
02-08 13:00:55.232 9121-9121/universaltruth.toastee I/Process﹕ Sending signal. PID: 9121 SIG: 9
Forgive me if I am not posting this correctly. This is my first time. I am open to any and all feedback. Thank you.
Code:
package universaltruth.toastee;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {
public CheckBox longToast = (CheckBox) findViewById(R.id.checkbox);
public EditText editText = (EditText) findViewById(R.id.toastText);
public int toastLength = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addListenerOnlongToast();
}
public void addListenerOnlongToast(){
longToast.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if(((CheckBox) view).isChecked()){
toastLength = '1';
}
}
});
}
public void toastMessage(View view){
String message = editText.getText().toString();
Toast.makeText(getApplicationContext(),message, (toastLength == 0) ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}02-08 12:48:34.718 6684-6684/universaltruth.toastee D/AndroidRuntime﹕ Shutting down VM
02-08 12:48:34.718 6684-6684/universaltruth.toastee W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4191bda0)
02-08 12:48:34.718 6684-6684/universaltruth.toastee E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: universaltruth.toastee, PID: 6684
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{universaltruth.toastee/universaltruth.toastee.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2408)
at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
at android.app.ActivityThread.access0(ActivityThre ad.java:174)
at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:10 2)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.jav a:5748)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.Activity.findViewById(Activity.java:20 14)
at universaltruth.toastee.MainActivity.<init>(MainAct ivity.java:19)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrument ation.java:1067)
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2399)
************at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
************at android.app.ActivityThread.access0(ActivityThre ad.java:174)
************at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
************at android.os.Handler.dispatchMessage(Handler.java:10 2)
************at android.os.Looper.loop(Looper.java:146)
************at android.app.ActivityThread.main(ActivityThread.jav a:5748)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
************at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
************at dalvik.system.NativeStart.main(Native Method)
02-08 13:00:50.672 9121-9121/universaltruth.toastee I/SELinux﹕ Function: selinux_android_load_priority , priority [3] , priority version is VE=SEPF_SM-N910F_4.4.4_A024
02-08 13:00:50.672 9121-9121/universaltruth.toastee E/SELinux﹕ [DEBUG] get_category: variable seinfocat: default sensitivity: NULL, cateogry: NULL
02-08 13:00:50.672 9121-9121/universaltruth.toastee E/dalvikvm﹕ >>>>> Normal User
02-08 13:00:50.672 9121-9121/universaltruth.toastee E/dalvikvm﹕ >>>>> universaltruth.toastee [ userId:0 | appId:10384 ]
02-08 13:00:50.682 9121-9121/universaltruth.toastee E/SELinux﹕ [DEBUG] get_category: variable seinfocat: default sensitivity: NULL, cateogry: NULL
02-08 13:00:50.682 9121-9121/universaltruth.toastee D/dalvikvm﹕ Late-enabling CheckJNI
02-08 13:00:50.682 9121-9121/universaltruth.toastee I/libpersona﹕ KNOX_SDCARD checking this for 10384
02-08 13:00:50.682 9121-9121/universaltruth.toastee I/libpersona﹕ KNOX_SDCARD not a persona
02-08 13:00:50.752 9121-9121/universaltruth.toastee D/TimaKeyStoreProvider﹕ in addTimaSignatureService
02-08 13:00:50.762 9121-9121/universaltruth.toastee D/TimaKeyStoreProvider﹕ Cannot add TimaSignature Service, License check Failed
02-08 13:00:50.762 9121-9121/universaltruth.toastee D/ActivityThread﹕ Added TimaKesytore provider
02-08 13:00:50.922 9121-9121/universaltruth.toastee D/AndroidRuntime﹕ Shutting down VM
02-08 13:00:50.922 9121-9121/universaltruth.toastee W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4191bda0)
02-08 13:00:50.922 9121-9121/universaltruth.toastee E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: universaltruth.toastee, PID: 9121
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{universaltruth.toastee/universaltruth.toastee.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2408)
at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
at android.app.ActivityThread.access0(ActivityThre ad.java:174)
at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:10 2)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.jav a:5748)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.Activity.findViewById(Activity.java:20 14)
at universaltruth.toastee.MainActivity.<init>(MainAct ivity.java:16)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrument ation.java:1067)
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2399)
************at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2599)
************at android.app.ActivityThread.access0(ActivityThre ad.java:174)
************at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1321)
************at android.os.Handler.dispatchMessage(Handler.java:10 2)
************at android.os.Looper.loop(Looper.java:146)
************at android.app.ActivityThread.main(ActivityThread.jav a:5748)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1291)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:1107)
************at de.robv.android.xposed.XposedBridge.main(XposedBri dge.java:132)
************at dalvik.system.NativeStart.main(Native Method)
02-08 13:00:55.232 9121-9121/universaltruth.toastee I/Process﹕ Sending signal. PID: 9121 SIG: 9
Forgive me if I am not posting this correctly. This is my first time. I am open to any and all feedback. Thank you.
Aucun commentaire:
Enregistrer un commentaire