B4A Library AppUpdating - automate apps updating from a webserver

Status
Not open for further replies.

MarcoRome

Expert
Licensed User
Longtime User
Hi Marco,
the version currently published is compiled with the Httputils2's release available BEFORE okHttp introduction.
I'm planning a newer version as soon as I have some spare time.
Thank you for your interest in AppUpdating lib.

udg

Mhh.. ok after different try this is result.

1.If you compile with this combination ( okHttp + HttpUtils 2.10 Library ) you havent error.
But when start App the value apkupdt.ReadWebVN return "" ( if you see in debug you have: sending message to waiting queue of uninitialized activity (submitjob))

2. If you take AppUpdateExample compile without problem but when start you have this error ( if you have new library HttpUtils 2.10 in folder library) :
B4X:
Installing file.
Installing file.
PackageAdded: package:b4a.example.appupdate
maininitializeProcessGlobals (java line: 609)
java.lang.NoClassDefFoundError: anywheresoftware.b4h.okhttp.OkHttpClientWrapper
    at anywheresoftware.b4a.samples.httputils2.httputils2service._process_globals(httputils2service.java:144)
    at b4a.example.appupdate.main.initializeProcessGlobals(main.java:609)
    at b4a.example.appupdate.main.afterFirstLayout(main.java:98)
    at b4a.example.appupdate.main.access$000(main.java:17)
    at b4a.example.appupdate.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5692)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)

So with new library okHttp + HttpUtils 2.10 dont work
 

MarcoRome

Expert
Licensed User
Longtime User
Ok. Resolve i recompile the library with the new version HttpUtils 2.10 + okHttp.
Tried and tested.
You no longer need to eliminate from the libraries as HttpUtils2 see in picture.



Dont forget this combination ( okHttp + HttpUtils 2.10 Library ).

In attachment Rel. 1.28 ( AppUpdating1.28-okHttp.zip )

Thank's again for this library ( the library 1.28 is only ricompilate, nothing in source is modified, so the source 1.26 present in 1# is same source )
 

Attachments

  • AppUpdating1.28-okHttp.zip
    12 KB · Views: 485
Last edited:

nibbo

Active Member
Licensed User
Longtime User
Just to confirm that I have tried the latest version (1.28) and it works perfectly.
Thanks udg for this lib.
 

Harris

Expert
Licensed User
Longtime User
Can I use the code module source without having to use the lib for AppUpdating?
I have modified Http2Utils.bas source to handle an error that sometimes occurs in my app - so I cannot use the lib (un-modified).

Sometimes for some unknown reason, the JobDone fails after I have transferred records to server for insertion. They get posted on server but my app cannot mark these as SENT. So next attempt will include already posted records and a Key Violation results... The mod below corrects this with the FixDupe method where the response_err is the primary key of the record that needs to be updated to SENT...

B4X:
Sub CompleteJob(TaskId As Int, success As Boolean, errorMessage As String)
    Dim job As HttpJob
    job = TaskIdToJob.Get(TaskId)
    TaskIdToJob.Remove(TaskId)
    job.success = success
    job.errorMessage = errorMessage
    job.Complete(TaskId)

' my mod....

    If job.success = False Then
       Log(" Job Name from HTTP: "&job.JobName&"  Tag: "&job.Tag&" err: "&errorMessage)
       If job.Tag = "AddLogs" Then
          Log("Response error message: "&resposne_err)
          CallSubDelayed2(  LogServmod,"FixDupe",resposne_err)
       End If
    Else
         ' ToastMessageShow(" Job was completed: "&TaskId,False)    

    End If 
     
End Sub
 

udg

Expert
Licensed User
Longtime User
Hi Harris,

you can use any part of the lib's code to best suit your needs. That's why I published the source code!

udg
 

Harris

Expert
Licensed User
Longtime User
Awesome!

I am sure it will go smoothly after all the effort you, with others help, put into it.
This will be a great way to keep the devices up to date without user interaction AND without requiring Play Store.

In fact, with my newest contract, internet nor cell exist! Remote Alaska where even WiFi using Access Points shall be challenging...
Have no fear - B4A and Android are here!


Thanks
 

BarryW

Active Member
Licensed User
Longtime User

Can install new apk version in silent mode (not manuall install after download). Tnx
 

udg

Expert
Licensed User
Longtime User
Hi Barry,
unfortunately, AFAIK, silent operation is possible only on rooted devices.

udg
 

Harris

Expert
Licensed User
Longtime User
Just finished implementing using source code.

Works GREAT ! ! ! Automatically updating the apk is HUGE!!! This is awesome....

Now all I have to do it create a record with app version and a report to ensure all devices are using the latest version - and NOT pressing the cancel button when asked to install...

Thanks so much for this. I shall donate soon...
 
Reactions: udg

udg

Expert
Licensed User
Longtime User
Hi BarryW,

I generally use 000webhost to experiment a bit with site-related stuff. Last year I also bought a Raspberry box and since then most in-house testing is done on it.

udg
 

Harris

Expert
Licensed User
Longtime User
Want your own server for cheap?

