hi ,
i use b4a 9.80
I recompiled src data using b4a 9.80 to use
when I test the app and press install is error
Where am I doing wrong ~~?
I only change the URL
Here is the error that occurred
thank you
==========Error msg =========
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
---- AppUpdating.ReadWebVN
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Webserver's info file content:
ver=2.11
<ChangeLog>
ver 1.01 - initial release
ver 1.87 - added status codes
ver 2.11 - bug fixes
</ChangeLog>
<FileSize>
1042287
</FileSize>
Web version number: 2.11
UpdateComplete - time: 00:19:31
---- AppUpdating.DownloadApk
new apk version downloaded and ready to install
UpdateComplete - time: 00:19:41
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
---- AppUpdating.InstallApk
Error occurred on line: 105 (Main)
java.lang.ClassNotFoundException: android.support$v4$content$FileProvider
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:288)
at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:74)
at eu.dgconsulting.appupdating.cl_appupdate._getfileuri(cl_appupdate.java:540)
at eu.dgconsulting.appupdating.cl_appupdate._sendinstallintent(cl_appupdate.java:1060)
at eu.dgconsulting.appupdating.cl_appupdate._installapk(cl_appupdate.java:648)
at b4a.example.appupdate2.main$ResumableSub_btnInstall_Click.resume(main.java:535)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
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:176)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1761)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
** Activity (main) Pause, UserClosed = true **
i use b4a 9.80
I recompiled src data using b4a 9.80 to use
when I test the app and press install is error
Where am I doing wrong ~~?
I only change the URL
Here is the error that occurred
thank you
B4X:
#Region Project Attributes
#ApplicationLabel: AppUpdating Example
#VersionCode: 2
#VersionName: 2.01
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private btnPackage As Button
Private btnCurVer As Button
Private btnWebVer As Button
Private btnCompare As Button
Private btnDwnld As Button
Private btnInstall As Button
Private ButtonUpdate As Button
Private EditText1 As EditText
Dim apkupdt As cl_appupdate
Private phone As Phone
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
EditText1.Color=Colors.White
EditText1.TextColor=Colors.Black
EditText1.Text=$"Step by Step library usage${CRLF}"$
If FirstTime Then
apkupdt.Initialize(Me,"update") 'initializes the class
apkupdt.Verbose = True 'this one affects the verbosity of the logs
End If
'ALWAYS NEEDED - this is your app's package name (see "Project/BuilConfigurations/Package")
apkupdt.PackageName = "b4a.example.appupdate2"
'ALWAYS NEEDED - this is the complete path to the info text file holding the newer version number
apkupdt.NewVerTxt = "http://192.168.1.83/android_apk/mes_sys/AppUpdateExample2.inf"
'apkupdt.NewVerTxt = "http://www.dgconsulting.eu/free_apk/AppUpdateExample2.inf"
'ALWAYS NEEDED - this is the complete path to your newer apk
apkupdt.NewVerApk = "http://192.168.1.83/android_apk/mes_sys/AppUpdateExample2.apk"
'apkupdt.NewVerApk = "http://www.dgconsulting.eu/free_apk/AppUpdateExample2.apk"
'OPTIONAL - Set credentials to access a protected folder. Not needed for this example
apkupdt.setCredentials("test","test")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'STEP 0: which is apk's package name?
'Can be called at any time not necessarily as step 0 as shown here
Sub btnPackage_Click
'Show package name
EditText1.Text=$"${EditText1.Text}Package name: ${apkupdt.PackageName}${CRLF}"$
End Sub
'STEP 1: which is apk's current version number?
'Can be called at any time not necessarily as step 1 as shown here
Sub btnCurVer_Click
'Read version number of currently executing apk
apkupdt.ReadCurVN 'send out command; async result in update_UpdateComplete
End Sub
'STEP 2: just curious about eventual availability of a newer apk version, so we simply check for it
'Can be called at any time not necessarily as step 2 as shown here
Sub btnWebVer_Click
'Read version number as showed in txt file on webserver
apkupdt.ReadWebVN 'send out command; async result in update_UpdateComplete
End Sub
'STEP 3: compares current version number to the one reported by the webserver
'Must follows steps 1 and 2. Assuming no errors in steps 1 and 2
Sub btnCompare_Click
If apkupdt.CurVN < apkupdt.WebVN Then
EditText1.Text=$"${EditText1.Text}Newer version available${CRLF}"$
Else
EditText1.Text=$"${EditText1.Text}No newer version available${CRLF}"$
End If
End Sub
'STEP 4: let's download the apk published on the webserver. No check on its version; just download it
'Can be called at any time not necessarily as step 4 as shown here
Sub btnDwnld_Click
'download apk from webserver raising appropriate errors when problems arise
apkupdt.DownloadApk 'send out command; async result in update_UpdateComplete
End Sub
'STEP 5: let's ask the user to install an apk's newer version, previously downloaded
'Must follow step 4.
Sub btnInstall_Click
Wait For (CheckInstallationRequirements) Complete (Result As Boolean)
apkupdt.InstallApk(Result) 'send out command; async result in update_UpdateComplete
End Sub
'Do it all (steps 1 to 5) with a single call
Sub ButtonUpdate_Click
EditText1.Text=$"A single sub call does it all${CRLF}"$
Wait For (CheckInstallationRequirements) Complete (Result As Boolean)
'OPTIONAL - if you like to show a splash screen while checking for a newer apk goes on
apkupdt.SetAndStartSplashScreen(Activity,LoadBitmap(File.DirAssets, "updating.jpg"))
'NEEDED - this is the one you need if you want to perform "automatic" updating of your apk
apkupdt.UpdateApk(Result) 'checks for newer apk, downloads it and asks the user to install it
End Sub
'This subs gets called after each command is executed
Sub update_UpdateComplete
LogColor($"UpdateComplete - time: ${DateTime.Time(DateTime.Now)}"$, 0xFF556B2F)
apkupdt.StopSplashScreen
'too lazy to manage error conditions..check apkupdt.ERR_xxx codes if you like
Select apkupdt.Status
Case apkupdt.OK_CURVER
EditText1.Text=$"${EditText1.Text}Running apk version: ${apkupdt.CurVN}${CRLF}"$
Case apkupdt.OK_WEBVER
EditText1.Text=$"${EditText1.Text}Webserver apk version: ${apkupdt.WebVN}${CRLF}"$
EditText1.Text=$"${EditText1.Text}Optional Change Log data: ${apkupdt.WebChangeLog}${CRLF}"$
EditText1.Text=$"${EditText1.Text}Optional FileSize Log data: ${apkupdt.WebFileSize}${CRLF}"$
Case apkupdt.OK_NEWERAPK
EditText1.Text=$"${EditText1.Text}Newer version available${CRLF}"$
Case apkupdt.NO_NEWERAPK
EditText1.Text=$"${EditText1.Text}No newer version available${CRLF}"$
Case apkupdt.OK_DOWNLOAD
EditText1.Text=$"${EditText1.Text}Newer version downloaded${CRLF}"$
Case apkupdt.OK_INSTALL
EditText1.Text=$"${EditText1.Text}User asked to install newer version${CRLF}"$
Case apkupdt.ERR_NOPERM
Log("No permission to install")
EditText1.Text=$"${EditText1.Text}User gave no permission to install${CRLF}"$
Case Else
EditText1.Text=$"${EditText1.Text}Status: ${apkupdt.Status}${CRLF}"$
End Select
End Sub
#Region version-safe-apk-installation
'https://www.b4x.com/android/forum/threads/version-safe-apk-installation.87667/
'Check whether we already have permission for install other apps.
'If not we open the relevant settings page
'then wait for Activity_Resume and check the value of CanRequestPackageInstalls again
Private Sub CheckInstallationRequirements As ResumableSub
If File.ExternalWritable = False Then
MsgboxAsync("Storage card not available. Make sure that your device is not connected in USB storage mode.", "")
Return False
Else If phone.SdkVersion >= 26 And apkupdt.CanRequestPackageInstalls = False Then
MsgboxAsync("Please allow me to install applications.", "")
Wait For Msgbox_Result(Result As Int)
Dim in As Intent
in.Initialize("android.settings.MANAGE_UNKNOWN_APP_SOURCES", "package:" & Application.PackageName)
StartActivity(in)
Wait For Activity_Resume '<-- wait for Activity_Resume
Return apkupdt.CanRequestPackageInstalls
Else If apkupdt.CheckNonMarketAppsEnabled = False Then
MsgboxAsync("Please enable installation of non-market applications." & CRLF & "Under Settings - Security - Unknown sources" _
& CRLF & "Or Settings - Applications - Unknown sources", "")
Return False
Else
Return True
End If
End Sub
#End Region
==========Error msg =========
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
---- AppUpdating.ReadWebVN
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Webserver's info file content:
ver=2.11
<ChangeLog>
ver 1.01 - initial release
ver 1.87 - added status codes
ver 2.11 - bug fixes
</ChangeLog>
<FileSize>
1042287
</FileSize>
Web version number: 2.11
UpdateComplete - time: 00:19:31
---- AppUpdating.DownloadApk
new apk version downloaded and ready to install
UpdateComplete - time: 00:19:41
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
---- AppUpdating.InstallApk
Error occurred on line: 105 (Main)
java.lang.ClassNotFoundException: android.support$v4$content$FileProvider
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:288)
at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:74)
at eu.dgconsulting.appupdating.cl_appupdate._getfileuri(cl_appupdate.java:540)
at eu.dgconsulting.appupdating.cl_appupdate._sendinstallintent(cl_appupdate.java:1060)
at eu.dgconsulting.appupdating.cl_appupdate._installapk(cl_appupdate.java:648)
at b4a.example.appupdate2.main$ResumableSub_btnInstall_Click.resume(main.java:535)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
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:176)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1761)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
** Activity (main) Pause, UserClosed = true **