Hello Stackoverflow community,
I am currently testing the Android Wear SDK and successfully developed my first wearable app using Android Studio. It is obviously part of a handheld app. This handheld app uses different product flavours for free and paid versions that have a different package names. In Android Studio the "development" package name is like com.abcde, while the flavours are com.abcde.free and com.abcde.pro.
The connection between wear app (dev package name is also com.abcde) and handheld is working fine so far, but I have problems with the packaging testing on the wear emulator.
My question: I have packaged the wear app into my release apk using the Gradle wearApp style in the first attempt and the manual style in the second attempt. Using the second attempt increases my apk by the size of the wear app!
However, I cannot see the app on the wear emulator after installing the release apk on my physical device (which is paired via adb forward with the wear emulator). Is this generally possible, or do I also need a physical wear device to test the automatic packaging?
Looking forward to answers. Thank you in advance!
I found the solution for this. It is a problem with the product flavors.
Let's say you have the following flavor configuration for example.
productFlavors {
free {
applicationId "com.myapp.free"
}
pro {
applicationId "com.myapp.pro"
}
}
You can package the wear app by adding this to your handheld apps build.gradle. This is for the pro version:
wearApp project(path: ':wear', configuration: 'proRelease')
And this is for the free release:
wearApp project(path: ':wear', configuration: 'freeRelease')
The solution was found here: https://stackoverflow.com/a/24828264/547268
Related
I tried to add a wear module to my existing app, tried a lot of solutions, but can't figure out why my app is not being installed on my watch.
What I tried :
First, Manual packaging with my app : https://developer.android.com/training/wearables/apps/packaging.html
But I quickly decided not to go through this.
Then I decided to go to gradle include, so to the build.gradle of app, I added the following to the end of dependencies :
debugWearApp project(path:':wear', configuration: 'flavor1Debug')
releaseWearApp project(path:':wear', configuration: 'flavor1Release')
To the build.gradle of wear, I added the following to the beginning of dependencies :
wearApp project(':wear')
Then, in android{} section of wear build.gradle, just after buildToolsVersion, I added the following :
publishNonDefault true
What I have seen :
No problem to install the wear app to the wear using bluetooth debug of the wear
Then, when I install a generate a release version of my app, I can see in raw, that it has been added a file android_wear_micro_apk.apk to res/raw which is my watch app.
I also saw a file android_wear_micro_apk.xml in res/xml with, from what I guess between hexa codes, the description of wear app.
Then I compare signatures :
keytool -list -printcert -jarfile mobile_app.apk
keytool -list -printcert -jarfile wear_app.apk
Using the wear app generated in res/raw. They exactly have the same signature. Then I compared :
aapt dump badging mobile_app.apk
aapt dump badging wear_app.apk
They have exact same package names and version codes and names.
So, from that :
Apk of wear is correctly added
Apk of wear is working if installed on the wear using adb and bluetooth debug
Both apk have same version code, version name, and package name
Wear is not requiring any permission
Phone is requesting following permissions
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET
com.android.vending.BILLING
com.google.android.c2dm.permission.RECEIVE
android.permission.VIBRATE
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
com.samsung.accessory.permission.ACCESSORY_FRAMEWORK
com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY
com.samsung.WATCH_APP_TYPE.Companion
com.samsung.wmanager.ENABLE_NOTIFICATION
I'm really wondering what I could have forgotten.
Thanks for any help
According to one of Google’s Android Developer Advocates, Android Wear 2.0 will require completely standalone watch and phone apps, and abandons the system used since the first version of Android Wear that automatically installs Android Wear apps based on the apps you have on your phone.
He puts it plainly in reply to another developer in the Android Wear Developers Google+ community (emphasis ours):
A Wear 2.0 user must visit the Play Store on their watch to install
apps. There is no auto-install like on Wear 1.X. Wear 2.0 apps get
full network access and can be installed completely separately from
the handheld app so the focus is much more on standalone Wear apps
than the handheld centric 1.X Wear apps.
But what about apps built solely for your watch? Well, there's a whole
store worth of apps that go beyond simple notifications and live on
the watch itself. Rather oddly, these still have to be installed
through your smartphone. For now, at least - the new Android Wear 2.0
update will include functionality for standalone apps.
Forum
On the watch:
Settings, Un-pair with phone. (Old release of AW may say Factory
reset.)
Do not set up the watch yet.
On the phone:
In Android Wear use the Disconnect... option.
In Android Wear, use Settings, Device settings and touch the watch
name, Touch FORGET WATCH.
Settings, Bluetooth. If you still see the watch, touch Forget... the
watch so it no longer appears in the list of paired devices.
Settings, Device, Apps, select Google Play Services. Clear cache and
Clear data. Uninstall updates.
Settings, Device, Apps, select Google App. Clear cache and Clear
data. Also Uninstall updates.
Settings, Device, Apps, select Android Wear. Clear cache and Clear
data. Also Uninstall updates.
Play Store, Apps, My apps, touch the Update all button.
You may want to check permissions declared in your app. As mentioned in Requesting Permissions on Android Wear regarding mismatching permission models between wearable and handset app,
If your handset app begins using the Android 6.0 (API level 23) model but your wearable app does not, the system downloads the Wear app, but does not install it. The first time the user launches the app, the system prompts them to grant all pending permissions. Once they do so, it installs the app. If your app, for example a watch face, does not have a launcher, the system displays a stream notification asking the user to grant the permissions the app needs.
The suggested solutions in these SO posts might also help:
Android Wear App not installed
Android Wear app not installing through handset
I want to create an Android wearable app on Android studio. I have installed the apk file on mobile to test run it. I would like to know how I can run the same apk on wearable device.Also, apk file created on Studio is different for wearable and mobile devices. How can we run it? Thanks in advance!
As it mentioned at official website you need to create special package signed by release key. See more info about packaging here.
When developing, you install apps directly to the wearable like with handheld apps. Use either adb install or the Play button on Android Studio.
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.
During the development period, do not use release key for signing. Instead, you should build your app which would result in two apks, one for the phone and one for the wear device. Then install each of them separately on the corresponding device using adb or Android Studio. Make sure you are using the same package names for both apks.
When you are done with your development, then build the app with your release key; then the wear apk will be embedded inside your phone apk and installation of your phone apk on a phone will result in the installation of the embedded wear apk on the wear device (make sure you remove the dev apks from both devices prior to this step otherwise installation will fail due to different keys).
Trying to debug through Android Studio as suggested by Julia and Ali, but it is always showing me Parse error while installing or running the code.
I have created a project for both mobile and wear. While running for mobile it works fine in the mobile device but while running the code in the wear it always shows Parse error.
I am using Moto 360 for running and debugging.
Gradle wrapper version: 2.5
Gradle android plugin: compile 'com.android.tools.build:gradle:1.2.3'
Android Studio: Version 1.2.2
Mobile dependencies:
wearApp project(':wear')
compile 'com.google.android.gms:play-services-base:7.5.0#aar'
compile 'com.google.android.gms:play-services-wearable:7.5.0#aar'
compile "com.android.support:support-v4:22.2.1"
Wear dependencies:
compile 'com.google.android.support:wearable:1.2.0'
compile 'com.google.android.gms:play-services-wearable:7.5.0'
By running assembleDebug, the mobile app gets built and packaged and then the wear app is built and packaged independently. This way, the wear apk does not end up inside the res/raw folder of the mobile app, the manifest is not updated etc.
But, if I run assembleRelease, the wear app is built first and correctly packaged inside the mobile app and installed on the watch.
I though that maybe signing would be the issue. I gave the debug build the same signing config as release (same certificate, keystore etc) but still same behavior.
This happens either using Android Studio or packaging from the command line.
Needless to say, this is very inconvenient since I can't debug the app on either device.
Has anyone ever experienced this behavior? Has anything changed in the gradle plugin that we have to enable to package wear apps in debug mode?
UPDATE: I don't know if my memory is failing me, but I do recall being able to package de app with assembleDebug, deploy to the phone (and consequently to the watch) and being able to attach the debugger on the watch.
I might be mistaken though. What I ended up doing was deploying the apps independently on both devices (through Android Studio) and going from there. It might be that I always did that in the past and the way the documentation is written lead me to believe otherwise. I will still leave this question here for other people.
If I recall correctly, the packaging of wear app inside the phone app is only done for release builds, so that is by design. In reality, when I am developing an app or debugging one, it is a LOT more convenient for me to just use adb to push the wear app; I don't have to constantly increment the version (otherwise the wear app will not be updated), nor I need to build the phone app each time. Is there a reason you cannot do that? Also, is there a reason you say ".. I can't debug the app on either device"?
I am creating a watch face for android wear. After creating watch face and reading this, I have generated signed apk for android wear.
But android studio is generating two signed apk: one for mobile device and another for wearable.
I want to pack my wearable app inside my mobile app so that watchface appear on companion app as shown on developer's guide.
I installed mobile-release.apk but when I open it it doesn't showing in companion app or anywhere. Can anyone help me how to install it?
Assuming you use android studio:
Your mobile build.gradle file should have the following dependency:
dependencies {
...
wearApp project(':wear')
}
Go to Build > Generate signed apk. In the first window, select mobile as your module.
Now when the build is complete, the wear module will automatically be embedded into the mobile module. The mobile apk is the one you distribute. Wear can be used for testing.
we release our first Wearable Application today but sadly this one isn't get installed automatically as it should.
We double checked the APK and the wearable apk is present but never hits the watch. Manually packaging the APK as suggested here http://android-developers.blogspot.de/2014/07/update-on-android-wear-paid-apps.html doesn't helped either. (We know this should only affect paid apps but just to be sure)
Is anybody else facing this issue? The app works if we install the APKs over adb.
Check your permissions. The Smartphone part needs to have all the permissions the Wear component has.
use the same package id for both apps (wear and mobile)
I spend ages on this. The wearApp gradle rule worked fine for me. But then for the Paid version of the app, following the guide on the blog to manually package the wear app, it wouldn't auto-load on the wearable. After lots of checking, I found that the wearApp gradle rule (on Android Studio 0.8.2), did actually place the wearable APK in the raw folder as per the blog post fix. So seems to be fixed in latest Android Studio (without being told?). And for some reason, manually packaging the APKs didn't work.
So use the wearApp gradle rule.
Also, if you need to reference a different version of the wear APK for different handheld APK versions (for free and pro versions to have applicationId that matches the wearable version), use the productFlavors in the wear gradle config:
productFlavors {
freeapp {
applicationId "com.barkside.appfree"
}
proapp {
applicationId "com.barkside.apppro"
}
}
Then in your Pro version gradle (for example), have the wearApp dependency target a particular configuration:
wearApp project(path: ':wear', configuration: 'proappRelease')
You will also need publishNonDefault true in the android block of the wear gradle.
Had the same problem, what helped me was adding
<uses-feature android:name="android.hardware.type.watch" android:required="false"/>
To the mobiles manifest.
What worked for me was removing product flavors. Sucks that I can't have flavor-specific code now, but Android refuses to package the wear app in release otherwise.
See: Android Wear app not installing through handset
You should check adb logcat on both devices to see what is going on. It will give error messages to indicate what problem might be happening.
Also, when you are testing locally, you should only adb install the phone APK to the phone, and let it install the embedded APK to the wearable device. Then you don't need to go all the way through the play store for testing. Make sure you do release builds, because those are the only ones that do the embedded APK with the wearApp() gradle rule.
I had a problem with installing an app, i think because my watch reset when it was installing. I had to desvinculate the watch, after reinstall everything it works. Maybe help someone
This is going to sound like such a basic and silly answer. But when I did my tests, I forgot that in Android Studios where you click on the play button to run your app, you can change it from mobile to wear. I was only ever installing the mobile app and not the wear app on the wear device.
Hope this helps someone.