Android Wear 2.0 support for Face Face app

I have an Android watch app that has both mobile and wear modules.

I want this application to be ready for upgrade 2.0, and I visited all the websites that Android developers offer, I understand almost everything that is going to change, but then reality comes in, and I'm stuck with the first simple steps.

As I read here :

If you create a standalone Wear 2.0 APK and continue to use Wear 1.0 APK, follow these steps:

Provide a standalone version of Wear APK and continue embedding the Wear Wear version on your APK phone

Then here we have:

If your app supports both Wear 1.x and Wear 2.0, continue to integrate APK Wear 1.x APK (minimum SDK version 20, 21, 22 or 23) into the APK and download the APK phone. Alternatively, download the standalone Wear 2.0 APK (which has a minimum version of SDK 24).

Since I want to support Android 1.x support, what should I do for sure?

How to set SDK version numbers in modules?

Do I need to duplicate a wear module with a modified version of the SDK to create a separate portable apk?

Gold and the kingdom for all who have done this successfully, and will present all the necessary steps to ensure application compatibility for current and upcoming Wear versions.

+4
source share
1 answer

, , -, , , Play .

Manifest fileable

<uses-feature android:name="android.hardware.type.watch" />
<application ...>
    <meta-data
        android:name="com.google.android.wearable.standalone"
        android:value="true" />
    ...
</application>

Gradle

// wearable module

dependencies {
    compile 'com.google.android.support:wearable:2.0.0'
    compile 'com.google.android.gms:play-services-wearable:10.0.1'
    ...
}

android {
    compileSdkVersion 25
    publishNonDefault true
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId = "com.example.watchface"
        minSdkVersion 20
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    productFlavors {
        wear1 {

        }
        wear2 {
            minSdkVersion 24
            versionCode 2 // +1 relatively to default value
        }
    }
    ...
}

SDK:

  • compile target = 25,
  • default min = 20 ( 1.x),
  • 2.0 = 24

: wear 2.0 apk , .

, : wear1 wear2. .

Gradle

// mobile module

dependencies {
    compile 'com.google.android.support:wearable:2.0.0'
    compile 'com.google.android.gms:play-services-wearable:10.0.1'
    ...
    wearApp project(path:':Wearable', configuration: "wear1Release")
}

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId = "com.example.watchface"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    ...
}

SDK:

  • compile target = 25,
  • min = 18

: , (1).

, configuration wearApp project() apk, "Release": wear1Release

APK

  • APK,
  • APK, ,
  • APK ( apk ).

APK Google Play

  • ,
  • apk wear2 apk.
+5

Source: https://habr.com/ru/post/1667896/


All Articles