1

我正在關注這兩個教程:tutorial 1tutorial 2。但是在我的AndroidManifest.xml文件中,下面幾行在watchface下有一個下劃線,所以我想知道如何修復它。 這裏是我的源代碼:https://github.com/lamiastella/AndroidWearAppandroid:name =「com.google.android.wearable.watchface.preview」錶盤未被識別

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

你可能會問這是什麼問題?我無法在模擬器中找到表格程序。我看到的只是一個藍色的第一頁,然後當我刷卡不言而喻綱領就像你所看到的在這裏: 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' 
} 
+0

因爲這個,你是否面對任何問題?我認爲它只是一個拼寫錯誤指示器(下劃線) – Dhina

+0

什麼是您的目標sdk版本?介意發佈build.gradle的ap? – Dhina

+0

@DhinakaranThennarasu我在帖子末尾添加了gradle控制檯 –

回答

2

你的錶盤實際上工作正常。

首先,com.google.android.wearable.watchface.preview上的下劃線實際上也出現在官方示例中。這是拼寫檢查器認爲有錯誤。其次,它實際上安裝正確,但您不要通過滑動到應用程序菜單來更改錶盤。要選擇新的錶盤,請按住屏幕約2秒鐘,然後進入特殊錶盤選擇屏幕。你的錶盤將出現在那裏,你可以使它活躍起來。