可穿戴应用程序无法从移动 apk 安装 [英] Wearable app does not install from mobile apk

查看:41
本文介绍了可穿戴应用程序无法从移动 apk 安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过我的三个模块(通用、移动和穿戴)的以下 Gradle 文件,我想知道为什么我的穿戴式应用程序没有安装在穿戴式设备上,当我使用穿戴式虚拟模拟器和我的穿戴式虚拟仿真器运行移动应用程序时移动设备运行并连接(通过 USB 和 Android Wear 应用程序),并通过移动模块(当前在移动目录中)对两个 apk 进行签名:

With the following Gradle files of my three modules (common, mobile, and wear), I was wondering why my wearable app doesn't install on the wearable device when I run the mobile app with both the wear virtual emulator and my mobile device running and connected (through USB and the Android wear app), and signed both apks through the mobile module (currently in the mobile directory):

常用模块:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

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

移动模块:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "dpark.gameoflife"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    signingConfigs {
        debug {
            storeFile file("C:\\Users\\Dave\\AndroidStudioProjects\\KEY_STORE\\Game_of_Life.jks")
            storePassword "***"
            keyAlias "game_of_life"
            keyPassword "***"
        }
        release {
            storeFile file("C:\\Users\\Dave\\AndroidStudioProjects\\KEY_STORE\\Game_of_Life.jks")
            storePassword "***"
            keyAlias "game_of_life"
            keyPassword "***"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    compile project(':common')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-wearable:8.4.0'
}

磨损模块:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "dpark.gameoflife"
        minSdkVersion 22
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    signingConfigs {
        debug {
            storeFile file("C:\\Users\\Dave\\AndroidStudioProjects\\KEY_STORE\\Game_of_Life.jks")
            storePassword "***"
            keyAlias "game_of_life"
            keyPassword "***"
        }
        release {
            storeFile file("C:\\Users\\Dave\\AndroidStudioProjects\\KEY_STORE\\Game_of_Life.jks")
            storePassword "***"
            keyAlias "game_of_life"
            keyPassword "***"
        }
    }

    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.3.0'
    compile 'com.google.android.gms:play-services-wearable:8.4.0'
    compile project(':common')
}

通用清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    package="dpark.common" >
</manifest>

移动清单:

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar" >
        <activity
            android:name=".MainActivity">
        </activity>
        <activity
            android:name=".WelcomeActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

穿戴清单:

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

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
        </activity>
        <activity
            android:name=".WelcomeActivity"
            android:theme="@android:style/Theme.DeviceDefault" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

...虽然应用程序正确安装在我的移动设备上,但我只在我的穿戴虚拟模拟器上收到通知(最多当我的示例应用程序只是应该显示 GridView 时),如下所示:

... While the app properly installs on my mobile device, I only get a notification (at most when my sample app is simply supposed to display a GridView) on my wear virtual emulator as follows:

谢谢!

自 4/4 起-这是我在 logcat 上得到的:

EDIT AS OF 4/4: -Here's what I get on my logcat:

04-04 09:39:27.462 15810-15810/dpark.gameoflife I/art: Late-enabling -Xcheck:jni
04-04 09:39:27.462 15810-15810/dpark.gameoflife I/art: VMHOOK: rlim_cur : 0 pid:15810
04-04 09:39:27.543 15810-15810/dpark.gameoflife W/System: ClassLoader referenced unknown path: /data/app/dpark.gameoflife-1/lib/arm
04-04 09:39:27.570 15810-15810/dpark.gameoflife I/GMPM: App measurement is starting up, version: 8487
04-04 09:39:27.571 15810-15810/dpark.gameoflife I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
04-04 09:39:27.580 15810-15810/dpark.gameoflife E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
04-04 09:39:27.580 15810-15810/dpark.gameoflife E/GMPM: Scheduler not set. Not logging error/warn.
04-04 09:39:27.644 15810-15831/dpark.gameoflife E/GMPM: Uploading is not possible. App measurement disabled
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8974_LA.BF.1.1.3__release_AU (I3fa967cfef)
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: OpenGL ES Shader Compiler Version: E031.28.00.02
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: Build Date: 09/29/15 Tue
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: Local Branch: mybranch14683032
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: Remote Branch: quic/master
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: Local Patches: NONE
04-04 09:39:27.763 15810-15847/dpark.gameoflife I/Adreno-EGL: Reconstruct Branch: NOTHING
04-04 09:39:37.863 15810-15831/dpark.gameoflife I/GMPM: Tag Manager is not found and thus will not be used
04-04 09:43:06.197 15810-15847/dpark.gameoflife E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb9d385f0

