如何使用 ant 而不是 gradle 将可穿戴 apk 嵌入到移动 apk 中

How to embed a wearable apk into a mobile apk using ant rather than gradle

我们公司有一个庞大而复杂的 ant 构建系统,用于构建包含数十个 android 项目的庞大套件,这些项目全部构建到一个 .apk 中。

我想将可穿戴应用合并到其中,但我不知道如何将可穿戴 .apk 嵌入到移动 .apk 中。

在 Android Studio / Gradle 中,通过简单地将 wear apk 作为移动 apk 的依赖项添加到移动设备 build.gradle 中,此嵌入式自动处理。

有人知道如何在 gradle 未使用时将 wear apk 嵌入到移动 apk 中吗?

包装可穿戴应用培训包含 packaging manually 的所有步骤:

  1. Include all the permissions declared in the manifest file of the wearable app in the manifest file of the mobile app. For example, if you specify the VIBRATE permission for the wearable app, you must also add that permission to the mobile app.
  2. Ensure that both the wearable and mobile APKs have the same package name and version number.
  3. Copy the signed wearable app to your handheld project's res/raw directory. We'll refer to the APK as wearable_app.apk.
  4. Create a res/xml/wearable_app_desc.xml file that contains the version and path information of the wearable app. For example:
<wearableApp package="wearable.app.package.name">
   <versionCode>1</versionCode>
   <versionName>1.0</versionName>
   <rawPathResId>wearable_app</rawPathResId> 
</wearableApp>
  1. Add a meta-data tag to your handheld app's <application> tag to reference the wearable_app_desc.xml file.
<meta-data android:name="com.google.android.wearable.beta.app"
  android:resource="@xml/wearable_app_desc"/>
  1. Build and sign the handheld app.

这些步骤中的很多都可以一次完成 - 最重要的步骤是第 3 步,在该步骤中,您可以在构建应用程序之前将生成的 Wearable APK 复制到正确的位置。