Android Wear:更改软件包名称时,请查看配置面配置活动问题

时间:2017-02-17 01:00:45

标签: android xml wear-os

我正在开发Android Wear手表及其移动配套配置活动。 首先,我按照文档(https://developer.android.com/training/wearables/watch-faces/configuration.html#CompanionActivity)使用了Google(https://developer.android.com/samples/WatchFace/index.html)提供的示例,特别是FitDistanceService。

如果我使用示例中的实际代码,则一切正常。小齿轮图标 - 用于打开随播(电话)配置活动 - 显示在手机上的Android Wear应用程序中,我可以通过点击它来打开配套电话配置活动。

但是,如果我将包名称从默认的“com.example.android.wearable.watchface”重命名为其他任何内容(甚至是com.example.android.wearable.mycompany),齿轮图标将从Android Wear应用程序中消失电话,无法打开配置活动。

我尝试以任何可能的方式更改包名称。我尝试在Android Studio中使用移动,复制,重命名功能(v.2.2.3)。我尝试使用Sublime Text手动更改所有项目文件中的包名及其所有出现,同时重命名相关文件夹并更改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”包名,但似乎不可能更改包名。

谢谢!

0 个答案:

没有答案
相关问题