Android Question Weird problem with okHTTP and TargetSDKVersion 28

Creaky

Member
Licensed User
Hi all,

I'm trying to update an older app of mine and am running into a problem with okHTTP and TargetSDKVersion 28.

Everything works fine when I use TargetSDKVersion 26, but with 28 I get the following error when executing a HTTP request:

(Line: 0) End Sub
java.lang.Exception: Sub http_responseerror signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject jvc.starlog.main_subs_0._http_responseerror(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject, class java.lang.Integer,

I have added the following in the manifest editor otherwise I got another error:

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

Can somebody help me out? Thanks! :)
 

MarcoRome

Expert
Licensed User
Add this line in your Manifest:

B4X:
'SdkVersion 28 or >
CreateResourceFromFile(Macro, Core.NetworkClearText)
AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)
 
Upvote 0

Creaky

Member
Licensed User
Thanks for your response!

Adding the 'CreateResourceFromFile(Macro, Core.NetworkClearText)' part generates another error:

Error parsing manifest script:
File not found: NetworkClearText.b4x_excluded​

I already have this part in the manifest and it does not fix the error:

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

DonManfred

Expert
Licensed User
I suggest
1. to update B4A to 9.5
2, to change the use of the okhttputils modules and replace them with the newest library. I fear you are using an old version of them.
 
Upvote 0

Creaky

Member
Licensed User
Does that mean the latest version of this library only comes with the latest version of B4A, and I can't just download the latest version of OKHTTPUtils2 ?!
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
The issue you encounter is not related to OkHttpUtils2.
If you are using OkHttp directly then you are making a mistake. Switch to OkHttpUtils2.

If you need to communicate with non-https URLs then you will need to allow clear network communication.
It can be done with:
B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)
If you are using an old version then follow these instructions: https://developer.android.com/training/articles/security-config
 
Upvote 0
Top