【问题标题】:Android APK with Watchface as library in it can't be installed because of "missing feature: watch"由于“缺少功能:手表”,无法安装其中包含 Watchface 作为库的 Android APK
【发布时间】:2018-12-21 19:40:18
【问题描述】:

我目前正在尝试对 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'
}

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

【问题讨论】:

  • 你好。 “无法在我的安卓智能手机上安装它”是什么意思?编译的结果是什么?
  • 在我真正的智能手机上它只是说:不会安装。它编译得很好,但我只能在手表模拟器上运行应用程序,而不能在智能手机模拟器上运行,所以我无法测试移动模块

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


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2016-10-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2015-03-22
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    • 1970-01-01
    相关资源
    最近更新 更多