Mar 16 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Mar 16 | 7:35 PM |
Andrew W. | has entered the room |
Andrew W. |
hello
|
Mark M. |
hello, Andrew!
|
Mark M. |
how can I help you today?
|
Mark M. |
(assuming the question isn't "how can I fix my bracket, as I had Minnesota in the Final Four?")
|
Andrew W. |
Well, I've got a problem with adapting my app to work with Android N.
|
Mar 16 | 7:40 PM |
Andrew W. |
What's the best way to do this, send the text or the file?
|
Mark M. |
what text and what file are you referring to?
|
Andrew W. |
lmfao about Minnesota.
|
Mark M. |
again, what text and what file are you referring to?
|
Andrew W. | |
Mar 16 | 7:45 PM |
Andrew W. |
This won't work on anything above API 23, and I'm wondering if I'll be able to keep it working in Android N without using any additional permissions.
|
Andrew W. |
Pretty sure the trouble starts at instChromium()
|
Mark M. |
that won't work on Android 7.0+
|
Mark M. |
due to the FileUriExposedException that it will throw
|
Mark M. |
if your targetSdkVersion is 24+
|
Mark M. |
also, you should not be deleting the APK right away, as the installer will not have had a chance to use it yet (though that's a problem on all versions of Android, not unique to 7.0+)
|
Mark M. |
what is your targetSdkVersion? and what are your exact symptoms?
|
Mar 16 | 7:50 PM |
Andrew W. |
Target sdk is 25 and symptoms are 'failed to find configured root that contains /data/data/com.anddevw.getchromium/files/getChromium/chrome-android/apks/ChromePublic.apk'
|
Mark M. |
oh, wait, this file is on internal storage
|
Mark M. |
that should fail on all versions of Android, as the app installer does not have access to your app's portion of internal storage
|
Mark M. |
your error is indicative of FileProvider, but you are not using that
|
Mark M. |
are you sure that I am working with the correct file?
|
Andrew W. |
the error is from the modified version of the file i just sent you.
|
Mark M. |
ah, OK
|
Mark M. |
your FileProvider metadata would need a <files-path> element
|
Andrew W. |
so to get where i need to be from what i sent you, what would you recommend?
|
Mark M. |
well, FileProvider
|
Mark M. |
you'll need that on Android 7.0+ for ACTION_INSTALL_PACKAGE
|
Mark M. |
however, you *can't* use that on older versions for ACTION_INSTALL_PACKAGE, because Google ignored my bug report for years
|
Mark M. |
so, you'll need to do a Build.VERSION.SDK_INT check to determine which flavor of Uri to create
|
Mark M. |
then, if you fix the FileProvider metadata XML to eliminate that error, you should be in better shape
|
Andrew W. | |
Mark M. |
use <files-path>, not <external-path>
|
Mar 16 | 7:55 PM |
Andrew W. |
this is the one currently giving me the error i had mentioned
|
Mark M. |
and either eliminate the path attribute or try cutting it back to "getChromium/apks"
|
Andrew W. |
aha
|
chike m. | has entered the room |
chike m. |
Hi
|
Mark M. |
Andrew: let me take a question from chike, and I will be back with you in a bit
|
Andrew W. |
how's it going
|
Mark M. |
chike: your turn! do you have a question?
|
Andrew W. |
no problem
|
chike m. |
yes, concerning the MVP pattern.
|
chike m. |
what are your thoughts on retaining the presenter?
|
chike m. |
when there is a configuration change
|
Mark M. |
I do not claim to be an expert on MVP
|
Mark M. |
and so I cannot really answer your question, sorry!
|
chike m. |
oh!
|
Mark M. |
my understanding is that retaining the presenter is a typical approach for MVP with Android, but, again, GUI architecture patterns are not my area of expertise
|
chike m. |
ok Mark. Thanks
|
Mark M. |
since I could not help on that one... do you have another, non-MVP question?
|
Mar 16 | 8:00 PM |
chike m. |
no.
|
Mark M. |
OK, again, sorry
|
Mark M. |
I will switch back to Andrew -- if you come up with another question, let me know
|
chike m. |
alright
|
Mark M. |
Andrew: back to you! do you have another question?
|
chike m. | has left the room |
Mark M. |
Andrew: do you have another question?
|
Andrew W. |
possibly...testing the changes
|
Mark M. |
OK
|
Mar 16 | 8:05 PM |
Andrew W. |
so it seems to be almost there, but i'm now getting 'Package installer keeps stopping'
|
Mark M. |
make sure you call addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) on the Intent before calling startActivity()
|
Mark M. |
otherwise, the installer won't have rights to read the APK given the Uri
|
Andrew W. |
View paste
(1 more line)
|
Andrew W. |
skipped the first line: private void instChromium () {
|
Mark M. |
don't call setFlags() twice in succession
|
Mark M. |
as the second one wipes out the first one
|
Mark M. |
either use addFlags(), or use a single setFlags() call with a | operator
|
Andrew W. |
ok
|
Mar 16 | 8:10 PM |
Andrew W. |
now it's giving 'There was a problem parsing the package.'
|
Andrew W. |
View paste
|
Mark M. |
OK, the change in message indicates that the Uri is working, at least sort of
|
Mark M. |
did you get rid of the deleteAPk() call?
|
Mark M. |
because it's unrealistic to expect the installer to be able to install from a deleted file... :-)
|
Andrew W. |
that just gets rid of the second apk they package together w the Chromium apk in the zip file. it never deletes the installed apk
|
Mar 16 | 8:15 PM |
Mark M. |
oh, right, that's a different file -- sorry, I missed that
|
Mark M. |
you might temporarily drop your targetSdkVersion below 24, use Uri.fromFile(), and see if things work
|
Mark M. |
if you get the same error, then there's an issue with the APK itself that you are trying to install
|
Mark M. |
if it works, then there's something still amiss with the FileProvider setup, though I'm not sure what
|
Andrew W. |
will Google still allow it for installs on people running N?
|
Mark M. |
sure, for older apps
|
Andrew W. |
View paste
|
Mark M. |
that manifest entry looks fine
|
Andrew W. |
and provider_paths.xml
|
Andrew W. |
View paste
|
Mark M. |
you have two FileProviders?
|
Mark M. |
that may be a problem
|
Andrew W. |
file_paths.xml and provider_paths.xml
|
Mark M. |
those are both manifest entries
|
Mark M. |
for the same component, with different authorities
|
Andrew W. |
aha
|
Mark M. |
if you have both of those manifest entries in the same app's manifest... I'm surprised that it compiles
|
Mar 16 | 8:20 PM |
Andrew W. |
it would be nice if it didn't.
|
Andrew W. |
so should i cut one or both of the entries?
|
Mark M. |
get rid of one, whichever one is the one that you are not using
|
Mark M. |
your Java code is referring to one of those authorities
|
Mark M. |
keep the <provider> for that authority
|
Mark M. |
comment out the <provider> for the other authority
|
Mark M. |
and see if that helps
|
Mark M. |
(meanwhile, I've made myself a note to try reproducing your dual-<provider> setup, as if that compiles and installs, that's seriously messed up)
|
Andrew W. |
you are possibly the only person anywhere who knows anything about this.
|
Mark M. |
oh, I doubt that
|
Mark M. |
I can name at least one other person outside of Google, as I worked on an issue about ACTION_INSTALL_PACKAGE not working at all for N last summer
|
Mar 16 | 8:25 PM |
Andrew W. |
well, so two, but there's not a lot of info floating around
|
Mark M. |
yeah, well, there's that
|
Mark M. |
apps installing apps is a bit of a niche area
|
Andrew W. | |
Andrew W. |
sorry, that was an accident
|
Andrew W. |
in general, what does a problem parsing the package mean?
|
Mar 16 | 8:30 PM |
Mark M. |
that's kinda a catch-all error
|
Mark M. |
usually, I interpret it as it was able to at least read part of the APK, but it thinks that the APK is malformed
|
Andrew W. |
interesting. well, thanks a million, Mark. i'll be renewing my subscription because this a tremendous help.
|
Mark M. |
thanks!
|
Mark M. |
you might try writing a test case to confirm that you can read from your own FileProvider, and that the results match
|
Mark M. |
I know FileProvider works, or at least worked, with ACTION_INSTALL_PACKAGE
|
Andrew W. |
yeah, it used to work.
|
Andrew W. |
i'll try writing the test case
|
Mark M. |
alas, that's a wrap for today's chat
|
Mark M. |
the transcript will go up on https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Saturday at 4pm US Eastern
|
Andrew W. |
have a good one
|
Mark M. |
you too!
|
Andrew W. | has left the room |
Mark M. | turned off guest access |