Getting error in Android Studio 2.1 with java 8

前端 未结 5 1982
抹茶落季
抹茶落季 2021-01-07 18:27

Currently I am using java 8 with latest android studio 2.1

Here is my build.gradle file

android {
    compile         


        
相关标签:
5条回答
  • 2021-01-07 18:56

    Try to use next values:

    compileSdkVersion = "android-N"
    buildToolsVersion = "24.0.0 rc3"
    
    0 讨论(0)
  • 2021-01-07 19:07

    I had this error too, and what I found was that the error itself was masking another compilation issue. Look at your Console Messages carefully and see if there is something else not compiling. Once I solved the underlying issue with my own code, this error magically disappeared. Hope this helps.

    0 讨论(0)
  • 2021-01-07 19:09

    you can try

    compileSdkVersion 23
    buildToolsVersion '24.0.0-rc3'
    

    note the dash before rc3. This is according to http://developer.android.com/preview/setup-sdk.html under the section "Update an existing project"

    I am using 23 just for the lambda.

    the following link shows the Supported Java 8 Language Features and APIs https://developer.android.com/preview/j8-jack.html

    0 讨论(0)
  • 2021-01-07 19:12

    I think we are all looking mostly at the same answer. To be precise I'd say "make sure the buildToolsVersion = "[version]" is the same as the [version] in the error".
    For some this will be 24.0.0

    0 讨论(0)
  • 2021-01-07 19:12

    Some java 8 features only support Android N. read android docs http://developer.android.com/preview/j8-jack.html#configuration

    When I use Default Methods on sdk23, I got this error too. so update your sdk version to Android N.

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