Android Question App crashes when compiled with targetSdkVersion 28 vs 26

biometrics

Active Member
Licensed User
Longtime User
I've updated to the latest B4X 9.80, Oracle JDK 8u241, Command line tools, resources.zip, Configure Paths updated.

It works fine with targetSdkVersion 26 but at 28 I get this log:

Any ideas?

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpGet;
    at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.InitializeGet(HttpClientWrapper.java:342)
    at anywheresoftware.b4a.samples.httputils2.httpjob._download2(httpjob.java:109)
    at evolabs.audit.main._activity_create(main.java:685)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at evolabs.audit.main.afterFirstLayout(main.java:104)
    at evolabs.audit.main.access$000(main.java:17)
    at evolabs.audit.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7682)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpGet
    ... 19 more
** Activity (main) Resume **
java.lang.RuntimeException: Unable to create service evolabs.audit.firebasemessaging: java.lang.RuntimeException: java.net.SocketException: Connection reset
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4082)
    at android.app.ActivityThread.access$1800(ActivityThread.java:231)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1968)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7682)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.RuntimeException: java.net.SocketException: Connection reset
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
    at evolabs.audit.firebasemessaging.onCreate(firebasemessaging.java:48)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4070)
    ... 8 more
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:215)
    at java.net.SocketInputStream.read(SocketInputStream.java:144)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:267)
    at java.io.DataInputStream.readByte(DataInputStream.java:268)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:344)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    ... 10 more
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

biometrics

Active Member
Licensed User
Longtime User
Thanks Don. My Googling of the error led me to add:

B4X:
<uses-library android:name="org.apache.http.legacy" android:required="false" />

In AddManifestText after:

B4X:
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="28"/>

but that didn't work. Your command (outside of AddManifestText) works.
 
Upvote 0

biometrics

Active Member
Licensed User
Longtime User
You shouldn't use the old HttpUtils2. Switch to OkHttpUtils2.
Is it a direct replacement? I'd like to avoid any major changes to the app. What will the implication be if I remain on HttpUtils2 for a while?
 
Upvote 0
Top