Moxy 致命异常 - 来自调用站点 #0 bootstrap 方法的异常
Moxy Fatal Exception - Exception from call site #0 bootstrap method
Moxy 的示例代码不起作用
https://github.com/moxy-community/Moxy
源代码被分离到不同的文件中,但现在呈现为不太复杂的视图
空应用程序(没有任何 MVP,它只有一个空屏幕)工作
但是,如果我像示例中那样添加代码,它会因致命异常而崩溃(如下所示)
interface ExplorerView : MvpView {
@StateStrategyType(AddToEndSingleStrategy::class)
fun foo()
}
@InjectViewState
class ExplorerPresenter : MvpPresenter<ExplorerView>() {
fun loadFiles() {}
}
class ExploreActivity : MvpAppCompatActivity(), ExplorerView {
@InjectPresenter
internal lateinit var explorerPresenter: ExplorerPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_explorer)
isPermissionsGranted()
}
private fun isPermissionsGranted() {
explorerPresenter.loadFiles()
}
}
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.birdyteam.filesexplorer, PID: 19725
java.lang.BootstrapMethodError: Exception from call site #0 bootstrap method
at moxy.MvpDelegate.<clinit>(MvpDelegate.java:37)
at moxy.MvpAppCompatActivity.getMvpDelegate(MvpAppCompatActivity.java:76)
at moxy.MvpAppCompatActivity.onCreate(MvpAppCompatActivity.java:27)
at com.birdyteam.filesexplorer.presentation.ui.ExploreActivity.onCreate(ExploreActivity.kt:28)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: Bootstrap method returned null
at moxy.MvpDelegate.<clinit>(MvpDelegate.java:37)
at moxy.MvpAppCompatActivity.getMvpDelegate(MvpAppCompatActivity.java:76)
at moxy.MvpAppCompatActivity.onCreate(MvpAppCompatActivity.java:27)
at com.birdyteam.filesexplorer.presentation.ui.ExploreActivity.onCreate(ExploreActivity.kt:28)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
在您的 build.gradle
文件中启用 Java8 功能:
android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// For Kotlin projects
kotlinOptions {
jvmTarget = "1.8"
}
}
有关完整文档,请参阅 here。
Moxy 的示例代码不起作用 https://github.com/moxy-community/Moxy 源代码被分离到不同的文件中,但现在呈现为不太复杂的视图
空应用程序(没有任何 MVP,它只有一个空屏幕)工作 但是,如果我像示例中那样添加代码,它会因致命异常而崩溃(如下所示)
interface ExplorerView : MvpView {
@StateStrategyType(AddToEndSingleStrategy::class)
fun foo()
}
@InjectViewState
class ExplorerPresenter : MvpPresenter<ExplorerView>() {
fun loadFiles() {}
}
class ExploreActivity : MvpAppCompatActivity(), ExplorerView {
@InjectPresenter
internal lateinit var explorerPresenter: ExplorerPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_explorer)
isPermissionsGranted()
}
private fun isPermissionsGranted() {
explorerPresenter.loadFiles()
}
}
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.birdyteam.filesexplorer, PID: 19725
java.lang.BootstrapMethodError: Exception from call site #0 bootstrap method
at moxy.MvpDelegate.<clinit>(MvpDelegate.java:37)
at moxy.MvpAppCompatActivity.getMvpDelegate(MvpAppCompatActivity.java:76)
at moxy.MvpAppCompatActivity.onCreate(MvpAppCompatActivity.java:27)
at com.birdyteam.filesexplorer.presentation.ui.ExploreActivity.onCreate(ExploreActivity.kt:28)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: Bootstrap method returned null
at moxy.MvpDelegate.<clinit>(MvpDelegate.java:37)
at moxy.MvpAppCompatActivity.getMvpDelegate(MvpAppCompatActivity.java:76)
at moxy.MvpAppCompatActivity.onCreate(MvpAppCompatActivity.java:27)
at com.birdyteam.filesexplorer.presentation.ui.ExploreActivity.onCreate(ExploreActivity.kt:28)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
在您的 build.gradle
文件中启用 Java8 功能:
android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// For Kotlin projects
kotlinOptions {
jvmTarget = "1.8"
}
}
有关完整文档,请参阅 here。