2017-12-03 186 views
0

我想將我的Android應用程序從Java轉換爲Kotlin。 對於應用程序快捷方式,我使用shortbread庫,它非常易於實現,但它在Kotlin中不起作用。難道我做錯了什麼 ?Kotlin中的註釋不起作用

的Java:

@Shortcut(id = "Camera", icon = R.drawable.iconshortcut,longLabel = "Instant Scan", shortLabel = "Scan") 

public class CameraActivity extends AppCompatActivity { ... 

科特林:

@Shortcut(id = "Camera", icon = R.drawable.iconshortcut, longLabel = "Instant Scan", shortLabel = "Scan") 

class CameraActivity : AppCompatActivity() { ... 

酥餅正在每當註釋是在Java中,但不是在科特林

Shortbread.create(this) 

回答

0

你需要使用kotlin-kapt插件能夠解析Kotlin文件中的註釋:

apply plugin: 'kotlin-kapt' 

dependencies { 
    ... 
    implementation 'com.github.matthiasrobbers:shortbread:1.0.2' 
    kapt 'com.github.matthiasrobbers:shortbread-compiler:1.0.2' 
} 

如果這樣不起作用,那麼在項目的GitHub倉庫中打開一個問題可能是有意義的。

+0

哇,非常感謝,它的工作! –