...我是否在我的 Manifest 或 Gradle 文件中遗漏了一些内容,如本文上方所示?

... Am I missing something either in my Manifest or Gradle files as shown above in this post?

推荐答案

第一印象

这里可能有很多问题.乍一看,gradle 配置似乎很好,有一个 Wear 应用程序参考、匹配的版本名称和编号、应用程序 ID 和包名称.清单不显示可能丢失的权限.没有特别的味道.

First impressions

Could be many things wrong here. On first sight the gradle configurations seem fine having a wear app reference, matching version name and numbers, application Id and package names. The manifests don't show permissions that could be missing. No special flavors.

为了解决这个问题,您需要收集日志.我看到您有 logcat 输出,但这实际上只是来自您的应用程序.您需要使用 WearablePkgInstaller 上的过滤器来过滤 android 磨损包安装程序特定的内容.

In order to resolve this issue you need to collect logs. I see you have logcat output but that is really just from your app. You need to filter on android wear package installer specific stuff with a filter set on WearablePkgInstaller.

同样,在您的手持设备上登录时,您只会看到触发安装的说明.每次您重新安装应用或从 Wear OS 应用触发应用同步时,都会显示该信息.

Also from the logging on your handheld device you will only see an instruction to trigger the installation. That should show every time you reinstall your app or trigger app sync from the wear OS app.

11-07 14:58:53.127 3330-8739/? I/WearablePkgInstaller: Setting DataItem to install wearable apps for com.spotify.music

然而,真正有价值的日志正在监视中.因此,请确保从可穿戴设备获取日志记录.您将在那里获得有关安装失败的信息,包括原因.

The really valuable logging however is on the watch. So make sure to get logging from the wearable device. There you will get information, including the reason why, on the failed installation.

有些手表有用于调试的 USB 连接.其他人需要一些额外的步骤来启用蓝牙调试.第一步是通过多次点击内部版本号来启用开发者选项和调试,类似于在手持设备上的操作.

Some watches have a USB connection for debugging. Others require some extra steps to enable debugging over bluetooth. First step is to enable developer options and debugging by tapping the build number several times, similar to how it's done on the handheld.

可穿戴设备上的日志可以在相同的 WearablePkgInstaller 过滤器上过滤,或者您可以使用自己的包 ID 进行过滤.日志记录可以非常清楚(例如 不匹配的 google play 服务 或缺少权限) 或者使用 returnCode 进行加密.

The logging on the wearable can be filtered on that same WearablePkgInstaller filter or you could use your own package Id to filter on. The logging can be very clear (like mismatching google play services or missing permissions) or rather cryptical with a returnCode.

如果是 returnCode,您必须检查 Android 的源代码该代码代表什么,并且基于 javadoc,您可以开始更具体地搜索.

In case of the returnCode you'll have to check in source code of Android what that code stands for and based on the javadoc you can start searching more specifically.

可穿戴项目仅包含在发布版本中.此外,最新的 Android Studio 版本有标志集 (FLAG_TEST_ONLY) 在安装时会导致returnCode -15 失败.检查手持应用程序是否启用了正确的运行时权限(也应该从错误日志中清除).

Wearable projects are only included in release builds. Also the latest Android studio builds have a flag set (FLAG_TEST_ONLY) that would result in a failure with returnCode -15 upon installation. Check that the handheld app has the proper runtime permissions enabled (that should be clear from error logging also).

即使是用于优化的构建工具也可以从应用程序中删除磨损项目.然后是可穿戴设备或手持设备没有最新的 Google Play 服务的选项.确保还检查this SO question上接受的答案以获取选项.

Even build tools for optimalisation could remove the wear project from the app. And then there is the option that either wearable or handheld doesn't have the latest Google Play Services. Make sure to also check the accepted answer on this SO question for options.

这篇关于可穿戴应用程序无法从移动 apk 安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