B4A Library AppUpdating - automate apps updating from a webserver

Status
Not open for further replies.
Important note: since all the changes made to the Android OS the original code is to be considered outdated. Thanks to @Yayou49 you may find at post#290 a version of the class usable on Android 6+ versions.

Note: version 1.25 breaks existing code so, please, read changelog in post #60 below.


Hi all,

this is my first contributing lib to this great NG.
How do I dare to publish such a low-grade stuff in an area where generally you may find real masterpieces of programming? Well, to be honest, I hope in your help to upgrade my work to a status of "ready-made solution" for those who prefer to run their own webservers where to publish apps.
Secondly, I was asked (both privately and publicly) to overcome my legitimate embarassment and go on with the publication. So, here we are: AppUpdating 1.18!

Note: any valid code fragment comes from some other thread, while all the bad stuff is entirely mine ;-)

Please find attached both the library as is (yes, it works out of the box) and its source code.

On a following post I'm gonna describe the lib in greater detail and show how to use it.

Umberto

AppUpdating version history

* version 1.30 (read notes on post #228)
  • compiled with okHttp 1.01 and okHttpUtils 2.20
  • removed files for version 1.25

* version 1.26 (read notes on post #84)
  • added property WebChangeLog to read optional app's version changelog data
  • better management of versioning in the info file
  • removed files for version 1.18 to avoid confusion (still available on request)
* version 1.25
* version 1.18
  • initial release
 

Attachments

  • AppUpdating_126_ex.zip
    28.3 KB · Views: 1,183
  • AppUpdating_126.zip
    11.3 KB · Views: 1,242
  • AppUpdating_126_src.zip
    10.8 KB · Views: 1,001
  • AppUpdating_130.zip
    11.4 KB · Views: 1,216
  • AppUpdating_130_src.zip
    15.7 KB · Views: 1,131
  • AppUpdating_130_ex.zip
    33.4 KB · Views: 1,339
Last edited:

techknight

Well-Known Member
Licensed User
Longtime User
Heads up. Appears with the latest version, each app I compiled would give me the appupdating OnStartCommand error. So I recompiled the library again, and this time I fixed my libs folder, and all is well.

So you gotta recompile the library again with the latest B4A.
 

techknight

Well-Known Member
Licensed User
Longtime User
I believe that what you're experiencing is due to the implicit nature of the intent used to wake-up an app compiled with AppUpdating lib.
Since the intent is implicit, every time an app is updated, each of your AppUpdating-based apps will be awakened, then is closed because the intent is not destined to it. Only the right app will execute code for restart.

You could verify the above adding a log in the starting intent section printing the extra data showing the name of the project which was updated. If I'm right, each of your apps should show the same name then terminate.

udg

Ah that makes sense, Once I studied the code a bit more, I figured that part out eventually. Now the question is, is there a way to make it more explicit? so it only wakes the intended App.

For S**ts and giggles I had a ton of apps installed with the library, once one awakens, eventually the whole tablet crashes when it runs out of memory due to the mass service launches. hahaha. Funny though ;-)

In case your wondering, its my Dev tab where I have dozens upon dozens of apps.
 

udg

Expert
Licensed User
Longtime User
Hi, fortunately yes, there's a way: it's called "broadcast explicit intents".
For some time now (months or even years) I expected to have enough time to fork this project in what I will have called AppUpdating2, based on explicit intents. Unfortunately I couldn't set those few hours needed to write and test it, but hope never dies..

Today it's my first day at work after some vacation time. Presumably I'll download and install the latest B4A release on the weekend. Then everything could follow!

udg
 

Emanuel Straub

Member
Licensed User
Longtime User
B4X:
Start download
updater_activity_resume (java line: 399)
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/Request$Builder;
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest.InitializeGet(OkHttpClientWrapper.java:392)
    at anywheresoftware.b4a.samples.httputils2.httpjob._download(httpjob.java:90)
    at com.baehr.launcher.updater._activity_resume(updater.java:399)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at com.baehr.launcher.updater.afterFirstLayout(updater.java:108)
    at com.baehr.launcher.updater.access$000(updater.java:17)
    at com.baehr.launcher.updater$WaitForLayout.run(updater.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6914)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.Request$Builder" on path: DexPathList[[zip file "/data/app/com.baehr.launcher-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 18 more
    Suppressed: java.lang.ClassNotFoundException: okhttp3.Request$Builder
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 19 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Application error found
starter_application_error (java line: 164)
java.lang.RuntimeException: Object should first be initialized (StringBuilder).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.keywords.StringBuilderWrapper.Append(StringBuilderWrapper.java:53)
    at com.baehr.launcher.starter._application_error(starter.java:164)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1044)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:994)
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleUncaughtException(ServiceHelper.java:135)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:212)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at com.baehr.launcher.updater.afterFirstLayout(updater.java:108)
    at com.baehr.launcher.updater.access$000(updater.java:17)
    at com.baehr.launcher.updater$WaitForLayout.run(updater.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6914)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
