在将AppCompatActivity迁移到WearableActivity时,我收到了以下消息的崩溃 .
引起:java.lang.IllegalStateException:找不到可穿戴共享库类 . 请将uses-library android:name =“com.google.android.wearable”android:required =“false”/>添加到应用程序清单
我正在关注此链接以在我的应用程序中启用环境模式:Keeping Your App Visible
我的清单和gradle中分别有以下内容:
<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'
我直接从链接中取出这些(希望我做对了) .
我的设备运行以下版本:
-
Android Wear - 1.1.1.1929530
-
Google Play服务 - 7.5.76(2002306-534)
-
Android OS - 5.1.1
我猜测提供android.support.wearable.activity.WearableActivity的库应该捆绑在设备上,但不在那里 .
2 回答
没有看到您的AndroidManifest,我可以做的唯一建议如下:
uses-library应该是应用程序级别,而不是清单级别 . 您的AndroidManifest应如下所示:
考虑:http://developer.android.com/guide/topics/manifest/uses-library-element.html
可能想使用
AmbientMode.AmbientCallbackProvider
而不是WearableActivity
.这是新的首选方法,它仍然为您提供
WearableActivity
的所有内容,但您可以继续使用AppCompatActivity
.Official docs call out the details (and example code) .