Android Question android 9 device crash dowloading text file

chiales

New Member
Licensed 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
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.
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
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._download(httpjob.java:71)
at b4a.example.main._button2_click(main.java:425)
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:348)
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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.methods.HttpGet" on path: DexPathList[[zip file "/data/app/b4a.example-NftgYEB7c7pNmd6I_zwgog==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-NftgYEB7c7pNmd6I_zwgog==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 23 more
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:

DonManfred

Expert
Licensed User
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.
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" />
)
 

DonManfred

Expert
Licensed 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:
Top