Android Question [SOLVED] AppUpdating 2.0 error IsValidComplete not start

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I try to run in my application the AppUpdating 2 library
When I run the application I get one error in line ApkUpdt.ReadWebVN

The error I get says
B4X:
Activity Height: 752 - Activity Width: 1280
17
sending message to waiting queue of uninitialized activity (subscribetotopics)
SDK#: 25 - UseFP: true - SharedFolder: /data/user/0/gr.long.view/files/shared
---- AppUpdating.ReadCurVN
    Current Version: 1.32
UpdateComplete - time: 18:34:00
Running apk version: 1.32
---- AppUpdating.ReadWebVN
IsValidComplete start
before
Error occurred on line: 121 (cl_appupdate)
java.lang.NumberFormatException: empty String
    at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1071)
    at java.lang.Double.parseDouble(Double.java:547)
    at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:58)
    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.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6186)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

I check my long.inf file and the format is UTF8.
Inside the file for the moment I have
B4X:
ver=1.33
<ChangeLog>
1) Auto update 1
2) Auto update 2
</ChangeLog>
<FileSize>
1456777
</FileSize>

Anything else I can check?

Thank you.
 

makis_best

Well-Known Member
Licensed User
Longtime User
OK.... Finally I make it work.

At main I change the way I call ReadWebVn using wait for
B4X:
Wait For (TestReadInfFile) complete (succ As Int) 'send out command; async result in update_UpdateComplete
If succ <> 0 Then
    Log($"WebVN : "$ & ApkUpdt.WebVN)
End If
and on sub just
B4X:
Sub TestReadInfFile As ResumableSub
    Dim J1 As cl_appupdate
    J1.Initialize(Me,"update")
    wait for (J1) complete (succ As Boolean)
    If succ Then
        J1.ReadWebVN
    End If
    Return J1.Status
End Sub

And about UpdateComplete just...
B4X:
Sub update_UpdateComplete
    LogColor($"UpdateComplete - time: ${DateTime.Time(DateTime.Now)}"$, 0xFF556B2F)
    'too lazy to manage error conditions..check apkupdt.ERR_xxx codes if you like
    Select ApkUpdt.Status
        Case ApkUpdt.OK_CURVER
            Log($"Running apk version: ${ApkUpdt.CurVN}"$)
            ApkUpdt.ReadWebVN
        Case ApkUpdt.OK_WEBVER
            Log($"Webserver apk version: ${ApkUpdt.WebVN}$"$)
            If ApkUpdt.CurVN < ApkUpdt.WebVN Then
                Msgbox2Async($"New version (${ApkUpdt.WebVN}) for install."$, "New version", "Yes", "", "No", Null, False)
                Wait For Msgbox_Result (index As Int)
                If index <> DialogResponse.CANCEL Then ApkUpdt.DownloadApk
            End If
        Case ApkUpdt.OK_DOWNLOAD
            Wait For (CheckInstallationRequirements) Complete (Result As Boolean)
            ApkUpdt.InstallApk(Result)
        Case ApkUpdt.OK_INSTALL
            Log($"User asked to install newer version"$)
        Case ApkUpdt.ERR_NOPERM
            Log("No permission to install")
        Case Else
            Log($"Status: ${ApkUpdt.Status}"$)
    End Select
End Sub

Thank you all for your held
Especially @udg
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi, just came back home and saw your message. I'm glad you solved the problem and now AU works well for you.
Just a side note: I don't think this is an ideal way to call the functions in the lib; it's closer to a workaround than a properly structured solution. My preference, as long we won't have a later version of AppUpdating, goes to something outlined as below (it's not actual code, but shows the overall idea):

B4X:
sub Activity_Create
...
ChooseLayout
end sub

sub ChooseLayout
wait for (CheckForUpdates) Complete (res as boolean)
if res then
   'show layout1
   Msgbox2Async($"New version (${ApkUpdt.WebVN}) for install."$, "New version", "Yes", "", "No", Null, False)
    Wait For Msgbox_Result (index As Int)
    If index <> DialogResponse.CANCEL Then wait for (DownloadAndInstall ) Complete (ob as Object)
else
    'show layout2
end if
end sub


sub CheckForUpdates as Resumablesub
wait for (apkupdt.ReadCurVN) Complete(status as int)
if apkupdt.status = apkupdt.OK_CurVN then wait for (apkupdt.ReadWebVN) Complete (status as int) else Return False
if apkupdt.status = apkupdt.OK_WebVN then return (apkupdt.CurVN < apkupdt.WebVN) else Return False
return False
end sub

sub DownloadAndInstall as resumablesub
wait for (ApkUpdt.DownloadApk) Complete (status as int)
if apkupdt.status = apkupdt.OK_DOWNLOAD then
   Wait For (CheckInstallationRequirements) Complete (Result As Boolean)
   ApkUpdt.InstallApk(Result)
end if
return Null
end sub

Anyway, the scheme you adopt is dependent on your app and on how you're comfortable with a solution over the other (or any other alternative that could come to mind).
 
Last edited:
Upvote 0

yinjiantuan

Member
Licensed User
Longtime User
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/b4a.example.appupdate2/files/shared/tmp.apk
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi, you really need to start a new thread for your question. This is needed in order to facilitate searching for others having the same issue.
Anyway, have a look at this thread where you may find the response to your request.
 
Upvote 0
Top