4

My Android Wear app keeps crashing intermittently with an illegal state exception telling me to add

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

I have seen this thread below, but my "uses-library" statement is in the application section as you can see.

Crash loading WearableActivity

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

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

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />

<!-- Required for complications to receive complication data and open the provider chooser. -->
<uses-permission android:name="com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA"/>

<application
    android:name=".App"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/Theme.Nav">

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

build.gradle

repositories {
    jcenter()
    maven {
        url 'https://maven.google.com'
    }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.support:wearable:2.0.5'
compile 'com.android.support:wear:26.0.1'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.kabouzeid:app-theme-helper:1.3.7'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:preference-v7:26.0.1'
compile 'com.android.support:mediarouter-v7:26.0.1'
compile 'com.android.support:percent:26.0.1'
compile 'net.vrallev.android:cat:1.0.5'
compile 'org.projectlombok:lombok:1.16.18'
compile 'com.twofortyfouram:android-plugin-client-sdk-for-locale:4.0.2'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.github.bumptech.glide:glide:4.1.1'
compile 'com.android.support:palette-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
provided 'com.google.android.wearable:wearable:2.0.5'
}

I get the same error with another of my wear apps. Here are it's dependencies.

repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
    maven { url "https://jitpack.io" }
    mavenCentral()
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.dom4j:dom4j:2.1.0'
compile 'commons-io:commons-io:2.5'
compile 'com.google.android.support:wearable:2.0.5'
compile 'com.android.support:wear:26.0.1'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'net.vrallev.android:cat:1.0.5'
compile 'com.google.code.gson:gson:2.8.2'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.github.bumptech.glide:glide:4.1.1'

compile 'com.github.kabouzeid:app-theme-helper:1.3.7'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:palette-v7:26.0.1'
compile 'com.android.support:preference-v7:26.0.1'

annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
compile 'com.google.android.exoplayer:exoplayer:r2.5.3'

compile project(':audiosearch');

compile 'com.android.support:support-v4:26.0.1'

provided 'com.google.android.wearable:wearable:2.0.5'
}

This is a standalone wear app.

Joel Page
  • 642
  • 3
  • 17
  • If you are making apps with optional wear app, you can follow the answer in this [SO post](https://stackoverflow.com/questions/39125450/run-app-with-wear-app-without-watch/39127118) if the latter is not working fine. The same error was encountered by the user. – MαπμQμαπkγVπ.0 Oct 01 '17 at 13:07
  • No, this is a standalone Wear app. – Joel Page Oct 01 '17 at 13:15
  • Might be an issue with your dependencies. Do you mind posting the build.gradle file too? – TofferJ Oct 02 '17 at 14:40
  • I posted the dependencies for this app as well as another one that is having the same issues for comparison. – Joel Page Oct 02 '17 at 15:11

0 Answers0