Getting Started with android TV Apps

Designing App for Android TV

為了支援便當(BANDOTT),我發現我的app都無法在電視上看到.
開始改設計囉..

specific design requirements to appear as an Android TV app:

-A large screen UX: TV的USER行為跟smartphone是不同的,所以要改很多地方.
與使用手機及平板電腦相較,使用者觀看電視時具有不同的一組預期。通常,電視使用者與螢幕的距離大約為 3M,因此微小的細節不太引人注目,而且小文字很難閱讀。
由於使用者與電視之間有一段距離,因此必須使用遙控器執行導覽與選取,而非觸碰螢幕上的元素。這些不同之處導致為電視使用者提供良好體驗的構成要素具有顯著不同的需求。

-TV devices using a directional pad (D-Pad).


-基本安裝與app要求:

>>Prerequisites(Before you begin building apps for TV)

1.Update your SDK tools to version 24.0.0 or higher
2.targets api >= Android 5.0 (API level 21) or higher
(The updated platform version provides new APIs for TV app)
3.Activity for TV (Required) - In your application manifest, declare an activity that is intended to run on TV devices.


請先按照google 的建議 更新app code:
以下就不重複寫出,列出一些踩到的坑:

>>Building Layouts for TV
--Provide a home screen banner: xhdpi resource with a size of 320 x 180 px.

--manifest 增加:
<uses-feature      android:name="android.software.leanback"      android:required="true" />
<uses-feature      android:name="android.hardware.touchscreen"      android:required="false" />

--->
issue 1: Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

solution:
I had the same problem when I update from com.google.android.gms:play-services:11.2.2 to com.google.android.gms:play-services:11.4.0.
This solved it for me:
  1. clean
  2. rebuild
-->
issue 2:     All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.0, 25.2.0. Examples include

solution:
Run
gradlew -q dependencies app:dependencies
看看有什麼package是用舊的.
在把他加進來,用新的版號,跟support library 一樣才可.他會錯就是因為有package 用舊的.
implementation 'com.android.support:palette-v7:27.0.2' 
implementation 'com.android.support:mediarouter-v7:27.0.2' 

如果不想寫死版號,可以用27.+
implementation 'com.android.support:palette-v7:27.+' 
前面的27.+一定要寫,不能全部用+,會找不到導致出錯.
這樣27.0.1~27.x.x都可自動升級.

--->
issue 3:  
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
 
solution:
If your minSdkVersion is set to 21 or higher, all you need to
do is set multiDexEnabled to true in your
 module-level build.gradle file, as shown here:

電視tv 要求api level=21. 所以直接加這行. 
android {
    defaultConfig {
       multiDexEnabled true
    }
}
 
--->
issue 4:
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
 
solution:
 project- clear -rebuild



--------------
模擬器實在太慢,又沒有google play store.
不知為何google沒把google play store放在模擬器上,
這樣x86開發者都不知怎麼安裝app.


只好用實機.
我手邊正好有一台foxconn bandott.

便當後面有一個usb type a 公,大家不要呆呆去買usb-a公-對a公連接線,接了也沒用喔.
我就是買了一條,結果都接上都沒反應.
要用cmd下執行 adb connect 便當的ip, 透過wifi來debug, install apk.
bandott要跟電腦在同一個區網下.
logcat也可以看到,只是每次重開機都要重新聯結一次.




問題又產生了:
 1.然後好不容易上架了後,還要審核.
跟上架一般手機app不同.
要等好幾天.


2.admob插屏廣告都不行run,因為他說
This app is using a lightweight version of the Google Mobile Ads SDK that requires the latest Google Play services to be installed, but Google Play services is either missing or out of date.

---> 2018.1.6.暫時無解,因為play store不會允許你安裝這個apk.
搞這又花了好幾天.目前還沒能上架成功.



簡單測試後,發現poweroff 再power-on 後進入app會當機,於是就要修正bug,
然後,最後終於修正了快10小時,app才正常不會當機, 別高興啊~
還要經過google審核app啊~
然後~過幾天收到..
嗚~想哭....

仔細看原因:
App status: Your app has not been accepted into Android TV.
Eligibility issues by APK version:

APK Version(s) Eligibility Issue
11Play/Pause key event is not respected during playback
Your media apps that play video or music content must respect the play/pause key during playback. Please refer to our Media Play/Pause documentation and Update the Playback State documentation for details.

看不懂他到底要什麼?
play/pause key event????
一頭霧水.

繼續找答案:
According to the Android TV Design Guidelines in order to get an application accepted and published into Google Play an Android TV app that plays video or must content must respect the play/pause key during playback. This application doesn't handle any of the PLAY, PAUSE, or PLAY_PAUSE buttons on the PlaybackActivity.java and as a sample of an application that adheres to these guidelines an update should be made to bring this sample back into compliance with these published guidelines.
Please refer to our Media Play/Pause documentation for details:
http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MEDIA_PLAY_PAUSE


發現好像要send KEY.
adb shell input keyevent [keycode]
 
那我就來SEND看看,看到底會發生啥事? 
adb shell input keyevent 85
ps:KEYCODE_MEDIA_PLAY_PAUSE=85 
 
經測試後, 會pause/play...有動作阿~~~
怎麼會說我沒實作?? google 的人實在是....xsadamekooxx 
 
--->TRY AGAIN...
ADD  Now Playing Card:
再上傳APK來審核看看吧...
不知又要等幾天...
 
2018.1.15.
等好久又被拒絕.
Play/Pause key event is not respected during playback
Your media apps that play video or music content must respect the play/pause key during playback. Please refer to our Media Play/Pause documentation and Update the Playback State documentation for details.

google給的理由根本就含糊不清,叫我自己去看guide.
但guide的內容太多,簡直就是一章十個條目叫我自己去比對. 
我都不知錯在哪...
煩啊. 

 

留言

張貼留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

舊有app在Android 12 閃退問題& app Splash screens

google play 正式發布前測試報告...非常好用.

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器