Android Question Appupdater and update application itself

rosippc64a

Active Member
Licensed User
Longtime User
Hi All,

Long time ago I could update my app, but actually I don't. I have an android 7.1 smart TV box - not a phone or tablet. Phone.sdkVersion=25. I can't use and try adb because I vainly use usb cable, pc can't see device.
So I tried the appupdater 2.0 demo. Appupdater said:
"The package conflicts with an existing package by the same name." Of course, I want update my app, so it is normal that the package name is the same. Isn't it?

I tried also the program in the topic "Auto start app after self update", but there I had another issue. As I wrote I cant use windows adb.exe because the pc doesn't see the android device. So I made an app what is the updater (1), and an app to be updated (2). In this second app assets' there is the updater app file.

When there isn't installed the app at all on the device and I install the updater only (1), there is no problem at all.So the app is working and good.

I remove the previous app to be clean the system, and install the app to be update (2), what after installing starts the update process, but there is an error: corrupt package. That updater (1) what shows no error when I installed at the first step. I feel the problem here is also the same package name.
What is the normal mode to update an app?
 

rosippc64a

Active Member
Licensed User
Longtime User
Yes, I use regularly the Bridge and was restarting also.
That device by the way a very good device, I use my other program what can speak, browsing internet, manage inner and external storage (file read/write), etc., etc.
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Yes, I have no other problem only install the updater app from same app where the package name is equal.
 
Last edited:
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
My program looks like:
(Android 7.1.2, SdkVersion=25)
B4X:
 If phone.SdkVersion >= 24 Then      
     i.Initialize("android.intent.action.INSTALL_PACKAGE", GetFileUri(apkname))
     i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
Else
     i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(SharedFolder, apkname))
     i.SetType("application/vnd.android.package-archive")
End If
StartActivity(i)
Nothing special. But my getfileuri throw an exception in the return line.
B4X:
Private Sub GetFileUri (FileName As String) As Object
Dim FileProvider As JavaObject
Dim context As JavaObject
 context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(SharedFolder, FileName))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub
My file was here:
/data/user/0/b4a.selfupdater/files/shared/update.apk
But FileProvider.RunMethod() throw an exception:
error: Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/b4a.selfupdater/files/shared/update.apk
Who said to them, that my file is in "/data/data/..." ?!
I had to make some change in the manifest!
Original:
CreateResource(xml, provider_paths,
<external-files-path name="name" path="" />
Good:
CreateResource(xml, provider_paths,
<root-path name="root" path="." />

It works now. But I don't know, that is some special what valid for this android device (X96mini), or valid for other type devices also?
Thanks Erel for the quick reply!
 
Last edited:
Upvote 0
My program looks like:
(Android 7.1.2, SdkVersion=25)
B4X:
If phone.SdkVersion >= 24 Then     
     i.Initialize("android.intent.action.INSTALL_PACKAGE", GetFileUri(apkname))
     i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
Else
     i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(SharedFolder, apkname))
     i.SetType("application/vnd.android.package-archive")
End If
StartActivity(i)
Nothing special. But my getfileuri throw an exception in the return line.
B4X:
Private Sub GetFileUri (FileName As String) As Object
Dim FileProvider As JavaObject
Dim context As JavaObject
context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(SharedFolder, FileName))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub
My file was here:
/data/user/0/b4a.selfupdater/files/shared/update.apk
But FileProvider.RunMethod() throw an exception:
error: Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/b4a.selfupdater/files/shared/update.apk
Who said to them, that my file is in "/data/data/..." ?!
I had to make some change in the manifest!
Original:

Good:


It works now. But I don't know, that is some special what valid for this android device (X96mini), or valid for other type devices also?
Thanks Erel for the quick reply!
I have the same problem. I've copied the manifest, the fileprovider module, and I get this error:
Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/shared/myapp.apk
 
Upvote 0
Top