首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法识别android:name="com.google.android.wearable.watchface.preview“watchface

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

Stack Overflow用户
提问于 2015-06-30 09:03:32
回答 1查看 371关注 0票数 1

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

与下面显示的解决方案树相比,我担心我的AndroidManifest.xml中可能有错误:

除此之外,我还收到了这个错误:

代码语言:javascript
复制
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)

下面是AndroidManifest.xml的代码:

代码语言:javascript
复制
<?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 run按钮上会有一个红色的十字。

你可能会问问题出在哪里?我在模拟器里找不到watchface程序。我看到的只是一个蓝色的首页,然后当我滑动它时,它会进入一个议程,就像你在这里看到的那样:

Gradle:

代码语言:javascript
复制
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 (模块:穿戴)中的内容

代码语言:javascript
复制
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'
}
EN

回答 1

Stack Overflow用户

发布于 2015-07-10 06:05:43

你的表盘实际上工作得很好。

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

其次,它实际上是正确安装的,但你不能通过滑动到应用程序菜单来改变手表的外观。要选择新的表面,请按住屏幕约2秒钟,然后将进入特殊表面选择屏幕。您的表盘将出现在那里,您可以使其处于活动状态。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31127926

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档