I am trying to launch an android wearable with an emulator, but it crashes on startup and getting the following error:
java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
But the weird part is i did defined it in my manifest like this:
New editted that "works"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wearfare.wearapp.gpswear"
android:versionCode="1"
android:versionName="1.0" >
<!-- Mark this app as an Android Wear app. -->
<uses-feature android:name="android.hardware.type.watch" />
<!-- Permission required for ambient mode to keep the application running. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault" >
<!-- API key for the Android Maps API v2. The value is defined as a string resource. -->
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxxxxxxxx"/>
<!-- Reference the wearable shared library required to support ambient mode. -->
<uses-library android:name="com.google.android.wearable" android:required="false" />
<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>
EDIT 2
I am getting the following:
10-07 10:04:43.972 1614-1614/com.wearfare.wearapp.gpswear W/ResourcesManager﹕ Asset path '/system/framework/com.google.android.wearable.jar' does not exist or contains no resources.
10-07 10:04:43.993 1614-1631/com.wearfare.wearapp.gpswear I/GMPM﹕ App measurement is starting up
10-07 10:04:43.995 1614-1631/com.wearfare.wearapp.gpswear E/GMPM﹕ getGoogleAppId failed with status: 10
10-07 10:04:43.995 1614-1631/com.wearfare.wearapp.gpswear E/GMPM﹕ Uploading is not possible. App measurement disabled
EDIT build.gradle
apply plugin: 'com.android.application'android {
signingConfigs {
}
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.wearfare.wearapp.gpswear"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.3.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:8.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-maps:8.1.0'
}
xxx is the api key i put in, but still getting the same error message when running the project. any suggestions what i am missing here?
Thanks in advance.
ALMOST THERE
Ok Guys, it looks like it does work, but it doesnt show my map, it's a grey field. I figured out i can dismiss the app when i longpress it.
So maybe it could be something else why it isnt showing my map?
I think the problem of the grey screen is that you didn't obtain the API key correctly. Please ensure that you have obtained the key correctly. I've had this exact problem when my key was generated for release instead of debug mode.
https://developers.google.com/maps/documentation/android-api/start#obtaining_an_api_key
I have checked your manifest and found problem in it.
Please add
</manifest>
tag at the end of the file.