java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalDate; error

后端 未结 3 856
情话喂你
情话喂你 2021-01-20 03:20

I tried everything, but the error not getting solved

Here is my code:

public String[] getWeekDays() {

    LocalDate today = LocalDate.now();
    Loc         


        
3条回答
  •  梦毁少年i
    2021-01-20 03:58

    NoClassDefFoundError-Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

    LocalDate today = LocalDate.now(); // Added 1.8
    

    Read LocalDate

    Make sure, You added this in your build.gradle section.

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        }
    

    FYI

    java.time package was added only in API 26.

    So, You should set

     minSdkVersion 26
    

    After that, Clean-Rebuild-Gradle.

提交回复
热议问题