I am trying Google's official PlacesPicker example. It runs and renders the first activity but when I click the button to "Pick a Place" it temporarily goes to the next activity but after showing the map for a very short time it goes back to the main activity.
When I looked at the log it has two issues that I cannot resolve one is
FIRST ISSUE
Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.zze.zzb
This I tried resolving by adding android.support.mulitdex.MultiDexApplication to my manifest
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
I also added this to the build.gradle
compile 'com.android.support:multidex:1.0.0'
Also other accepted solutions suggests that it might be related to the 65k limit error so I also selectiely added only the necessary google play services to the build.gradle
compile 'com.google.android.gms:play-services-measurement:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
SECOND ISSUE
12934/com.example.google.playservices.placepicker 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.
03-21 11:29:02.583 12934-12934/com.example.google.playservices.placepicker E/GMPM: Scheduler not set. Not logging error/warn.
03-21 11:29:02.653 12934-13065/com.example.google.playservices.placepicker E/GMPM: Uploading is not possible. App measurement disabled
I tried so many solutions suggested here in Stackoverflow but with no success. this , and this and this are just some of the accepted answers I have tried.
I am sure that the api key is valid because the calls are being registered on my google developer console. It is really frustrating that an official example cant be compiled and tested easily. Does anybody encountered this issues and how did you fix them? Also if you know or have a better much updated working example of Android Places API please share I will really appreciate it.
UPDATE 1 : MY MANIFEST FILE
<?xml version="1.0" encoding="UTF-8"?><!--
Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.google.playservices.placepicker"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<!-- PlacePicker requires the ACCESS_FINE_LOCATION permission and a geo API key.
See this page for more information on how to obtain an API key:
https://developers.google.com/places/documentation/android/start
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- PlacePicker also requires OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIza..xxx...key.from.google" />
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>