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

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

问题描述

使用我的三个模块(常见,移动和穿戴)的以下Gradle文件,我想知道为什么当我同时使用Wear虚拟模拟器和我的移动虚拟机运行移动应用时,可穿戴应用没有安装在可穿戴设备上运行和连接(通过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

...如本文上面所示,我的清单文件或Gradle文件中是否缺少某些内容?

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

推荐答案

第一印象

这里可能有很多错误.乍一看,gradle配置看起来不错,其中包含磨损应用程序参考,匹配的版本名称和编号,应用程序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连接.其他人则需要一些额外的步骤来在蓝牙上启用调试.第一步是通过多次点击build number来启用开发人员选项和调试,这与在手持设备上的操作类似.

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进行过滤.日志记录非常清晰(例如

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,您必须

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服务.确保还检查此SO问题上的可接受答案,以获取选项

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天全站免登陆