Lambda expressions crash with IncompatibleClassChangeError in Android when using jack

前端 未结 1 1806
春和景丽
春和景丽 2021-02-07 12:11

I am using Java 8 in my Android project. I have setup both Jack (In android application module) and Retrolambda (in other modules).

The problem I am having is that my La

1条回答
  •  旧巷少年郎
    2021-02-07 12:49

    Google are no longer supporting android-jack.

    Jack is no longer supported, and you should first disable Jack to use the Java 8 support built into the default toolchain

    Android Studio 3.0 and later supports Lambdas expressions. Configure 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
     }
    }
    

    Note: If Android Studio detects that your project is using Jack, Retrolambda, or DexGuard, the IDE uses Java 8 support provided by those tools instead. However, consider migrating to the default toolchain

    0 讨论(0)
提交回复
热议问题