aliounemane2
Messages postés28Date d'inscriptionmardi 16 décembre 2014StatutMembreDernière intervention 5 octobre 2017
-
5 févr. 2015 à 23:54
John82 -
6 févr. 2015 à 00:10
Bonjour j'utilise comme IDE android Studio et en exécutant mon code mon application se lance au bout de 10secondes et se ferme et m'envoie un message sous forme de boite de dialogue en me disant que Test (c'est le nom de l'application) est arrété
voici le code fragment_main.xml
02-05 22:49:17.139 19589-19589/com.example.nema.test D/ActivityThread? setTargetHeapUtilization:0.25
02-05 22:49:17.149 19589-19589/com.example.nema.test D/ActivityThread? setTargetHeapIdealFree:8388608
02-05 22:49:17.149 19589-19589/com.example.nema.test D/ActivityThread? setTargetHeapConcurrentStart:2097152
02-05 22:49:17.409 19589-19589/com.example.nema.test D/AndroidRuntime? Shutting down VM
02-05 22:49:17.409 19589-19589/com.example.nema.test W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x40e51438)
02-05 22:49:17.409 19589-19589/com.example.nema.test E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nema.test/com.example.nema.test.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4963)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.nema.test.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:5184)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4963)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Tout simplement dans MainActivity tu fais appel au layout activity_main tandis que la listView que tu essaye de référencer se trouve dans fragment_main.xml.
Essaye de faire un setContentView(R.layout.fragment_main)