Android Question AppUpdate vs NB6 conflict

Tomas Petrus

Active Member
Licensed User
Longtime User
In my app recently met NB6 and AppUpdate

These both thing need to be in manifest but one break the another
B4X:
'for custom sounds in NB6
CreateResource(xml, provider_paths,<external-files-path name="name" path="shared" />)

'for appupdating
CreateResource(xml, provider_paths,<files-path name="name" path="shared" />)

Any ideas how to make it work together ?
tryied to search for shared and change it for example in one module to shared2, but it didnt work..
Maybe I didnt find the right spot or maybe there is another aproach ?

any ideas ?
 

udg

Expert
Licensed User
Longtime User
Glad to hear that is now working for you.
Just one question: did you use it as is (so having NB6 to name1/shared1) or did you alter it as we originally planned (i.e. modify the path for AU keeping that for NB6)?
I tested on 4.4 and in a few days I'll test on Android 7. If you or anybody else could test it on Android 8 we then could confirm current code and publish it as an official update of the lib.

udg
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
just one little change is now needed when implementing NB6 by the tutorial or examples

B4X:
'Dim folder As String = rp.GetSafeDirDefaultExternal("shared")
Dim folder As String = rp.GetSafeDirDefaultExternal("shared1")
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
recently I sometimes get new error
I am not sure what it means and even if it is related, it started occured today

B4X:
repo_login (java line: 99)
java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(java.lang.Object)' on a null object reference
    at b4a.example3.keyvaluestore._put(keyvaluestore.java:395)
    at cz.esol.edispecink.repo._login(repo.java:99)
    at cz.esol.edispecink.main$ResumableSub_Prihlasit.resume(main.java:9843)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:190)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1179)
    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:6494)
    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)
java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(java.lang.Object)' on a null object reference
Log reader error: java.io.InterruptedIOException: read interrupted
-1 received
writer error
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2034)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2068)
    at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:387)
    at anywheresoftware.b4a.remotelogger.Connector$Writer.run(Connector.java:160)
    at java.lang.Thread.run(Thread.java:764)
Starting remote logger. Port: 4000
After accept
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Fantastic. Thank you so much.
 
Upvote 0

labcold

Member
Licensed User
Longtime User
HI, I'm having trouble getting this to work correctly.
I am using Android 7.1.1 and B4A v9.
I am only using the examples at the moment not my own APK.

All seems to work ok until the install when I get the error "App not installed ... the package conflicts with an existing package by the same name".
Obviously it does, and should, have the same name as its an upgrade.

I tried the 204 solution above as well as the original but all do the same thing.
I've tried different private keys etc. I have read through the various posts to date and I cant see anything that I have missed.
If I change the package name then it will load the new version from the internet and install it but after that the name conflict happens again.
I have also tried this on a couple of other devices (Andr 8) and have the same issue.

sorry if I have missed something obvious but I could really do with your help on this.
Harry
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Harry,
I guess the problem you're experiencing derives from our different signing keys. Read here for a deeper explanation.
How to solve in order to test the lib?
First, uninstall any copy of AUExample2 from your device then downloand and install my package from my site.
Run it (not from the IDE, just run the apk). It should check the server, find itself as a newer copy and install again.
I'm not 100% sure this will work.

Another option is to compile and publish a copy of AUExample2 to a site of yours and download form there.
 
Upvote 0

labcold

Member
Licensed User
Longtime User
Another option is to compile and publish a copy of AUExample2 to a site of yours and download form there.

Hi Thanks for the reply!
I'm sory but I am still having problems on the last stage.
As you suggested I modified rebuilt the example APK and loaded it onto my public server.
All the functions work correctly, show existing ver, get web version, compare, download ....
BUT when I do the install step I get asked for permission - I agree then it just fails.
I do not get any debug info (using bridgelogger for runtime debug) just Android screen saying
APK not installed.
here is the debug info.....
Logger connected to: 29S
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
SDK#: 27 - UseFP: true - SharedFolder: /data/user/0/b4a.example.appupdate2/files/shared
** Activity (main) Resume **
---- AppUpdating.ReadCurVN
Current Version: 2.04
UpdateComplete - time: 11:08:48
---- AppUpdating.ReadWebVN
IsValidComplete start
before
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
after
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: 11:08:50
---- AppUpdating.DownloadApk
Donload ok? true
Copy2 (saving) ok? TRUE
new apk version downloaded and ready to install
UpdateComplete - time: 11:10:34
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
---- AppUpdating.InstallApk
user asked to install new apk
UpdateComplete - time: 11:12:27
** Activity (main) Pause, UserClosed = false **
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Harry,
as you observed everything seems to work until the last step. The OS wakes the service recognizing a new version of the app, the service asks for installation and the OS shows the user a request for permission. So, the failing seems to happen in the OS realm, when the user effectively allows permission to install.
Can you try on a different device?
I ask because it could be some particular setting on your phone that keeps the OS from completing its task.
If not, maybe you can try again with the debug filter removed (Logs tab). I'm not very good at reading that kind of logs but we can surely count on the Community ed Erel himself to spot eventual problems.
 
Upvote 0

labcold

Member
Licensed User
Longtime User
Thanks again for replying so quickly - much appreciated :D
OK so I have the same problem on both Android 7.1.1 and Android 8.1.0 on two different platforms.
I agree that there is something stopping the install but I cannot see what it is as there isnt any useful information in the logs as far as I can see. It doesnt matter if I run with or without debug enabled. I can see the files in the file system but the only way to get it to install is to remove the first app manually and then install the new version. then of course it wont update again from there. This all defeats the purpose of upgrades in any case.
When I first had this problem it was reporting the error cant install because of signatures. So having sorted that as discussed earlier, it responded with error conflicting name, from my own server copy it responds only with App not installed.
I will do another run tomorrow and capture all the log information and then post that here.
Such a shame to be so close yet so far away - thus was it ever so :D
Harry
 
Upvote 0

labcold

Member
Licensed User
Longtime User
OK so I have managed to get this to work !!!
Now I cannot truly explain why which disturbs me greatly.
This is what I did....
I firstly copied the library source into the project rather than using the external library.
This actually made no difference and it still failed at the install point.
Then I changed "tmp.apk" to "updated.apk" and all of a sudden it loads :O

Interestingly Erel's example on loading an APK from the assets directory did work OK on both my devices, and the reason I changed the filename was to use the download part which worked well and then try to copy it locally then update.
But I never got any further than changing the filename and recompiling to see if the file was correctly located in the file system.
I will do some more testing and check that this is a consistent 'fix' on a new device, but I don't feel this is really the issue which as I say really worries me.
Anyway thanks for taking time to help its much appreciated and I hope this works from now on :)
Harry
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Thank you for your update.
The main reason I published the lib source code since almost the beginning is that letting everyone to attack new or existing problems will make the lib stronger.
 
Upvote 0
Top