Android Question android 9 device crash dowloading text file

chiales

Member
Licensed User
Longtime User
I'have a simple button that download text file from site https:
It run until android8 , android 9 phone crash with new
sdk 28 compilation.

help me

Sub Button2_Click
Button2.Text="ATTENDI..."
jib.Initialize("j",Me)
jib.Download("https://cannonedoro.altervista.org/lotto/estrazioni.txt")

End Sub

Sub JobDone(job As HttpJob)

If job.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirInternal, "estrazioni.txt", False)
File.Copy2(job.GetInputStream, out)
Msgbox("Download estrazioni completato ","Download")
Button1.Enabled=True
Button2.Text="DOWNLOAD"
out.Close '<------ very important
Else
Log("Error: " & job.ErrorMessage)
End If
job.Release
End Sub
 

Scantech

Well-Known Member
Licensed User
Longtime User
Please post your error codes.

I ran your code with Emulator Android 9 and this is the error i get.
The HttpUtils library will crash and deprecated.

Is this the error code you get? It will help others to diagnose the problem.

Notice: If you use OKHttpUtils Library version 2.82 it will not crash.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Your answer is wrong. it has nothing to do with httputils library.

Add the following to the manifest

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

DonManfred

Expert
Licensed User
Longtime User
okhttputils is a internal library. It is installed when you install b4a. It is the file OkHttpUtils2.b4xlib in the internal library folder.

2.82 is the newest

make sure not to have a okhttputils2.xml and jar in your additional library folder.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…