My librarie no work with targetSdkVersion="14"

Discussion in 'Android Questions' started by alan1968, Oct 22, 2012.

  1. alan1968

    alan1968 Active Member Licensed User

    A smal problem with my librarie MODBUS

    in manifest.xml

    with ics :

    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="14"/>
    no works /app close if access at a fonction of my lib

    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="7"/>
    Works fine but no ics style

    Why ?
     
    Last edited: Oct 22, 2012
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should check the logs and see the error message.
     
  3. alan1968

    alan1968 Active Member Licensed User

    Voici
    Code:
    ** Activity (main) Resume **
    main_set_ip_wago (java line: 
    19246)
    android.os.NetworkOnMainThreadException
       at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:
    1099)
       at java.net.InetAddress.lookupHostByName(InetAddress.java:
    391)


       at java.net.InetAddress.getAllByNameImpl(InetAddress.java:
    242)
       at java.net.InetAddress.getByName(InetAddress.java:
    295)
       at com.exemple.android.modbus_b4a.Ip(modbus_b4a.java:
    74)
       at wagoidpro.projet.main._set_ip_wago(main.java:
    19246)
       at wagoidpro.projet.main._activity_resume(main.java:
    1250)
       at java.lang.reflect.Method.invokeNative(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:
    511)
       at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    165)
       at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    149)
       at wagoidpro.projet.main$ResumeMessage.run(main.java:
    210)
       at android.os.Handler.handleCallback(Handler.java:
    605)
       at android.os.Handler.dispatchMessage(Handler.java:
    92)
       at anywheresoftware.b4a.Msgbox.waitForMessage(
    Msgbox.java:211)
       at anywheresoftware.b4a.Msgbox.msgbox(
    Msgbox.java:136)
       at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    202)
       at wagoidpro.projet.main.afterFirstLayout(main.java:
    84)
       at wagoidpro.projet.main.access$
    100(main.java:16)
       at wagoidpro.projet.main$WaitForLayout.run(main.java:
    72)
       at android.os.Handler.handleCallback(Handler.java:
    605)
       at android.os.Handler.dispatchMessage(Handler.java:
    92)
       at android.os.Looper.loop(Looper.java:
    137)
       at android.app.ActivityThread.main(ActivityThread.java:
    4424)
       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:
    784)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    551)
       at dalvik.system.NativeStart.main(Native Method)
    android.os.NetworkOnMainThreadException
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You library makes a network call on the main thread. This is considered bad practice as it will make the program unresponsive
     
  5. alan1968

    alan1968 Active Member Licensed User

    yes Erel ,i search on google, I saw this :-/
    I have to recode all my librarie ? or there is another way to execute in another thread my fonction


    thx!
     
  6. alan1968

    alan1968 Active Member Licensed User

  7. Erel

    Erel Administrator Staff Member Licensed User

    This library will not help.

    I recommend you to move (rewrite) all the communication code to Basic4android. Basic4android with HttpUtils2 and AsyncStreams make it much simpler to correctly implement such solutions.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice