2

Sample code from Moxy doesn't work https://github.com/moxy-community/Moxy Source code is separated to different files, but now presented for less complicated view

Empty application (without anything with MVP, it only has one empty screen) works But if I add code as in the example it crashes with a fatal exception (provided below)

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) 
Pete Ythong
  • 305
  • 5
  • 13
Aroize
  • 61
  • 6

1 Answers1

4

Enable Java8 features in your build.gradle file:

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"
   }
}

See here for full documentation.

kenny_k
  • 3,831
  • 5
  • 30
  • 41
Aroize
  • 61
  • 6
  • 1
    A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted](//stackoverflow.com/help/deleted-answers). – Machavity Oct 01 '19 at 12:49