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
According to Android's pages about FileProvider

I guess you could use a subdir for one of the two (probabily AU will be a better candidate). "name" should be different too, since its a way to name that specific sub.

<external-files-path name="name" path="path" />
Represents files in the root of your app's external storage area.

<files-path name="name" path="path" />
Represents files in the files/ subdirectory of your app's internal storage area.

These child elements all use the same attributes:

name="name"
A URI path segment. To enforce security, this value hides the name of the subdirectory you're sharing. The subdirectory name for this value is contained in the path attribute.
path="path"
The subdirectory you're sharing. While the name attribute is a URI path segment, the path value is an actual subdirectory name. Notice that the value refers to a subdirectory, not an individual file or files. You can't share a single file by its file name, nor can you specify a subset of files using wildcards.
You must specify a child element of <paths> for each directory that contains files for which you want content URIs. For example, these XML elements specify two directories:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="my_images" path="images/"/>
<files-path name="my_docs" path="docs/"/>
</paths>

Eventually, you could try with something like:
B4X:
'for appupdating
CreateResource(xml, provider_paths,<files-path name="auname" path="shared/au" />)
 
Last edited:
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
udg thx I uderstand it better now but...

To change Appupdating I have to recompile the library, because the path is inside the compiled library
I have 0 experience with lib compiling for B4A and no time right now.....
I have checked and downloaded https://www.b4x.com/android/forum/t...mpiler-build-libraries-without-eclipse.29918/ but then I got stuck... but that is another issue...

So it seems to me that NB6 is better candidate for the change for my current situation.

So I tried:

1. try
In manifest
B4X:
'for NB6 custom sounds
CreateResource(xml, provider_paths,<external-files-path name="name2" path="shared2" />)

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

in notification creation
B4X:
    Dim folder As String = rp.GetSafeDirDefaultExternal("shared2")
    File.Copy(File.DirAssets, FileName, folder, FileName)

B4X:
Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/cz.esol.edispecink/files/shared2/novaaukce.mp3

2. try
In manifest
B4X:
'for NB6 custom sounds
CreateResource(xml, provider_paths,<external-files-path name="name2" path="shared/nb" />)

in notification creation
B4X:
    Dim folder As String = rp.GetSafeDirDefaultExternal("shared/nb")
    File.Copy(File.DirAssets, FileName, folder, FileName)

B4X:
Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/cz.esol.edispecink/files/shared/nb/novaaukce.mp3
 
Upvote 0

udg

Expert
Licensed User
Longtime User
To change Appupdating I have to recompile the library, because the path is inside the compiled library
The library source is plain B4A code, you don't need any other tool than the IDE itself.
Just open the lib source, modify it, then go to Project/Compile to Library.
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
cool didnt know that but ...

I did change
B4X:
    If p.SdkVersion >= 24 Or File.ExternalWritable = False Then
        UseFileProvider = True
        SharedFolder = File.Combine(File.DirInternal, "shared/au")
        File.MakeDir("", SharedFolder)
    Else
        UseFileProvider = False
        SharedFolder = rp.GetSafeDirDefaultExternal("shared/au")
    End If

and compiled the library - change the lib in project for new one and change the manifest
B4X:
'Appupdating
CreateResource(xml, provider_paths,<files-path name="auname" path="shared/au" />)

RUN and error

So I reverse the changes, recompiled the lib and tryied and the same error again

B4X:
B4A Version: 9.00
Parsing code.    (0.15s)
Building folders structure.    (0.06s)
Compiling code.    (0.24s)
Compiling layouts code.    (0.04s)
Organizing libraries.    (0.00s)
Generating R file.    (0.00s)
Compiling debugger engine code.    (0.04s)
Compiling generated Java code.    (0.05s)
Convert byte code - optimized dex.    Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$attr;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$color;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$dimen;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$drawable;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$id;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$integer;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$layout;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/compat/R$string;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:696)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
    at com.android.dx.command.dexer.Main.runDx(Main.java:293)
    at com.android.dx.command.dexer.Main.main(Main.java:249)
    at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:688)
    ... 4 more

What went wrong ?

If I exchange the lib for the original one the project run without error
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I'm not good at reading errors, but
Convert byte code - optimized dex. Error
reminds me of a few threads about a value to increase in B4A ini file. Please search for "optimized dex" or similar and follow directions about what I believe should be a solution for an error like yours.
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
Readed and tried all, didnt help.
So I started over, downloaded source of the library / restart everything / clean my project / recompile lib and it works : )

Sort of....
With original lib and comented NB6 AppUpdating works perfectly

with my lib it get stuck
B4X:
---- AppUpdating.UpdateApk
sending message to waiting queue of uninitialized activity (submitjob)

Changes I did
MANIFEST
B4X:
CreateResource(xml, provider_paths,<files-path name="auname" path="shared/au" />)

