WearableActivity failed to load

I am getting an error with the following message when migrating AppCompatActivity to WearableActivity.

Caused by: java.lang.IllegalStateException: Could not find wearable shared library classes. Please add use-library android: name = "com.google.android.wearable" android: required = "false" / "> to your application manifest

I used this link to enable a behavior in my application: Keeping your application visible

I have the following in my manifest and gradle respectively:

<uses-library android:name="com.google.android.wearable"
    android:required="false" />

      

...

minSdkVersion 22
targetSdkVersion 22



compile 'com.google.android.support:wearable:1.2.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:7.5.0'

      

I took them straight from the link (I hope I got it right).

The following versions work on my device:

  • Android Wear - 1.1.1.1929530

  • Google Play Services - 7.5.76 (2002306-534)

  • Android OS - 5.1.1

I am guessing that the library that supplies android.support.wearable.activity.WearableActivity needs to be added to the device but does not exist.

+3


source to share


2 answers


Without seeing my AndroidManifest, the only suggestion I can make is this:

uses-library should be application level, not manifest level. Your AndroidManifest should look like this:



<manifest
    package="com.yourpackage.app_package"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-feature android:name="android.hardware.type.watch"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.DeviceDefault">

        <uses-library android:name="com.google.android.wearable" android:required="false" />

        <activity
        ....
        </activity>
   </application>
</manifest>

      

Consider: http://developer.android.com/guide/topics/manifest/uses-library-element.html

+10


source


You might want to use AmbientMode.AmbientCallbackProvider

instead WearableActivity

.

This is the new preferred method and it still gives you everything with WearableActivity

, but you can keep using AppCompatActivity

.



The official docs call for details (and sample code) .

0


source







All Articles