Android Question *RESOLVED* Self upgrader fails with kit built by co-worker.

Lee Gillie CCP

Active Member
Licensed User
Longtime User
We use Microsoft Visual Source Safe to share various software development projects among staff. On all developer computers project folders appear on the same driver letter, and the same path. Further this shares the company APK signed key.

We do not have our APK in the Google store. Instead we have a WEB API support site that provides a download of our APK, which can be triggered in-app when a new version of our APK is available.

Our in-app self upgrader works like...
B4X:
public Sub CurrentAPKDownloaded( rmc As RemoteMethodCall )
    If Not( rmc.Success ) Then
        Msgbox("Unable to download most current version at this time.","Update Failed")
        Return
    End If

    Dim su As StringUtils
    Dim rsp As String = rmc.Response.SubString2(1,rmc.Response.Length-1)
    Dim bts() As Byte = su.DecodeBase64(rsp)
    Dim APKFileName As String = "EljayDelivery.apk"
    
    If File.Exists(File.DirDefaultExternal,APKFileName) Then
        File.Delete(File.DirDefaultExternal,APKFileName)
    End If

    Dim out As OutputStream
    out = File.OpenOutput(File.DirRootExternal,APKFileName,False)
    out.WriteBytes(bts, 0, bts.length)
    out.Close
    
    Dim i As Intent

    Dim apkPath As String = "file://" & File.Combine(File.DirRootExternal, APKFileName)
    
    Log("Installing from: " & apkPath)
    
    i.Initialize(i.ACTION_VIEW,apkPath )
    i.SetType("application/vnd.android.package-archive")

    StartActivity(i)
    
    ExitApplication
    
End Sub

Down to the question/problem. When I build subsequent new APK and push them, the tablets in the field do the upgrade just fine. When my co-worker pushes a kit, then Android will balk. The only recourse is to have the user manually uninstall the app, and reinstall from the new APK. If she then builds a new kit, it will auto-upgrade fine. But then next time I build an APK, the customer once again has to do the little fire drill.

I would think if we both target the same SDK and Android version, and that we both share the exact same signed key for building, then WHAT ELSE is Android looking at when it decides a new kit is not compatible enough for simplified upgrade?
 

Cableguy

Expert
Licensed User
Longtime User
Base Version maybe???
when you roll out an update, do you also update the version number on the software?
Upgrade will fail if the installed version is higher or equal to the "to be installed" version...
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Absolutely. It is how the auto-upgrade reports to the app that a new version is available. Without the version advance, it would not offer. For example I check in V3.1 to VSS. When my co-worker checks the project out to work on she advances from V3.1 to V3.2, and once the kit is built, she checks it back in. Next time I then bump it from V3.2 to V3.3 (etc.)
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User

I took a look at it, and it really doesn't change the APK produced by B4A that I could see. Perhaps I missed it? Remember we have pushed APKs built on our individual workstations to the WEB API server, and we have a way to update the APK in-app (the simple posted code), which it sounds like what this library is about.

I suspect our problem more so is that the APK produced at my workstation somehow mismatches the APK produced at my co-workers workstation so that updating (on a customer tablet in the field) is not allowed, and it requires the user to first uninstall our app, which introduces a number of manual steps for them that are not otherwise needed when version update APKs ARE compatible.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
are all necessary SDK the same version across workstations?

I suggested the lib as a troubleshoot solution, so that you could try it out with a test project, and see if it produced the same effect...or even compare them shoulder to shoulder.
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
It sure does. My plan is to do some testing with my co-worker, and ensure she is doing a release build, and also referencing the proper signing key. One hindrance to testing for us is that I don't know how to build an APK without actually having an install to a device, and we only have one test device. So I think I need to ask the customer for a second test device to try auto-upgrades on, and perhaps do as JordiCP suggested and monitor logs on the target device. I really don't yet know if Android will log why it wants a complete re-install if we reproduce the problem.

Does anyone have advice on starting the install intent and exiting the app at nearly the same time? Perhaps I should exit app delayed?
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Thanks to all for your help on this. As EXPECTED we were able to do alternating builds between workstations, bumping the version, release build, using the shared signed key, ensuring SDK and JDK identically selected, and Android allowed updates without first requiring a manual uninstall! (happy dance)

Next task is to roll ahead to Android 8 and the corresponding SDK. My guess is this one time tablets in the field will likely have to go through the lengthier process, but testing will tell. We have two tablets here today to test with, which is much simpler to work through, rather than having truck drivers do this over the phone in the field. But I'll know what to expect, and can have the office manager update tablets manually if needed, and then we should be good going forward.
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Next task is to roll ahead to Android 8 and the corresponding SDK. My guess is this one time tablets in the field will likely have to go through the lengthier process, but testing will tell. We have two tablets here today to test with, which is much simpler to work through, rather than having truck drivers do this over the phone in the field. But I'll know what to expect, and can have the office manager update tablets manually if needed, and then we should be good going forward.

I advanced to V8 sdk 26, and our app was still able to do the simple update without requiring uninstall! Cool... Now THATsUtImTalkinBout!
 
Upvote 0
Top