When I run my instant app I'm experiencing a crash due to the shortcut feature, please see the image with the stack trace, this is the only thing I can provide as I'm not able to attach the debugger, another problem :(
**GroupApplication.class**
override fun onCreate() {
...
ShortcutsHelper.init(this)
ShortcutsHelper.addSearchShortcut()
}
object ShortcutsHelper {
lateinit var appContext: Context
lateinit var shortcutManager: ShortcutManager
fun init(context: Context) {
this.appContext = context.applicationContext
this.shortcutManager = context.getSystemService(ShortcutManager::class.java)
}
fun addSearchShortcut() {
val shortcut = ShortcutInfo.Builder(appContext, SEARCH_SHORTCUT_ID)
.setShortLabel(appContext.getString(R.string.search_shortcut_short_label))
.setLongLabel(appContext.getString(R.string.search_shortcut_long_label))
.setIcon(Icon.createWithResource(appContext, R.drawable.ic_search_black))
.setIntent(GroupHomeActivity.getStartIntent(appContext, NavigationScreen.SEARCH))
.build()
shortcutManager.addDynamicShortcuts(listOf(shortcut))
}
I understand that a shortcut does not make any sense in an Instant App, is there a better solution than having all the code related to shortcuts commented when creating an IA?