Problems installing Android security provider

(ndelic) #1

I’m trying to install Google Play Services security provider but I can’t make it work.
It compiles fine but I get java.lang.IllegalStateException: Unable to get current module APK info in ModuleManager created with non-module Context when I run the app. I don’t have a clue as to why this happens, I reference that contains the ProviderInstaller class and put <meta-data android:name="" android:value="@integer/google_play_services_version" /> in the manifest. I couldn’t find any explanation for this anywhere, maybe I’m missing some other references?

Using Fire .2351.

Test project attached. (235.5 KB)

(ndelic) #2

I made it work in Android Studio, but I had to import Google Play Services (GPS) by excluding because GPS apparently references one of older versions of appcompat library. The dependencies part of build.gradle looks like this:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')  //  These three...
    implementation ''  //  ... are added...
    implementation ''  //  ... by AndroidStudio
    implementation ("") {  //  Added by me
        exclude group: ''

Can excluding a group also be done in Fire?

(marc hoffman) #3

Not currently. What exactly does this do?

(ndelic) #4

AFAIK adds (GPS) gradle reference without adding dependency to GPS because a different version of reference is already added to the main project/app. This is the only way to make GPS ProviderInstaller.installIfNeeded work, which, in my case, is needed to make embedded NanoHttpd websockets server work via SSL.

(marc hoffman) #5

Ok. I’ll have a look at that. If you can send me a simple test case project that shows this issue and has all the references that would make this work if the exclude was working, that’ll help me narrow this down.

(marc hoffman) #6

Oh, actually, try adding <ExcludeGradleDependency Include=""/> to your project, that might already do the trick…

(ndelic) #7

Please correct me if I’m wrong, but wouldn’t that exclude dependency for the whole project? It only has to be excluded for GPS, I need for the main project.

Test projects coming up shortly.

(marc hoffman) #8

This only affects indirect dependencies. Your direct reference to the package would still work.

(ndelic) #9

Ok, I’ll try that before creating test projects.

(marc hoffman) #10

If that does not work, also try using the full package name of the offending package (e.g. <ExcludeGradleDependency Include=""/> .

(ndelic) #11

I couldn’t make it work with your last suggestion.

Test projects for Fire .2351 and Android Studio are attached. Fire fails on ProviderInstaller.installIfNeeded in MainActivity.onCreate, while Android Studio works. However, if I exclude from build.gradle in Android Studio, the project won’t even compile. If I add <ExcludeGradleDependency Include="" /> to the Fire project, it will compile but with 197 hints. TBH I have no idea if Fire problem is even related to conflict between android support library and Google Play Services, but both projects are configured similarly (I think) so I hope you’ll be able to make something out of them.

Oh, and breakpoints in Fire project still don’t work. They work most of the time in my app’s project if I rebuild it, but after a few runs they eventually stop working until next rebuild. If I create a new project (like the one attached) I can’t make any breakpoint work, even if I rebuild the project multiple times. (3.1 MB) (947.3 KB)

Update - the 197 compiling hints are related to Google Play Services dependencies, not excluded dependency.

(marc hoffman) #12

Hmm, ok. I’ll have a look at the projects tomorrow. you probably need the full name(s) in the exclude, with : and the second part of the name; checking the code, I compare full package names, not prefixes, for the excludes (right now; I’ll probably expand that)

Hmm. someone was supposed to follow up on that, sorry. this failure is outride of my scope, this seems to be compiler or debug engine related. I’ll chase this up with the team tomorrow.

(Carlo Kok) #13

hi, do you notice anything before the working application stops working? Like a specfic thing that happens before this occurs?

As for not the testcase that’s not working at all: Your test app uses as a namespace, but that’s a reserved namespace that we ignore for debugging (that’s the namespace android itself uses), to avoid breakpoints in the runtime.

(ndelic) #14

Hi Carlo

Sorry for late reply I was on a trip yesterday. I compiled a new sample for you, without the forbidden namespace in project name but also without excluding dependency for Google Play Services reference because I have no idea how to do it right. This should somehow be excluded from Fire Project to make it work, as you can see from the working Android Studio project attached three posts above.

New Fire ProviderInstaller (396.9 KB)

This is what happens before ProviderInstaller.InstallIfNeeded is called:

This is what happens when the ProviderInstaller line is executed:

Please note that breakpoints sometimes work and sometimes they don’t. I guess I was lucky this time. :wink:

(ndelic) #15

Any update on this?

(Carlo Kok) #16

not yet; I’ll ping my colleague again.

(ndelic) #17

Thank you.

(Carlo Kok) #18

We’ve managed to reproduce the debugging problem and are looking into that. I’m not sure about the exception itself though, I have never used that api.

(ndelic) #19

As I said, for ProviderInstaller.InstallIfNeeded to work it has to be possible to exclude dependency for Google Play Services. The Android Studio project (attached to one of my previous emails) build.gradle dependencies look like this:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation ''
    implementation ''
    implementation('') {
        exclude group: ''
    implementation('') {
        exclude group: ''
    implementation project('')
    implementation project(':cooper')
    implementation project(':swift')

As you can see, I’m excluding dependency from and AFAIK this can’t be done in Fire so ProviderInstaller fails.

Given that I can’t compile my project in Fire I just compile the shared code into Android Library and do the rest in Android Studio. Which is too bad because I would prefer to use Fire for everything. But I’m not a paying customer at the moment so I know I can’t expect you to loose much time solving this problem. I hope you’ll be able to do it sometime. Until then, I can live with Android Studio.

(marc hoffman) #20

Your project has

<ExcludeGradleDependency Include="" />

you want

<ExcludeGradleDependency Include="" />

where whatever is the name of the actual package you want excluded (eg "appcompatibility-v7` or whatever the offending package may be.