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 com.google.android.gms:play-services-basement that contains the ProviderInstaller class and put <meta-data android:name="com.google.android.gms.version" 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?
I made it work in Android Studio, but I had to import Google Play Services (GPS) by excluding com.android.support 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 'com.android.support:appcompat-v7:28.0.0' // ... are added...
implementation 'com.android.support.constraint:constraint-layout:1.1.3' // ... by AndroidStudio
implementation ("com.google.android.gms:play-services-basement:16.1.0") { // Added by me
exclude group: 'com.android.support'
}
}
AFAIK adds com.google.android.gms:play-services-basement (GPS) gradle reference without adding com.android.support dependency to GPS because a different version of com.android.support 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.
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.
Please correct me if I’m wrong, but wouldn’t that exclude com.android.support dependency for the whole project? It only has to be excluded for GPS, I need com.android.support for the main project.
If that does not work, also try using the full package name of the offending package (e.g. <ExcludeGradleDependency Include="com.android.support:whatever"/> .
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 com.android.support from build.gradle in Android Studio, the project won’t even compile. If I add <ExcludeGradleDependency Include="com.android.support" /> 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.
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.
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 com.android. 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.
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 com.android.suport 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.
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.
As I said, for ProviderInstaller.InstallIfNeeded to work it has to be possible to exclude com.android.support dependency for Google Play Services. The Android Studio project (attached to one of my previous emails) build.gradle dependencies look like this:
As you can see, I’m excluding com.android.support dependency from com.google.android.gms:play-services-base and com.google.android.gms:play-services-basement. 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.