Reputation: 804
After much looking around SO and other places and not being able to fix my problem I will now create a new post in the hopes of getting my problem resolved.
I am putting together a test app to obtain a location using Google play services and seem to have everything in place - including the permissions. When the test app is run via the emulator,, an error stating that the client must have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permissions. Below is a piece of the stack trace.
11-19 16:34:40.403: E/AndroidRuntime(1245): Caused by: java.lang.SecurityException: Client must
have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to perform any location
operations.
And here is part of AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.ACCESS_COURSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<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>
What else? I am using the Google APIs platform 5, api 21 for my build target and have the google-play-services... library added to the project. I have also set-up mock latitude and longitude values on the DDMS' Emulator Control tab.
Is there anything else that needs to be put in place to get this to work? Can this be run from the emulator? For what it is worth, the project being worked with is the LocationUpdates project that was downloaded from Google.
If you need additional information to help point me in the right direction please let me know.
Thank you.
Upvotes: 2
Views: 503
Reputation: 87
I'm not sure why you get permission errors even though your permissions are in the manifest file but I can already tell you that Google Play Services won't work on the emulator unless you're using Google API
See here
To develop an app using the Google Play services APIs, you need to set up your project with the Google Play services SDK. If you haven't installed the Google Play services SDK yet, go get it now by following the guide to Adding SDK Packages. To test your app when using the Google Play services SDK, you must use either: A compatible Android device that runs Android 2.3 or higher and includes Google Play Store. The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher.
EDIT: Oh wow, I have just noticed that this post is already quite old. If that's a problem someone please tell me or delete the post
Upvotes: 1