Reputation: 334
I'm developing an android wear app for a wearable device which does not have Google Play Services installed on it (for China region). But the app fails to run with the following exception :
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've already added this line in my manifest file, but it still throws the same exception. Below are my manifest and gradle files :
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xyz.abcd">
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-library
android:name="com.google.android.wearable"
android:required="false" />
<!-- Set to true if your app is Standalone, that is, it does not require the handheld app to run. -->
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<activity
android:name=".AbcActivity"
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>
app: build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.xyz.abcd"
minSdkVersion 26
targetSdkVersion 28
versionCode 5
versionName "1.0.4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
buildToolsVersion = '27.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.wear:wear:1.0.0'
implementation 'com.google.android.gms:play-services-wearable:10.2.0'
implementation 'com.google.android.support:wearable:2.5.0'
compileOnly 'com.google.android.wearable:wearable:2.5.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha05'
}
I've made a lot of search regarding this, but i'm unable to find any appropriate solution which works.
Please help!
Thanks in advance!
Upvotes: 0
Views: 1233
Reputation: 76807
Library play-services-wearable:10.2.0
seems to be required for China;
but only when using Fused Location Provider API or Data Layer API:
implementation "com.google.android.gms:play-services-wearable:17.0.0"
This is non-sense and should be removed:
buildToolsVersion = '27.0.3'
And if this here fails:
<uses-library
android:name="com.google.android.wearable"
android:required="false" />
The shared library is missing on-device, because it will only be known at compile-time:
compileOnly 'com.google.android.wearable:wearable:2.5.0'
I think you may eventually have to use com.google.android.support
there:
implementation "com.android.support:wear:28.0.0"
implementation "com.google.android.support:wearable:2.5.0"
compileOnly "com.google.android.wearable:wearable:2.5.0"
If the issue persists, consider filing an issue on the issue tracker.
Upvotes: 1