kotlin dagger injection - Android

By Lauren
at 2016-05-26T12:40
at 2016-05-26T12:40
Table of Contents
想請教一個dagger injection 的問題
目前是寫espresso test, 要注入一個isTabletEnabled參數
這樣寫
@Inject @Identifier boolean isTabletEnabled
這樣在java file 當中沒有問題
但是copy 到kotlin 檔案中被轉成
@Inject @Identifier internal var isTabletEnabled: Boolean = false
編譯會過, 但是在執行時會跑出can't inject to private field 錯誤,
stackoverflow 上面看到是教人用constructor injection
但我這是跑test, class & method 都不能有參數
想請問看看有沒有人有甚麼想法
--
目前是寫espresso test, 要注入一個isTabletEnabled參數
這樣寫
@Inject @Identifier boolean isTabletEnabled
這樣在java file 當中沒有問題
但是copy 到kotlin 檔案中被轉成
@Inject @Identifier internal var isTabletEnabled: Boolean = false
編譯會過, 但是在執行時會跑出can't inject to private field 錯誤,
stackoverflow 上面看到是教人用constructor injection
但我這是跑test, class & method 都不能有參數
想請問看看有沒有人有甚麼想法
--
Tags:
Android
All Comments

By Doris
at 2016-05-31T10:48
at 2016-05-31T10:48
Related Posts
用chromecast看bilibili

By Ina
at 2016-05-26T09:50
at 2016-05-26T09:50
google文字轉語音 中英混讀?

By Kelly
at 2016-05-26T09:19
at 2016-05-26T09:19
開發人員選項中的記錄器緩衝區大小用途

By Noah
at 2016-05-26T08:58
at 2016-05-26T08:58
820鎖定螢幕如何更換音樂

By John
at 2016-05-26T08:30
at 2016-05-26T08:30
line存取的手機資訊僅限於以line進行的?

By Queena
at 2016-05-26T04:55
at 2016-05-26T04:55