Android app shows error

Asked

Viewed 29 times

1

Good night

I’m learning to use Android Studio. I’m trying to develop an application that picks up some json data via url, but when running my application, it presents the following error:

02-01 23:30:35.700 14230-14230/? D/dalvikvm: Late-enabling CheckJNI
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication D/AndroidRuntime: Shutting down VM
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41bd4730)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{br.net.exemplo.myapplication/br.net.exemplo.myapplication.MainActivity}: android.os.NetworkOnMainThreadException
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.access$700(ActivityThread.java:159)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:176)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5419)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:525)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:  Caused by: android.os.NetworkOnMainThreadException
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1144)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.net.InetAddress.getAllByName(InetAddress.java:214)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at br.net.exemplo.myapplication.JSONParser.getJSONFromUrl(JSONParser.java:37)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at br.net.exemplo.myapplication.MainActivity.onCreate(MainActivity.java:36)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5372)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.access$700(ActivityThread.java:159) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:176) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5419) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:525) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
02-01 23:30:36.990 14230-14230/br.net.exemplo.myapplication E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 

What can it be?

Thank you

  • 1

    java.lang.RuntimeException: Unable to start activity: br.net.example.myapplication. You did not declare in Manifest.Xml the Activity main.

  • Solved your doubt?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.