android:name =“com.google.android.wearable.watchface.preview”watchface无法识别

时间:2015-06-30 01:03:32

标签: android android-layout android-studio android-manifest wear-os

我正在关注这两个教程:tutorial 1tutorial 2。但是在我的AndroidManifest.xml文件中,以下行在watchface下有一个下划线,所以我想知道如何解决它。 这是我的源代码:https://github.com/lamiastella/AndroidWearApp

enter image description here 我恐怕在我的AndroidManifest.xml中可能会出现错误,与此处显示的解决方案树相比: enter image description here 此外,我收到此错误:

06-30 00:54:55.461    1361-1602/com.google.android.gms.wearable W/WearableConn﹕ Error writing to device, error: failed to connect to /10.0.2.2 (port 5601): connect failed: ECONNREFUSED (Connection refused)

enter image description here

以下是AndroidManifest.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mona.app1" >

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

    <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

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

        <service
            android:name=".WeatherWatchFaceService"
            android:label="Weather"
            android:allowEmbedded="true"
            android:taskAffinity=""
            android:permission="android.permission.BIND_WALLPAPER" >
            <meta-data
                android:name="android.service.wallpaper"
                android:resource="@xml/watch_face" />
            <meta-data
                android:name="com.google.android.wearable.watchface.preview"
                android:resource="@drawable/preview" />
            <meta-data
                android:name="com.google.android.wearable.watchface.preview_circular"
                android:resource="@drawable/preview_circular" />
            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" />
                <category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
            </intent-filter>
        </service>
    </application>
</manifest>

旁注:我不确定为什么Android Wear运行按钮上有红叉。 enter image description here enter image description here

您可能会问问题是什么?我在模拟器中找不到watchface程序。我所看到的只是一个蓝色的第一页,然后当我滑动它就像你在这里看到的那样进入议程: enter image description here enter image description here

摇篮:

Configuration on demand is an incubating feature.
:wear:preBuild UP-TO-DATE
:wear:preDebugBuild UP-TO-DATE
:wear:checkDebugManifest
:wear:preReleaseBuild UP-TO-DATE
:wear:prepareComAndroidSupportRecyclerviewV72200Library UP-TO-DATE
:wear:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:wear:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:wear:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:wear:prepareComGoogleAndroidSupportWearable120Library UP-TO-DATE
:wear:prepareDebugDependencies
:wear:compileDebugAidl UP-TO-DATE
:wear:compileDebugRenderscript UP-TO-DATE
:wear:generateDebugBuildConfig UP-TO-DATE
:wear:generateDebugAssets UP-TO-DATE
:wear:mergeDebugAssets UP-TO-DATE
:wear:generateDebugResValues UP-TO-DATE
:wear:generateDebugResources UP-TO-DATE
:wear:mergeDebugResources UP-TO-DATE
:wear:processDebugManifest UP-TO-DATE
:wear:processDebugResources UP-TO-DATE
:wear:generateDebugSources UP-TO-DATE
:wear:processDebugJavaRes UP-TO-DATE
:wear:compileDebugJava UP-TO-DATE
:wear:compileDebugNdk UP-TO-DATE
:wear:compileDebugSources UP-TO-DATE
:wear:preDexDebug UP-TO-DATE
:wear:dexDebug UP-TO-DATE
:wear:validateDebugSigning
:wear:packageDebug UP-TO-DATE
:wear:zipalignDebug UP-TO-DATE
:wear:assembleDebug UP-TO-DATE

BUILD SUCCESSFUL

Total time: 3.701 secs

这是build.gradle中的内容(模块:穿)

apply plugin: 'com.android.application'


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.mona.app1"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.2.0'
    compile 'com.google.android.gms:play-services-wearable:7.5.0'
}

1 个答案:

答案 0 :(得分:2)

你的表盘实际上工作正常。

首先,com.google.android.wearable.watchface.preview的下划线实际上也出现在官方样本中。这是拼写检查员认为有错误。

其次,它实际安装正确,但您不要通过滑动到应用程序菜单来更改表盘。要选择新的表盘,请按住屏幕约2秒钟,然后它将进入特殊的表盘选择屏幕。您的表盘将出现在那里,您可以将其激活。