0

I'm developing an Android Wear watch face along with its mobile companion configuration activity. As a start I followed the documentation (https://developer.android.com/training/wearables/watch-faces/configuration.html#CompanionActivity) and used the available examples from Google (https://developer.android.com/samples/WatchFace/index.html), specifically the FitDistanceService.

If I use the actual code from the example it all works. The small gear icon - used to open the companion (phone) configuration activity - shows up in the Android Wear app on the phone and I can open the companion phone config activity by tapping on it.

But if I rename the package name from the default "com.example.android.wearable.watchface" to anything else (even to com.example.android.wearable.mycompany) the gear icon disappears from the Android Wear app on the phone and it becomes impossible to open the configuration activity.

I tried changing the package name in any possible way. I've tried using the Move, Copy, Rename functionalities in Android Studio (v. 2.2.3). I've tried to manually change the package name and all its occurrencies in all of the project files using Sublime Text, also renaming the related folders and changing any occurrence of the package name in the manifest.xml of wear and mobile apps. After the renaming (moving, copying etc.) it all works perfectly. Not a warning, nothing. The watch face behaves as expected, but the gear icon simply disappears.

This is the MOBILE manifest.xml:

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

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

<!-- Permissions required by the wearable app -->
<uses-permission android:name="android.permission.WAKE_LOCK" />


<!-- Location permission used by FitDistanceWatchFaceService -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- All intent-filters for config actions must include the categories
com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION and
android.intent.category.DEFAULT. -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<!-- This activity is needed to allow the user to authorize Google Fit for the Fit Distance
WatchFace (required to view distance). -->
<activity
android:name=".ConfigActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.example.android.wearable.watchface.CONFIG_FIT_DISTANCE" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

</application>

</manifest>

And this is the WEARABLE one:

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

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

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

<!-- Required to act as a custom watch face. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!-- Required for complications to receive complication data and open the provider chooser. -->
<uses-permission android:name="com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA"/>


<!-- Location permission used by FitDistanceWatchFaceService -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BODY_SENSORS"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

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

<uses-library
android:name="com.google.android.wearable"
android:required="false"/>

<activity android:name="android.support.wearable.complications.ComplicationHelperActivity"/>

<!--
All intent-filters for config actions must include the categories
com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION
and android.intent.category.DEFAULT.
-->
<service
android:name=".FitDistanceWatchFaceService"
android:label="@string/fit_distance_name"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face"/>
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/preview_distance"/>
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="@drawable/preview_distance_circular"/>
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="com.example.android.wearable.watchface.CONFIG_FIT_DISTANCE"/>

<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService"/>

<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE"/>
</intent-filter>
</service>

<activity
android:name=".FitDistanceWatchFacePermissionActivity"
android:label="@string/title_activity_fitdistance_watch_face_permission">
</activity>

<activity
android:name=".BodysensorsWatchFacePermissionActivity"
android:label="@string/title_activity_bodysensors_watch_face_permission">
</activity>

</application>
</manifest>

They both work perfectly, if you don't try to rename the package from "com.example.android.wearable.watchface" to something else.

Any clues? Of course I could go on with the "com.example.android.wearable.watchface" package name, but it seems implausible that it's not possible to change the package name.

Thank you!

Veertualia
  • 45
  • 7
  • 1
    Can you include your code after changing the package name ? – Kapouter Feb 17 '17 at 13:53
  • Try to clean the project after renaming the packages sometimes android studio doesn't rebuild the project after the rename. Choose Build -> Clean Project and then run it again. Try also the solution in this [SO question](http://stackoverflow.com/questions/22155938/android-studio-gets-package-name-wrong-when-running-apk). For more information, check this [video](https://www.youtube.com/watch?annotation_id=annotation_653662523&feature=iv&src_vid=RNcrzOMugn8&v=A-rITYZQj0A) that explain how to change the package name in Android Studio. – KENdi Feb 17 '17 at 14:45
  • Hello. Thanks for the link KENdi, , but now something very strange is happening. Even using the sample project from Google (https://github.com/googlesamples/android-WatchFace), without any modification, the Gear icon of the companion app is not showing for any of the various modules composing the project. There should be at least two or three apps inside the project with a companion app on mobile (Sample digital and Sample Analog for example) but no gear icon is showing in the Android Wear app on the phone and the three small pips of these watch faces now show "Install settings app". – Veertualia Feb 19 '17 at 17:59
  • Ok, I had forgot to update the companion app. Removing the directory ~/.gradle/caches/ solved the problem. Thank you KENdi. – Veertualia Feb 19 '17 at 20:14

0 Answers0