Check out:
https://www.weloveservers.net/?utm_...m=email&utm_campaign=name_super_fast_vps_sale

I have seven of these servers, for 19 bucks a year per each!


This one is for 6 bucks per year... (six bucks - now that's just stupid....)

10 GB Disk Space Storage
1TB Bandwidth (100Mbps)
128MB Guaranteed RAM + 256 MB vSwap
1 IPv4 Address
SolusVM Access
Full Root Access
Choice of Linux OS's
Self Managed
OpenVZ Virtualization Technology

Locations: Los Angeles, Dallas, Buffalo
Powered by: 4x Enterprise-grade SATA Drives (Hardware RAID 10)

Warwound recommenced these guys and their service is pretty good...
Having a server has taught me alot about Linux, web, php and so much more...

PM me your email and I will forward the latest offering from WeLoveServers...
 
Last edited:

nibbo

Active Member
Licensed User
Longtime User
OK, I thought this was working but it is only doing so for me.
When the users attempt to install the update they get 'Error: Not Found'
The apk is there and it must have access as the ReadWebVN returned the latest version which is in the same server directory.
Both the txt and apk files have full control permissions. The MIME type is set u OK.

Any ideas?
 

udg

Expert
Licensed User
Longtime User
Hi Nibbo,

a first test could be to try the download directly from the browser.
This is useful to discover eventual problems with filename not exactly matching or permissions/mime types.

Since ReadWebVN returns the correct values, that means it can read the txt definition file. Next step should be call DownloadApk with same string but the extension changed from txt to apk. Do you show/log any error message?

If you want me to have a look at your code, PM me at any time.

udg
 

nibbo

Active Member
Licensed User
Longtime User

Thanks for the tip... I typed in the URL to the apk in the tablet's browser and was able to download the file OK.
The problem was the website is SSL and I had missed 's' from the https part of the URL. I think it is OK now.
Thanks for your time.
 

Harris

Expert
Licensed User
Longtime User
Just donated to your excellent efforts.
Keep up the great work!

Thanks
 

udg

Expert
Licensed User
Longtime User
Hi Harris,
thank you very much. A few donations more like yours and I'll have a ticket paid to Alaska. Is it a wonderful place to visit, right? A lot of years ago I had a flight-stop in Anchorage and so had the opportunity to spend a few hours there.
Glad to hear that your RD project is going well.

Umberto
 

Harris

Expert
Licensed User
Longtime User
Made it to Red Dog today. Flew from Anchorage on a 737-400. Tech Cominco charters with Alaskan Airways each Wed and Sat. Plane is always full. -5C at 71.5 latitude in the arctic - not bad really. Some snow in forecast.
Quite a big operation built on the permafrost. Everything is on steel piles driven deep into the ground. Concrete costs $1000 per yard (at this very remote location).

Over the next week I shall get much accomplished.
Need to create Geozones in critical areas on the haul road, establish wifi AP locations, install a couple test units in trucks and take runs with driver's to get their interpretation of what is being implemented for the fuel, ore (lead / zinc) and freight hauls - then adjust my activities to what REALLY goes on as opposed to what I have been told to date...

This is sent by the sat connection they installed in the camp. Slow but gets the job done... I can even connect to my VPS website (tripinspect.com) to send an receive test data we shall create (since the local server is not installed here yet).

My gain a few pounds since meals are a full buffet for breakfast, lunch and dinner. All you can eat of great healthy food - for free! These guys at RD have it good... Average low end wage is 100 G per year US. Work shifts are 4 week in - 2 week out ( or 2 in - 1 out ).

Wish me luck...

Thanks
 
Reactions: udg

opus

Active Member
Licensed User
Longtime User
Hi, thanks for this good lib., it took me just a couple of houres to make it work.
However, I'm running into a problem, how the check for webserver not online or folder/files not on server WITHOUT showing an error message.
So far I'm using the .UpdateAPK method. When running the code without the webserver being online, an error message is shown even before I can check the .Status which will be -100 by then.
Edit:
Found the reason! The error message is a ToastMessage from the JobDone in the Lib. So I would only need this ToastMessage commented out. But, I've never compiled a Lib...Searching.
.... If everything in live would be that easy. Found everything, even the newly compiled lib-files. Problem solved!
 
Last edited:
Reactions: udg

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

Its a great lib. Thanks for this wonderful lib.

I just came across a bug in this lib. I am not sure whether this is a bug or is it something wrong in the way that I am doing.

If I call ApkUpdt.CurVN , it will never reach the status ApkUpdt.OK_CURVER in the Sub AppUpdateCheck_UpdateComplete, instead the app goes into an infinite loop.

The above call ie ApkUpdt.CurVN is supposed to return the Current version of the Apk running on the phone

Rest of the methods in this lib are working fine for me.

By the way, a suggestion from my side. When we call the ApkUpdt.DownloadApk / ApkUpdt.UpdateApk instead of showing a png/jpg picture saying that the Apk is downloading, it would be better if you can show the actual download progress using some progress bar, so that the user knows that the download is happening and the user is aware of the actual progress of the download process.

Regards
Anser
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…