无法安装带有Watchface作为库的Android APK,因为“缺少功能:观看”

时间:2018-12-21 19:40:19

标签: android android-gradle build.gradle wear-os

我目前正在尝试为Wear OS表盘编程。我首先使用表盘编译了该应用程序,但是无法将其安装在我的Android智能手机(Android 6.0)上。因此,我创建了一个附加的移动模块,并将现有的磨损模块添加为Android库。移动模块包含空白活动。现在,我仍然无法在智能手机上安装该应用程序,当我想使用AVD测试该应用程序时,它显示“缺少功能:观看”

这是整个项目的 build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

这是移动模块的 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "de.leinequell.nixiesmart"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation project(':wear')
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.android.gms:play-services-wearable:+'
}

这是损耗库的 build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    defaultConfig {

        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.android.support:wearable:2.4.0'
    implementation 'com.google.android.gms:play-services-wearable:16.0.1'
    implementation 'com.android.support:percent:28.0.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:wear:28.0.0'

    compileOnly 'com.google.android.wearable:wearable:2.4.0'
}

谢谢大家的帮助。我不是专业人士,因此答案可能非常明显且容易找到。另外,我不是英语为母语的人,因此,如果语法等不是十全十美,我感到抱歉。谢谢您的帮助。

1 个答案:

答案 0 :(得分:0)

错误消息missing feature: watch试图说明的是...

您应该使用Wear OS或智能手表在模拟器上运行应用程序。

具有:mobile:wear模块时,运行配置应反映出这一点。