Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.4k views
in Technique[技术] by (71.8m points)

android - Wearable app does not install from mobile 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):

Common module:

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'
        }
    }
}

Mobile module:

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'
}

Wear module:

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')
}

Common manifest:

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

Mobile 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>

Wear 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>

... 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:

enter image description here

enter image description here

enter image description here

Thanks!

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

What you really need to do -> get LOGS

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.

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.

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.

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.

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.

Some more things you could check

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).

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...