in the AppUpdating lib
B4X:
    If p.SdkVersion >= 24 Or File.ExternalWritable = False Then
        UseFileProvider = True
        SharedFolder = File.Combine(File.DirInternal, "shared/au")
        File.MakeDir("", SharedFolder)
    Else
        UseFileProvider = False
        SharedFolder = rp.GetSafeDirDefaultExternal("shared/au")
    End If
 
Upvote 0

udg

Expert
Licensed User
Longtime User
sending message to waiting queue of uninitialized activity (submitjob)
Do you eventually start AU from activity SubmitJob then move to a different activity?
I'm not sure, but it seems that the lib is trying to call back an activity (submitjob) that is not currently active.
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
No I dont thing so, I thought that "submitjob" is part of your lib.
My app have only Main activity rest is in services, codemodules etc.

When I change the lib to the original / restart IDE / rerun app it works
with my version I got this error

If I search for submitjob in AU and in my App there is no trace of it...
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
+ just found out that if this line is in manifest then NB6 start crashing.....

So I am not sure if this is the right way to go

B4X:
CreateResource(xml, provider_paths,<files-path name="auname" path="shared/au" />)

B4X:
Error occurred on line: 153 (Repo)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at cz.esol.edispecink.repo._createfileprovideruri(repo.java:308)
    at cz.esol.edispecink.repo._notification(repo.java:400)
    at cz.esol.edispecink.repo._novaprirazena(repo.java:559)
    at cz.esol.edispecink.tracker$ResumableSub_CheckPrirazene.resume(tracker.java:2008)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6863)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/cz.esol.edispecink/files/shared/novazakazka.mp3
    at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:739)
    at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:418)
    ... 25 more
*** Service (starter) Create ***
** Service (starter) Start **
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I don't know the solution, but maybe I figured out what's implied in the problem.
Originally (in AU example code) the relevant part of the Manifest looked like:
B4X:
' Starting from Android 7 (API 24) we pass a file uri using a FileProvider
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
I highlighted in bold what should be the key that links those two sections.
So, adding NB6 (I never used it to date), you should find a way to "insert" a reference to the other directory in the above scheme. I mean, adding "
external-files-path name=" at the same time "files-path" is added.

I hope @Erel (or anybody else that knows how to do it) will help us with this.

Edit: and here it should be the solution!

In your case, it should be:
B4X:
CreateResource(xml, provider_paths,
<paths>
   <files-path name="name1" path="shared/au" />
   <external-files-path name="name" path="shared" />
</paths>
)
 
Last edited:
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
yep that help : )
so now I have 2 defined path and NB6 is working, app is not crashing but ... : )

still stuck here when using changed lib

B4X:
---- AppUpdating.UpdateApk
sending message to waiting queue of uninitialized activity (submitjob)
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
Tryied to run your demo of AU with my changed lib.

in the lib I only changed path here
B4X:
If p.SdkVersion >= 24 Or File.ExternalWritable = False Then
        UseFileProvider = True
        SharedFolder = File.Combine(File.DirInternal, "shared/au")
        File.MakeDir("", SharedFolder)
    Else
        UseFileProvider = False
        SharedFolder = rp.GetSafeDirDefaultExternal("shared/au")
    End If

and got the same problem
B4X:
sending message to waiting queue of uninitialized activity (submitjob)

I think that the app have a problem accesing or finding the resource and its just waiting forever...
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Or can u please try to change the path and recompile the library in 9.0 if you get the same result ?
I'll try it today and give you some feedback.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Tomas,
I did check with my copy of AU demo and lib and found your same error. Then something led me to check the lib version..and it was still 2.02. For some reason I was convinced to have updated it some time ago. Please refer to this post and the few preceding ones to build yourself a functioning lib. Sorry, for the confusion.
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
Went there and walked through it, and I am confused ... : ( there are lot of steps some of which I dont understand fully.
exactly how many is few preceding 2 - 10 ? : ))

any plans of releasing updated version source code ? : )
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I'm working on it ..
Putting together class, service and demo code seems to work correctly (strangely enogh, I've to disable wi-fi to have it work 100%).
Having demo code to call the lib shows the same error you reported (which seems related to OkHttpUtils2 when used to download a file)
All that on my old 4.4 Android device since I don't have an 8+ one.

B4A 9.00

Update: it seems that the problem is due to an incompatibility between b4xlibs and traditional libs, so I have to build a b4xlib from my new code. Stay tuned...
 
Last edited:
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Tomas,
please try the attached files. They're "temporary" since I can't anticipate if they will work for you "as is" or we will need small amendments.

AppUpdating.b4xlib is the new version of AU lib in the form of an b4xlib as requested by the internal use of OkHttpUtils2.
AUDemo204.zip is the source of my original demo where the Manifest was adapted to make it work with the lib in its current form
Note that I set the verbose var to True (in the newinst2 service itself) in order to better understand what happens

Last point. Disinstall your current demo app before compiling and executing the attached one. This will make for a cleaner playground and take us in the position to better understand eventual new problems.

udg
 

Attachments

  • AppUpdating.b4xlib
    7.1 KB · Views: 548
  • AUDemo204.zip
    31.7 KB · Views: 530
Upvote 0
Top