简体   繁体   中英

Android wear packaging not working

Am trying to packaging Android wear application but wear app not automatically installed in watch.

I am using Eclipse to package wear app manually as described here

https://developer.android.com/training/wearables/apps/packaging.html#PackageManually

Log also says that wear app installed but I cannot found the app in watch. Here is the installation log,

09-16 12:55:08.135: D/Finsky(11998): [1] WorkerTask.onPreExecute: Verification Requested for id = 4, data=file:///storage/emulated/0/Download/WearCompanion.apk flags=16 fromVerificationActivity=false
09-16 12:55:13.955: D/PackageManager(2339): Sending to user 0: act=android.intent.action.PACKAGE_ADDED dat=package:com.titut.wear flg=0x8000000 Bundle[{android.intent.extra.UID=10013, android.intent.extra.user_handle=0}]
09-16 12:55:14.160: I/HomeSyncInstallReceiver(2711): Package Added : com.titut.wear
09-16 12:55:14.930: D/BackupManagerService(2339): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.titut.wear flg=0x8000010 (has extras) }
09-16 12:55:14.950: D/ECS_EnterpriseContainerService(2339): <<< Intent data is   >>> : package:com.titut.wear
09-16 12:55:14.975: D/[FileShare][Server](12291): ServerBroadcastReceiver : onReceive: android.intent.action.PACKAGE_ADDED // package:com.titut.wear
09-16 12:55:15.130: I/SmartCardBroadcastReceiver(11980): foundMatchingVendorPackage - Checking for com.titut.wear
09-16 12:55:15.195: I/CrashAnrDetector(2339): onPackageAdded : com.titut.wear
09-16 12:55:15.320: D/PackageBroadcastService(6283): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.titut.wear
09-16 12:55:15.365: I/IcingCorporaProvider(3480): Updating corpora: APPS=com.titut.wear, CONTACTS=MAYBE
09-16 12:55:15.400: D/WearablePkgInstaller(3243): Got PackageUpdateReceiver message Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.titut.wear flg=0x8000010 cmp=com.google.android.wearable.app/com.google.android.clockwork.companion.packagemanager.PackageUpdateReceiver (has extras) }

What would be the mistake? any suggestions? Thanks.

Note: I am using below command to install the application in companion mobile device

adb install WearCompanion.apk

UPDATED:

Wear app Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.titut.wear"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <uses-sdk
        android:minSdkVersion="20"
        android:targetSdkVersion="20" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.DeviceDefault" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="com.titut.wear.LoadingActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.titut.wear.MainActivity"
            android:label="@string/app_name" >
        </activity>
        <activity
            android:name="com.titut.wear.OfferDetailActivity"
            android:label="@string/app_name" >
        </activity>

        <service android:name="com.titut.wear.OngoingNotificationListenerService" >
            <intent-filter>
                <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
            </intent-filter>
        </service>
    </application>

</manifest>

Companion App Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.titut.wear"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="20" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <uses-feature
        android:name="android.hardware.type.watch"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.bluetooth_le"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.titut.companion.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <service android:name="com.titut.companion.service.MessageListenerService" >
            <intent-filter>
                <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.wearable.beta.app"
            android:resource="@xml/wearable_app_desc" />

        <service
            android:name="com.titut.companion.service.BeaconService"
            android:enabled="true" />
    </application>

</manifest>

Raw folder

在此输入图像描述

wearable_app_desc.xml

<wearableApp package="com.titut.wear">
  <versionCode>1</versionCode>
  <versionName>1.0</versionName>
  <rawPathResId>wearable_app</rawPathResId> 
</wearableApp>

Before You install app in device Just Check Below things.

1) Your PhoneAppPackage name and wearApp Packagename must be same

2) In Xml folder appPathResid and your added Apk File Name must be same

3) Have you use Original device for testing then just Bluetooth Debugging is on or if you use Emulator and real phone then USB Debugging On

Thats it...

Wear apps are NOT pushed to the device automatically, when signed with a debug key. You need to either push the installation manually to the device by debugging it with Eclipse, or sign the mobile APK with a release key:

Note : The automatic installation of wearable apps does not work when you are signing apps with a debug key and only works with release keys. See Packaging Wearable Apps for complete information on how to properly package wearable apps.

More details here: https://developer.android.com/training/wearables/apps/creating.html#Install

Permissions in the mobile/companion app must be identical to those in the wear app. In your wear manifest there is only one permission, but in the mobile manifest there are five. Copy the mobile manifest permissions to the wear manifest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM