2017-08-07 191 views
0

我正在嘗試爲1.x和2安裝獨立的Android Wear應用。我遵循了步驟on the android developer page,但用戶說安裝apk不會自動安裝他們的1.x手錶。移動應用擁有相同的權限。這只是在這裏獲得穿apk安裝。移動應用上沒有任何活動。爲Android安裝1.x和2.0包裝分開安裝apk

我是否需要將磨損應用程序打包到我的移動應用程序中?從我讀到的內容來看,即使對於1.x也不應該這樣做。

這裏是什麼我的APK看起來像在開發者控制檯預覽: enter image description here

手機清單:

<?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' 
} 

的gradle磨損:

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' 
} 

[編輯]我不得不更新包括併發症permissio並在移動應用程序中刪除手錶功能以將其上傳到遊戲商店。一些用戶報告說正在安裝,但其他用戶無法使用它。

回答

1

你的假設是正確的,你不應該在手機APK中嵌入穿APK(這是​​做舊的方式)。但是,您仍然需要發佈手機APK。

您的屏幕截圖中只有2個APK。總共應該有3個:電話APK for AW 1.x,穿APK for AW 1.x,穿AW APK的APK。

確保AW 2.0 APK的版本號碼最高,其次是AW 1.x手錶APK,最後是AW 1.x手機APK。

請注意,只有先前發佈帶嵌入式穿戴APK的AW 1.x應用程序時,才需要標記wearAppUnbundled true(在您的手機gradle文件中)(但不應傷害否則將其包括在內)。

+0

從閱讀文檔中,我認爲只有在需要使用sdk 25時才需要使用兩個apks。我只需要23.「如果您想要同時定位SDK版本23和版本25,請更新Wear模塊的版本。如果現有Wear 1.x應用程序的最低SDK版本爲23,則包含以下內容:「是否需要? –

+0

我剛讀了三遍,我的回答是:我真的不知道。至少可以說,這有點令人困惑。我所知道的是,上面的作品適合我。但在我的情況下,AW 2.0 APK支持API等級25+,AW 1.x APK(電話和可穿戴設備)支持API等級20+。不知道這是否有所作爲。 – TofferJ

+0

剛剛得到我的一位用戶的確認,它確實最終與手錶同步。這通常很慢,所以可能只是等待一段時間。我很欣賞這個確認。我會嘗試更新,一旦我發現它是否適用於Android 2.0用戶。 –