我想用可选的磨损应用程序制作应用程序。
如果设备配有配对手表,请在手表上安装应用。但如果没有,应用程序移动应该可以随时使用。
我在Android Studio上创建了一个项目并选择创建一个移动和磨损的应用程序,但是当项目执行时抛出一个错误:
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
at android.support.wearable.activity.WearableActivity.initAmbientSupport(WearableActivity.java:187)
at android.support.wearable.activity.WearableActivity.onCreate(WearableActivity.java:70)
at com.mundocompilado.sesamo.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6259)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
那么,如何制作带有选项穿着的应用程序?
Obs:我有两个项目:移动和穿戴
移动:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mundocompilado.sesamo">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
磨损:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mundocompilado.sesamo">
<uses-feature android:name="android.hardware.type.watch" android:required="false"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<uses-library
android:name="com.google.android.wearable"
android:required="false" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
有帮助吗?
答案 0 :(得分:0)
磨损:
的gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.4.0'
compile 'com.google.android.gms:play-services-wearable:9.0.0'
}
清单:
<uses-library
android:name="com.google.android.wearable"
android:required="false" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.WAKE_LOCK" />//optional
移动应用程序:
compile 'com.google.android.gms:play-services-wearable:9.2.0'
wearApp project(':wear')
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
如何使用磨损模拟器连接设备
https://developer.android.com/training/wearables/apps/creating.html
答案 1 :(得分:0)
我发现了问题。按钮左侧&#34;运行&#34;在android studio中有一个可选模块,默认选择了我的项目穿。所以我改为移动项目并运作良好。