Android Wear:更改软件包名称时观察面部伴侣配置活动问题

Android Wear:更改软件包名称时观察面部伴侣配置活动问题,android,xml,wear-os,Android,Xml,Wear Os,我正在开发一款Android Wear watch face及其移动伴侣配置活动。 首先,我遵循文档()并使用Google()提供的示例,特别是FitDistanceService 如果我使用示例中的实际代码,那么一切都会正常工作。小齿轮图标-用于打开伴侣(手机)配置活动-显示在手机上的Android Wear应用程序中,我可以点击它打开伴侣手机配置活动 但是,如果我将软件包名称从默认的“com.example.android.wearable.watchface”重命名为其他名称(甚至是com

我正在开发一款Android Wear watch face及其移动伴侣配置活动。 首先,我遵循文档()并使用Google()提供的示例,特别是FitDistanceService

如果我使用示例中的实际代码,那么一切都会正常工作。小齿轮图标-用于打开伴侣(手机)配置活动-显示在手机上的Android Wear应用程序中,我可以点击它打开伴侣手机配置活动

但是,如果我将软件包名称从默认的“com.example.android.wearable.watchface”重命名为其他名称(甚至是com.example.android.wearable.mycompany),手机上的android Wear应用程序中的gear图标将消失,无法打开配置活动

我试着以任何可能的方式更改包名。我曾尝试在Android Studio(2.2.3版)中使用移动、复制和重命名功能。我尝试使用Sublime文本手动更改包名及其在所有项目文件中出现的所有内容,同时重命名相关文件夹,并更改wear和mobile应用程序的manifest.xml中出现的包名。 重命名(移动、复制等)后,一切都很好。没有警告,什么都没有。手表表面的行为与预期一致,但齿轮图标只是消失

这是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>

这是可穿戴的:

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

如果您不尝试将包从“com.example.android.wearable.watchface”重命名为其他名称,它们都可以完美地工作

有什么线索吗?当然,我可以继续使用“com.example.android.wearable.watchface”包名,但似乎不可能更改包名


谢谢大家!

更改包名后是否可以包含代码?请尝试在重命名包后清理项目有时android studio在重命名后不会重建项目。选择Build->cleanproject,然后再次运行它。也尝试一下这个解决方案。有关更多信息,请选中此选项,说明如何在Android Studio.Hello中更改包名。谢谢KENdi的链接,但是现在发生了一些非常奇怪的事情。即使使用Google()的示例项目,在没有任何修改的情况下,配套应用程序的Gear图标也不会为构成该项目的任何模块显示。项目中应该至少有两到三个应用程序在手机上有一个配套应用程序(例如数字和模拟样本),但手机上的Android Wear应用程序中没有显示gear图标,这些手表的三个小点现在显示“安装设置应用程序”。好吧,我忘记更新配套应用程序了。删除目录~/.gradle/caches/解决了问题。谢谢你,肯迪。