title: Android plugin using Google Fitness API for Unity3D
body: <p>The main goal of my project is to create a Unity plugin that will be able to use Google Fitness step counter API. It have to provide several features like: getting daily steps count, getting total steps, saving steps amount on the google account and finally the most important and the most difficult sending notifications when steps amount have reached a specified value.</p>
  
  <p>I decided to make an android plugin with running background service that will be able to send those notifications as mentioned above, but I encountered a problem on the very beginning of this project. There is a problem with Google Services initialization, which working perfectly when I’m using it in native android app, but when I’m trying to use it as android library in Unity it always fails.</p>
  
  <p>logcat error:</p>
  
  <pre><code>06-05 13:49:27.991 15144-15144/? E/GMPM: 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.
  06-05 13:49:27.991 15144-15144/? E/GMPM: Scheduler not set. Not logging error/warn.
  06-05 13:49:28.005 15144-15158/? E/GMPM: Uploading is not possible. App measurement disabled
  </code></pre>
  
  <p>I was thinking that key to this problem may be to somehow provide data (appIds, SHAs etc.) from generated in the Google Developers console “google-services.json” file into Unity, but .aar library which was generated from android studio contains those informations in res/values/strings file as I think it should.</p>
  
  <p>I was testing many probable solutions including:</p>
  
  <ul>
  <li><p>exporting android project from unity and adding my library module to it</p></li>
  <li><p>providing my library as .jar file and “google-services.json” separately</p></li>
  <li><p>providing necessary data directly in Unity in res/values/strings file</p></li>
  <li><p>adding it to exported project</p></li>
  </ul>
  
  <p>Ended up with the same error as I mentioned above. </p>
  
  <p>Am I doing something wrong, or maybe there is an entirely different approach to this problem?</p>
  
  <p>Edit:</p>
  
  <p>Android Manifest from Unity (Plugins/Android):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="&lt;UNITY APP PACKAGE NAME&gt;" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal"&gt;
    &lt;supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" /&gt;
  
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  
  
    &lt;application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true" android:isGame="true" android:banner="@drawable/app_banner"&gt;
  
      &lt;activity android:name="&lt;PLUGIN PACKAGE NAME + CLASS NAME&gt;" android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"&gt;
  
        &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;category android:name="android.intent.category.LEANBACK_LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
  
        &lt;meta-data android:name="unityplayer.UnityActivity" android:value="true" /&gt;
      &lt;/activity&gt;
  
    &lt;/application&gt;
  
    &lt;uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" /&gt;
    &lt;uses-feature android:glEsVersion="0x00020000" /&gt;
  
    &lt;uses-feature android:name="android.hardware.touchscreen" android:required="false" /&gt;
    &lt;uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" /&gt;
    &lt;uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" /&gt;
  &lt;/manifest&gt;
  </code></pre>