I am using an edited version of:
The Example app runs great.
However, when I port it over to my main app, I get the following error:
The error is here (Marked WITH "<---------------------"):
I have checked the Manifest and this is in:
I am running the example in Post #243B4A Library - AppUpdating - automate apps updating from a webserver
Hey I never got around to it as it really wasnt causing a problem. But, the new B4A 6.80 release breaks your library. its completely broken. Error: LogCat connected to: HA0N5DDN --------- beginning of system --------- beginning of main --------- beginning of crash main_update_updatecomplete...www.b4x.com
The Example app runs great.
However, when I port it over to my main app, I get the following error:
B4X:
---- AppUpdating.UpdateApk
Current Version: 1.00
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
---- AppUpdating.JobDone --
JobName = JobWebVNcompare, Success = true
-- JoWebVNcompare
Read while in webVNcompare: ver=1.01
Web version number: 1.01
Newer version available. Now I try its downloading
-- ApkUpdate
---- AppUpdating.JobDone --
JobName = JobApkUpdate, Success = true
-- JobApkUpdate
Error occurred on line: 331 (cl_appupdate)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.rob.leadguru/files/tmp.apk: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
at com.rob.leadguru.cl_appupdate._jobdone(cl_appupdate.java:812)
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 anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:746)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
... 17 more
The error is here (Marked WITH "<---------------------"):
B4X:
Private Sub JobDone (Job As HttpJob)
Log("---- AppUpdating.JobDone --")
If sVerbose Then Log(TAB & "JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "JobWebVNonly"
If sVerbose Then Log(TAB & "Read while in JobWebVNonly: " & Job.GetString)
webver=ExtractVN(Job.GetString) 'Job.GetString.SubString(4)
webclog=ExtractCL(Job.GetString) 'optional changelog data
If webver = "" Then
sStatusCode = ERR_TXTROW
Else
sStatusCode = OK_WEBVER 'read apk's version number as published on webserver
If sVerbose Then Log(TAB & "Web version number: " & webver)
End If
Finito
Case "JobApkDownload"
Log(TAB & "-- JobApkDownload")
'copy from external to storage card
Dim out As OutputStream
out = File.OpenOutput(File.DirDefaultExternal,"tmp.apk",False)
File.Copy2(Job.GetInputStream, out)
out.Close
sStatusCode = OK_DOWNLOAD
If sVerbose Then Log(TAB & "new apk version downloaded and ready to install")
Finito
Case "JobWebVNcompare"
Log(TAB & "-- JoWebVNcompare")
If sVerbose Then Log(TAB & "Read while in webVNcompare: " & Job.GetString)
webver=ExtractVN(Job.GetString) 'Job.GetString.SubString(4)
webclog=ExtractCL(Job.GetString) 'optional changelog data
If webver = "" Then
sStatusCode = ERR_TXTROW
Finito
Else
sStatusCode = OK_WEBVER 'read apk's version number as published on webserver
If sVerbose Then Log(TAB & "Web version number: " & webver)
End If
If curver < webver Then
sStatusCode = OK_NEWERAPK 'newer apk version available on webserver
If sVerbose Then Log(TAB & "Newer version available. Now I try its downloading")
ApkUpdate 'download and install
Else
sStatusCode = NO_NEWERAPK
If sVerbose Then Log(TAB & "No newer version available on webserver.")
Finito
End If
Case "JobApkUpdate"
Log(TAB & "-- JobApkUpdate")
'copy from external to storage card
Dim out As OutputStream
out = File.OpenOutput(File.DirDefaultExternal,"tmp.apk",False) '<-------------------------------ERROR HERE
File.Copy2(Job.GetInputStream, out)
out.Close
sStatusCode = OK_DOWNLOAD
If sVerbose Then Log(TAB & "new apk version downloaded and ready to install")
'intent to install
Dim i As Intent
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirDefaultExternal, "tmp.apk"))
i.SetType("application/vnd.android.package-archive")
StartActivity(i)
sStatusCode = OK_INSTALL
If sVerbose Then Log(TAB & "user asked to install new apk")
Finito
End Select
Else
Log(TAB & "Error: " & Job.ErrorMessage)
sStatusCode = ERR_HTTP
If sVerbose Then Log(TAB & "error in httputils2")
ToastMessageShow("Error: " & Job.ErrorMessage, True)
Finito
End If
Job.Release
End Sub
I have checked the Manifest and this is in:
so, I don't know what is causing the erroe.<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>