WSDOT / wsdot-android-app

Source code for the WSDOT Android application
GNU General Public License v3.0
19 stars 12 forks source link

Moved to Android Studio. #46

Closed loganSims closed 8 years ago

loganSims commented 8 years ago

Changes

After moving to Android Studio an error for google services emerged during the Gradle build: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin

There is a quick way to configure google services using a JSON file and a Gradle plugin. The plugin parses configuration information from the JSON file to set up google services. According to a stack overflow user arne.jans here, there is no need to use this JSON configuration if we have already set up google services.

To resolve this error I added the string resource google_app_id to the apikey.xml with it's value set to the api project ID from the google dev console. I put this in apikeys.xml because I am not sure if this ID should be public. The play services seem to be working correctly. It may be worth using the Gradle plugin in the future.

EDIT: The error was resolved by adding only play services libraries we use in the app.

For more information on the JSON config file and the plugin see this page under "Set up your project" and "Get a configuration file".

loganSims commented 8 years ago

Testing signed apk before we move.

loganSims commented 8 years ago
Correction about the error under "other".

It's a runtime error that showed up after we started using gradle, not during the gradle build process. The app will still build and seems to run fine with the error.

loganSims commented 8 years ago

I believe I tracked down the cause of the error under "other".

As described in the 3rd bullet point we had compile 'com.google.android.gms:play-services:8.4.0' in our gradle dependencies. This pulled in all of the google services libraries. One of those libraries requires the resource R.string.google_app_id. We aren't using that library which explains why the app runs fine without the resource.

Changing the dependencies to only add in the libraries we are using removes the error. I hadn't noticed the error was resolved by the change in dependencies because I had already added the 'google_app_id' resource before I changed our dependencies.

The offending library could have been something like the Google Cloud Messaging (GCM) Android client, which we do not use.