starter_application_error (java line: 164)
java.lang.RuntimeException: Object should first be initialized (StringBuilder).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.keywords.StringBuilderWrapper.Append(StringBuilderWrapper.java:53)
    at com.baehr.launcher.starter._application_error(starter.java:164)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1044)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:994)
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleUncaughtException(ServiceHelper.java:135)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:212)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at com.baehr.launcher.updater.afterFirstLayout(updater.java:108)
    at com.baehr.launcher.updater.access$000(updater.java:17)
    at com.baehr.launcher.updater$WaitForLayout.run(updater.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6914)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Hello,

B4A Version is 7.01.
Get an Error when starting the Download.
Changed the AppUpdating.xml like Erel said.

What can i do? Any ideas?
 

DonManfred

Expert
Licensed User
Longtime User
  • Like
Reactions: udg

udg

Expert
Licensed User
Longtime User
Hi @Emanuel Straub ,

as @DonManfred already explained, you need to recompile the lib from its source because the compiled versions in post#1 are from earlier realeases of B4A.
Source in post #243 it's ok since it's what Don himself used to help while I wasn't able to upgrade my copy of B4A due to a project scheduled for realease those days.

Sooner or later I'll have to update this project..

ps: Don, thanks as always.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I just found a Thread where someone is using appupdate on Android 7 (setting targetsdk to 24) and he run into problems based on Android 7 restrictions.

This may affect other appupdater users too i guess!?
See my answer in this thread about this. Note that i did not tried it as yet but based on the Fileprovider tutorial it should work like this i guess.
 

udg

Expert
Licensed User
Longtime User
Hi @DonManfred , thank you.

So what you suggests is to initially check for Android version and then eventually use hints from the Fileprovider tutorial to give access to the downloaded file?
Did I understand it correctly?

BTW, Android 8 seems to require explict intents..should I finally set some time for AppUpdating2 ? What do you think?

udg
 

DonManfred

Expert
Licensed User
Longtime User
should I finally set some time for AppUpdating2 ? What do you think?
Yes, definetively. It is a good time to clean up the Class and make it ready for B4A 7+ (incl wait for, sleep) i think.

Android 8 is coming, Android 7 is coming on more and more devices. even 6.
No problem when you set targetsdk to max 23.

But if you set it to 24 or higher then you need to respect the rules for this sdklevel.
The TO in the thread i posted finally decided to stay on 23 (i had a phone call with him). So the solution posted does not work for him.

But if someone decide to use 24 or higher then we must know how to do it on these SDKs.
I´m still investigating
 

udg

Expert
Licensed User
Longtime User
Android 8 is coming
While I'm still using an Android 4.4.4 device as my most updated one.. :)

I'm considering to publish a final release (1.40) for anybody to recompile with earlier versions of B4A, then a "deep cleanup" version(1.45) for B4A 7+ and finally start a new project (AppUpdating2) based on explicit intents. This way anyone should be happy (and we will gain some more time to investigate about the SDK24 problem..eheh).

udg
 

Harris

Expert
Licensed User
Longtime User
Hummmm,

My app downloads the new apk but when android attempts to install it, "App not installed" - with no reason why?

Worked well (always) in the past. I don't think it is appudating since it grabs the apk just fine.

package name has not changed. debug key was always used (unless the debug key has a new signature because I did update B4A since I last updated devices with an apk?

Using B4A 6.30

Thanks
 

Harris

Expert
Licensed User
Longtime User

Well, there you go... the correct answer...

This means that I will have to physically remove get each tablet from each vehicle to manually update them.
This means some very long days ahead catching trucks (they run around the clock).
Life's a bitch at times - so stop bitchin, suck it up and GET ON IT!
Just look at the bright side - at least I am not using some other crappy product (difficult / fails more than works) to create 100% working apps!

Thanks for the quick reply - missed that post as I searched the thread...
 

Harris

Expert
Licensed User
Longtime User
I think you can still use the old debug key as explained in pot #6 of the following thread without having to remove the old apps from the tablets:
https://www.b4x.com/android/forum/threads/conflicting-signature.71219/#post-452635
YES! I got the old debug file and applied it. Works as promised...
Saved me hours (perhaps days) of chasing trucks - waiting for them to arrive to update manually... (many better things to do like coding)

Thanks a bundle for pointing this out! True spirit of a community - helping each other out.
 
Status
Not open for further replies.
Top