-1

The app starts without a problem but at the last step it closes with: Unfortunately, "YOURAPP" has stopped.

Log Cat gives me the following output, but I don't understand where the real problem is:

01-02 10:39:05.634: W/NetworkManagementSocketTagger(90): setKernelCountSet(10005, 0) failed with errno -2
01-02 10:39:05.644: W/InputManagerService(90): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41ac4678 (uid=10005 pid=203)
01-02 10:39:22.314: D/AndroidRuntime(565): Shutting down VM
01-02 10:39:22.314: W/dalvikvm(565): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
01-02 10:39:22.394: E/AndroidRuntime(565): FATAL EXCEPTION: main
01-02 10:39:22.394: E/AndroidRuntime(565): java.lang.IllegalStateException: Could not execute method of the activity
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.view.View$1.onClick(View.java:3039)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.view.View.performClick(View.java:3480)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.view.View$PerformClick.run(View.java:13983)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.os.Handler.handleCallback(Handler.java:605)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.os.Looper.loop(Looper.java:137)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.app.ActivityThread.main(ActivityThread.java:4340)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.lang.reflect.Method.invokeNative(Native Method)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.lang.reflect.Method.invoke(Method.java:511)
01-02 10:39:22.394: E/AndroidRuntime(565):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-02 10:39:22.394: E/AndroidRuntime(565):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-02 10:39:22.394: E/AndroidRuntime(565):  at dalvik.system.NativeStart.main(Native Method)
01-02 10:39:22.394: E/AndroidRuntime(565): Caused by: java.lang.reflect.InvocationTargetException
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.lang.reflect.Method.invokeNative(Native Method)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.lang.reflect.Method.invoke(Method.java:511)
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.view.View$1.onClick(View.java:3034)
01-02 10:39:22.394: E/AndroidRuntime(565):  ... 11 more
01-02 10:39:22.394: E/AndroidRuntime(565): Caused by: android.os.NetworkOnMainThreadException
01-02 10:39:22.394: E/AndroidRuntime(565):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.net.InetAddress.getAllByName(InetAddress.java:220)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
01-02 10:39:22.394: E/AndroidRuntime(565):  at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
01-02 10:39:22.394: E/AndroidRuntime(565):  at java.net.URL.openStream(URL.java:462)
01-02 10:39:22.394: E/AndroidRuntime(565):  at at.mav.abc2.MainActivity.letzteseiteClick(MainActivity.java:267)
01-02 10:39:22.394: E/AndroidRuntime(565):  ... 14 more
01-02 10:39:22.614: W/ActivityManager(90):   Force finishing activity at.mav.abc2/.MainActivity
01-02 10:39:22.614: W/WindowManager(90): Failure taking screenshot for (240x394) to layer 21010
01-02 10:39:22.754: I/WindowManager(90): createSurface Window{41b1a098  paused=false}: DRAW NOW PENDING
01-02 10:39:22.824: D/dalvikvm(565): GC_CONCURRENT freed 298K, 3% free 14173K/14599K, paused 17ms+61ms
01-02 10:39:23.169: W/ActivityManager(90): Activity pause timeout for ActivityRecord{41a86108 at.mav.abc2/.MainActivity}
01-02 10:39:23.216: W/NetworkManagementSocketTagger(90): setKernelCountSet(10005, 1) failed with errno -2
01-02 10:39:23.354: I/WindowManager(90): createSurface Window{41a70210 com.android.launcher/com.android.launcher2.Launcher paused=false}: DRAW NOW PENDING
01-02 10:39:24.404: W/NetworkManagementSocketTagger(90): setKernelCountSet(10040, 0) failed with errno -2
01-02 10:39:26.274: I/Process(565): Sending signal. PID: 565 SIG: 9
01-02 10:39:26.315: I/WindowManager(90): WIN DEATH: Window{41a66820 at.mav.abc2/at.mav.abc2.MainActivity paused=false}
01-02 10:39:26.315: I/ActivityManager(90): Process at.mav.abc2 (pid 565) has died.
01-02 10:39:26.444: W/InputManagerService(90): Got RemoteException sending setActive(false) notification to pid 565 uid 10040
01-02 10:39:34.248: W/ActivityManager(90): Activity destroy timeout for ActivityRecord{41a86108 at.mav.abc2/.MainActivity}

On Android 1.6, 2.1, 2.3.3 there is no problem. It only occurs with version 4.0 or higher

molnarm
  • 9,856
  • 2
  • 42
  • 60
oli
  • 5
  • 4

3 Answers3

1

The log tells you what the problem is:

Caused by: android.os.NetworkOnMainThreadException

See the documentation for details and best practices.

molnarm
  • 9,856
  • 2
  • 42
  • 60
0

This exception is thrown when an application attempts to perform a networking operation on its main thread. Run your code in AsyncTask: Document

class Task extends AsyncTask<Void, Void, Void> {

    private Exception exception;

    protected Void doInBackground(Void... v) {
        // do your tasks here
    }

    protected void onPostExecute(RSSFeed feed) {

    }
}

How to execute the task:

new Task().execute();

Don't forget to add Internet permissions to AndroidManifest.xml file:

RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
0

You are trying to make network operations on the main thread.

http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

this has to be done inside its own thread.

m.Ling
  • 296
  • 1
  • 6