簡體   English   中英

包裝用於Android Wear 1.x和2.0的單獨Wear APK

[英]Packaging separate wear apks for android wear 1.x and 2.0

我正在嘗試為1.x和2創建一個獨立的Android Wear應用程序。我按照android開發人員頁面上的步驟進行操作 ,但用戶表示Wear apk不會自動安裝在其1.x手表上。 移動應用具有相同的權限。 只有在這里可以安裝Weapk APK。 移動應用上沒有任何活動。

我是否需要將Wear應用打包在我的移動應用中? 根據我的閱讀,即使對於1.x,也不應該這樣做。

這是我的apk在開發人員控制台中的外觀預覽: 在此處輸入圖片說明

移動清單:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/Theme.Nav">

</application>

磨損清單:

<?xml version="1.0" encoding="utf-8"?>

<uses-feature android:name="android.hardware.type.watch" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

<!-- Required for complications to receive complication data and open the provider chooser. -->
<uses-permission android:name="com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA"/>

<application
    android:name=".App"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/Theme.Nav">
    <uses-library
        android:name="com.google.android.wearable"
        android:required="false" />

    <meta-data
        android:name="com.google.android.wearable.standalone"
        android:value="true" />

    <activity android:name=".ui.activity.SplashActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- Main activity for music browsing on phone -->
    <activity android:name=".ui.activity.MainActivity"
        android:launchMode = "singleTop">
    </activity>

    <service android:name=".service.MediaPlayerService" />

    <activity android:name="android.support.wearable.activity.ConfirmationActivity" />

    <!--
     Main music service, provides media browsing and media playback services to
     consumers through MediaBrowserService and MediaSession. Consumers connect to it through
     MediaBrowser (for browsing) and MediaController (for play session control)
    -->

    <service android:name=".service.FsService" />
    <service android:name=".service.NsdService" />

    <receiver
        android:name=".service.NsdService$StartStopReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="com.turndapage.navmusic.FTPSERVER_STARTED" />
            <action android:name="com.turndapage.navmusic.FTPSERVER_STOPPED" />
        </intent-filter>
    </receiver>

    <!-- Don't export this receiver in free, this clashes with paid -->
    <receiver
        android:name=".RequestStartStopReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="com.turndapage.navmusic.ACTION_START_FTPSERVER" />
            <action android:name="com.turndapage.navmusic.ACTION_STOP_FTPSERVER" />
        </intent-filter>
    </receiver>
    <receiver android:name=".WifiStateChangeReceiver">
        <intent-filter>
            <action android:name="android.net.wifi.STATE_CHANGE" />
        </intent-filter>
    </receiver>

    <service android:name=".WifiStateChangeReceiver$StartServerService" />
    <service android:name=".WifiStateChangeReceiver$StopServerService" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <service
        android:name=".watchface.AnalogComplicationWatchFaceService"
        android:enabled="true"
        android:label="@string/my_analog_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_analog" />
        <meta-data
            android:name="com.google.android.wearable.watchface.preview_circular"
            android:resource="@drawable/preview_analog" />
        <meta-data
            android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
            android:value="com.turndapage.navmusic.CONFIG_COMPLICATION_SIMPLE"/>

        <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="android.support.wearable.complications.ComplicationHelperActivity"/>
    <activity
        android:name=".config.AnalogComplicationConfigActivity"
        android:label="@string/analog_complication_config">
        <intent-filter>
            <action android:name="com.turndapage.navmusic.CONFIG_COMPLICATION_SIMPLE"/>

            <category android:name="com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>

    <receiver android:name=".provider.ComplicationToggleReceiver"/>

    <activity android:name=".config.ColorSelectionActivity"/>

    <service android:name=".provider.CurrentSongComplicationProvider"
        android:icon="@drawable/ic_library_music_white_24dp"
        android:label="@string/current_song"
        android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER">
        <intent-filter>
            <action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST"/>
        </intent-filter>

        <meta-data
            android:name="android.support.wearable.complications.SUPPORTED_TYPES"
            android:value="SHORT_TEXT,LONG_TEXT"/>

        <meta-data
            android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
            android:value="0"/>
    </service>

    <service android:name=".provider.SkipBackComplicationProvider"
        android:icon="@drawable/ic_skip_previous_white_24dp"
        android:label="@string/skip_back"
        android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER">
        <intent-filter>
            <action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST"/>
        </intent-filter>

        <meta-data
            android:name="android.support.wearable.complications.SUPPORTED_TYPES"
            android:value="ICON"/>

        <meta-data
            android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
            android:value="0"/>
    </service>

    <service android:name=".provider.SkipForwardComplicationProvider"
        android:icon="@drawable/ic_skip_next_white_24dp"
        android:label="@string/skip_next"
        android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER">
        <intent-filter>
            <action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST"/>
        </intent-filter>

        <meta-data
            android:name="android.support.wearable.complications.SUPPORTED_TYPES"
            android:value="ICON"/>

        <meta-data
            android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
            android:value="0"/>
    </service>

    <service android:name=".provider.PlayPauseComplicationProvider"
        android:icon="@drawable/ic_media_play_dark"
        android:label="@string/play_pause"
        android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER">
        <intent-filter>
            <action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST"/>
        </intent-filter>

        <meta-data
            android:name="android.support.wearable.complications.SUPPORTED_TYPES"
            android:value="ICON"/>

        <meta-data
            android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
            android:value="0"/>
    </service>

    <!-- Watch face stuff -->

</application>

移動搖籃:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.turndapage.navmusic"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 260350011
    versionName "0.3.5"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    wearAppUnbundled true
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
jcenter()
maven {
    url 'https://maven.google.com'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}

磨損量:

plugins {
id "me.tatarka.retrolambda" version "3.5.0"
}
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.turndapage.navmusic"
    minSdkVersion 23
    targetSdkVersion 26
    versionCode 260350010
    versionName "0.3.5"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
// Needed for retrolambda
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
jcenter()
maven {
    url 'https://maven.google.com'
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.support:wearable:2.0.3'
compile 'com.android.support:wear:26.0.1'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'com.google.android.exoplayer:exoplayer:r2.4.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.kabouzeid:app-theme-helper:1.3.7'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:preference-v7:26.0.1'
compile 'com.android.support:mediarouter-v7:26.0.1'
compile 'com.android.support:percent:26.0.1'
compile 'net.vrallev.android:cat:1.0.5'
compile 'org.projectlombok:lombok:1.16.18'
compile 'com.twofortyfouram:android-plugin-client-sdk-for-locale:4.0.2'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'com.google.android.gms:play-services-fitness:11.0.4'
compile 'com.android.support:palette-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
provided 'com.google.android.wearable:wearable:2.0.3'
}

[編輯]我必須進行更新以包含並發症權限,並刪除移動應用程序上的觀看功能,才能將其上傳到Play商店。 一些用戶報告說它正在安裝,但其他用戶無法使它正常工作。

您的假設是正確的,您不應該將磨損APK嵌入手機APK中(這是過去的做法)。 但是,您仍然需要發布手機APK。

屏幕截圖中只有2個APK。 一共有3個:針對AW 1.x的手機APK,針對AW 1.x的手機APK和針對AW 2.x的APK。

確保AW 2.0 APK具有最高版本代碼,其次是AW 1.x手表APK,最后是AW 1.x手機APK。

請注意,僅當您之前發布了帶有嵌入式Wear APK的AW 1.x應用程序時,才需要wearAppUnbundled true標志(在您的手機gradle文件中)(但包括它也不會受到傷害)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM