Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin ignores custom file found in root directory #44

Open
ClaudeHangui opened this issue Oct 18, 2021 · 12 comments
Open

Plugin ignores custom file found in root directory #44

ClaudeHangui opened this issue Oct 18, 2021 · 12 comments

Comments

@ClaudeHangui
Copy link

ClaudeHangui commented Oct 18, 2021

I created a custom file named service.properties at the root of my project and I stored my google api key in it as such: key_name="value"
In my module's build.gradle file I have this configuration:
secrets { propertiesFileName 'service.properties' }
When I run the project I get the error message saying telling me to check if the api key exist. It does already exists as I originally set my key in the strings.xml file and I read directly from there, before attempting this plugin
I am using v1.3.0 of the plugin

@arriolac
Copy link
Collaborator

Hi @ClaudeHangui, can you try with the latest version of this library (2.0.0)? Also, just to confirm, are you able to get the plugin to work when it reads from local.properties and not from a custom file? If there are any other error/warning log statements you can share that would be helpful.

@ClaudeHangui
Copy link
Author

Yes I am able to have it working from the local.properties file. We didn't want to upgrade to v2.0.0 as that requires us to move our AGP to v7.x.x
The error logs that we have are as usual i.e when the api key is nor configured or can't be accessed on the project:
Ensure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists: API Key: "my key"

@arriolac
Copy link
Collaborator

Are you getting a compilation error? Or is the error related to the map not showing (i.e. the plugin is able to fetch the key, but the key does not have the correct APIs enabled)? Based on the message you pasted, it seems that it might be the latter (see Enabling APIs)

@ClaudeHangui
Copy link
Author

ClaudeHangui commented Oct 18, 2021

The plugin isn't able to fetch the key. Like I said, I initially set up my key in the strings.xml file, read it in the AndroidManifest.xml and I had no issue in displaying my location on the map. I tried the plugin with a custom configuration/ file and I have the error above

@arriolac
Copy link
Collaborator

The error message that you shared in #44 (comment) does not match the error you are describing of the plugin not being able to fetch the key.

You should see something like this error for BuildConfig.GOOGLE_MAPS_KEY references:

Application.kt: (32, 45): Unresolved reference: GOOGLE_MAPS_KEY

Or, the following error if the plugin is not able to fetch your key in the AndroidManifest.xml file:

Attribute meta-data#com.google.android.geo.API_KEY@value at AndroidManifest.xml:32:13-44 requires a placeholder substitution but no value for <GOOGLE_MAPS_KEY> is provided.

Can you share more information from your logs?

@ClaudeHangui
Copy link
Author

Here :

Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: "my api key"
Android Application (<cert_fingerprint>;<package_name>): fingerPrint;packageName

Again setting up my key in local.properties or strings..xml works absoluetely fine

@arriolac
Copy link
Collaborator

Yep, that error message indicates that API key restrictions are incorrectly applied and does not have anything to do with the plugin's functionality. Is it possible that you have 2 separate keys that might be interfering with each other (or different build variants with separate package names)?

@ClaudeHangui
Copy link
Author

ClaudeHangui commented Oct 18, 2021

As a matter of fact we do have multiple build variants. But right now I am in debug mode

@ClaudeHangui
Copy link
Author

@arriolac Any ideas on how I should go about in this case ?

@arriolac
Copy link
Collaborator

If you can share a demo project that reproduces this issue for me to look into further that would be helpful.

Another thing you can test to verify that this issue is for sure with the plugin and not with a restricted API key, can you create a new unrestricted Google Maps API key and use that instead?

@ClaudeHangui
Copy link
Author

I'll try that

@arriolac
Copy link
Collaborator

Any update on your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants