Android: Creating wearable apps-packaged releases

Source: Internet
Author: User

Packaged wearable apps (packaging wearable apps) include packaging with Android studio and manually packaging and turning off resource compression (Turn off Asset Compression).
When the app is published, you have to package the wearable app into a mobile app, because users can't browse and install apps directly on wearables.
If packaged correctly, when the user downloads the phone app, the system automatically pushes the wearable app to the paired wearable device.

Note: This feature does not work for apps that use a debug key signature and must be installed directly in the development process using ADB install or Android studio.
Packaging with Android Studio declare a gradle dependency in the Build.gradle file of your mobile app, point to wearable application module:
dependencies {   compile ' com.google.android.gms:play-services:[email protected] '   compile ' com.android.support:support-v4:20.0.+ '   Wearapp project (': Wearable ')}
Click Build > Generate signed APK... Then follow the onscreen instructions to specify your publishing key store (release KeyStore) and sign it.
Android Studio automatically exports signed, embedded wearable module apps to your project's root directory.
In addition, you can create a signingconfig rule in the Build.gradle file of the wearable and mobile module to sign with your publishing key.
Two application modules must be signed so that the automatic push publishing function is used normally.
Android {  ...  Signingconfigs {    Release {      keyalias ' myalias '      keypassword ' mypw '      storefile file (' path/to/ Release.keystore ')      storepassword ' MYPW '    }  }  buildtypes {    release {      ...      Signingconfig signingconfigs.release    }d  }  ...}

Click the Gradle button in the right sidebar toolbar of Android Studio to compile the mobile app and run the Assemblerelease task.

This task is located in: Project name > Phone Module name > Assemblerelease.

Note: This example embeds the password into your gradle file, which may not be appropriate. To replace the password with a system variable, see Configure signing settings.
sign wearables and mobile apps separately
If the compilation process requires a separate signature of the wearable application,
You can declare the following gradle rule in the Build.gradle file of your phone module to embed the signed wearable app:
dependencies {  ...  Wearapp files ('/path/to/wearable_app.apk ')}
You can then use any of the methods to sign the phone app (menu item Android Studio Build > Generate signed APK ... or Gradle signingconfig rules as described above).
Manual packaging (Package manually) if you use other development tools, you can also do it by hand.
Copy your signed wearable app to the Res/raw directory of your mobile app project. We will refer to this apk by wearable_app.apk.
Create a Res/xml/wearable_app_desc.xml file that contains the version and path information for the app. Like what:
<wearableapp package= "Wearable.app.package.name" >  <versionCode>1</versionCode>  < versionname>1.0</versionname>  <rawPathResId>wearable_app</rawPathResId> </ Wearableapp>
Package, Versioncode and Versionname are the same as those specified in the Wearable app Androidmanifest.xml file. Rawpathresid is the static variable name of the API resource.
For example, for wearable_app.apk, the static variable is named Wearable_app.
Add a meta-data tag to your mobile app's <application> tag to refer to the Wearable_app_desc.xml file.
  <meta-data android:name= "Com.google.android.wearable.beta.app"                  android:resource= "@xml/wearable_app_desc" />
Compile your phone app and sign it.
Turn off resource compression (Asset Compression) Many compilation tools automatically compress files that are added to Res/raw. However, because the wearable app's apk has been compressed, and if it is re-compressed by another tool, the installer (Installer) will not be able to read the wearable app and the installation fails.
In the mobile app, the Packageupdateservice log records the following error: "This file cannot is opened as a file descriptor; It is probably compressed. "

Android Studio does not compress your apk files by default, but if you use other development tools, make sure that you do not compress two times.


by Iefreer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.