Android Question What causes this problem. (SOLVED)

ciprian

Active Member
Licensed User
Longtime User
Hello.
I'm having a serious error in my app but i don't understand where is the problem.
Everything running well in emulator, but on my phone it's crushes.
Here is the log:
B4X:
JobName = job2, Success = true
--------- beginning of crash
java.lang.RuntimeException: java.io.FileNotFoundException: /data/user/0/com.cip.droid.ipx800/cache/4 (No such file or directory)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:233)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6938)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.io.FileNotFoundException: /data/user/0/com.cip.droid.ipx800/cache/4 (No such file or directory)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:287)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._hc_responsesuccess(httputils2service.java:173)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    ... 8 more
 

ilan

Expert
Licensed User
Longtime User
java.io.FileNotFoundException

from the logs you can see that the file you are trying to read/use does not exists. you will need to provide some code so we can see whats the problem.
are you downloading something and saving it to a file?

post the relevant code.
 
Upvote 0

nypaulie

Active Member
Licensed User
Longtime User
I had a "FileNotFound..." problem too. A user (sorex) told me to rename the .apk file to a .zip one so I could open it. In doing so I saw that my file Was actually missing. Try this trick to check yours.
 
Upvote 0

ciprian

Active Member
Licensed User
Longtime User
This is related to a http job efectively, with httputils2 library.
When i do an job.download , this causes a crash.
I've allready tried to change job.download with job.poststring... but same result.
I dont try to download some file, but just using job.download to send a http order to a http machine.
This is the code into my toogle button:
B4X:
Sub tog_CheckedChange(checked As Boolean)
    Dim index As Int
    index = clv1.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv1.GetPanel(index)
    Dim tog As ToggleButton
    tog = pnl.GetView(2) 
    Dim btn As Button
    btn = pnl.GetView(1) 
    If checked Then
        Job2.Initialize("job2", Me)
        Job2.Username = manager.GetString("user")
        Job2.Password = manager.GetString("pass")
        Job2.Download("http://"&ServerIp&":"&port&"/leds.cgi?led="&index)
        Job2.Release
        btn.Enabled = False
    Else
        Job2.Initialize("job2", Me)
        Job2.Username = manager.GetString("user")
        Job2.Password = manager.GetString("pass")
        Job2.Download("http://"&ServerIp&":"&port&"/leds.cgi?led="&index)
        Job2.Release
        btn.Enabled = True
    End If
End Sub
I'm using a samsung galaxy s8 smartphone... dont having space issues...

Same problem into a button_click sub:
B4X:
Sub Button_Click
    Dim index As Int
    index = clv1.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv1.GetPanel(index)
    Dim btn As Button
    btn = pnl.GetView(1)
    Dim indexOK As String = index +1
    Log(txtMsg.Text)
    Job2.Initialize("job2", Me)
    Job2.Username = manager.GetString("user")
    Job2.Password = manager.GetString("pass")
    Job2.Download("http://"&ServerIp&":"&port&"/preset.htm?RLY"&indexOK&"=1")
    Job2.Release
    ToastMessageShow("Impulsion Envoyé",True)
End Sub
 
Upvote 0

ciprian

Active Member
Licensed User
Longtime User
Do you mean i need to change it like this?
B4X:
Sub Button_Click
    Dim index As Int
    index = clv1.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv1.GetPanel(index)
    Dim btn As Button
    btn = pnl.GetView(1)
    Dim indexOK As String = index +1
    Log(txtMsg.Text)
    Dim Job2 as httpjob
    Job2.Initialize("job2", Me)
    Job2.Username = manager.GetString("user")
    Job2.Password = manager.GetString("pass")
    Job2.Download("http://"&ServerIp&":"&port&"/preset.htm?RLY"&indexOK&"=1")
    Wait For (Job2) JobDone(Job2 As HttpJob)
    If Job2.Success Then
        Log(Job2.GetString)
    End If
    Job2.Release
    ToastMessageShow("Impulsion Envoyé",True)
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
yes. Or use the jobdone eventsub. The point is that you need to Release the job after the wait for resp. in the jobdone sub.

B4X:
Sub Button_Click
    Dim index As Int
    index = clv1.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv1.GetPanel(index)
    Dim btn As Button
    btn = pnl.GetView(1)
    Dim indexOK As String = index +1
    Log(txtMsg.Text)
    dim job as httpjob ' you should initialize a new instance each time
    Job.Initialize("job2", Me)
    Job.Username = manager.GetString("user")
    Job.Password = manager.GetString("pass")
    Job.Download("http://"&ServerIp&":"&port&"/preset.htm?RLY"&indexOK&"=1")
    Wait For (Job) JobDone(Job As HttpJob)
    If Job.Success Then
        Log(Job.GetString)
    End If
    Job.Release
    ToastMessageShow("Impulsion Envoyé",True)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…