Skip to content

Revert support for java 1.7 or figure a way to use java 8 features while maintaining compatibility for Android before N #832

Closed

Description

@freszu

WHat kind of issue is this?
Bug Report

This issue was already brought up here : mapbox/mapbox-gl-native#11392 and solution was going back to 1.7, this is most likely the PR that caused this issue: #770

Expected Behavior

Everything compiles while supporting lowest android sdk supported by mapbox: 14.

Current Behavior

App won't compile unless i target Android N

AGPBI: {"kind":"error","text":"Static interface methods are only supported starting with Android N (--min-api 24): com.mapbox.geojson.Geometry com.mapbox.geojson.Geometry.fromJson(java.lang.String)","sources":[{}],"tool":"D8"}

Possible Solution

Context (Environment)

Build Tools: com.android.tools.build:gradle:3.1.2
MinSdk: 21
mapBoxServicesVersion = '3.2.0'

Activity

  1. tobrun commented on Jun 7, 2018

    @tobrun
    Member

    App won't compile unless i target Android N, the shown error can throw you off but you don't actually need to target Android N to use java8 language features.

    From your java8-support link:

    After that, for each module that uses Java 8 language features (either in its source code or through dependencies), update the Source Compatibility and Target Compatibility to 1.8 in the Project Structure dialog as shown in figure 2 (click File > Project Structure).

    so you are required to use the following in your build.gradle:

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

    This issue is not actionable for us, java8 is the way forward.

  2. osana commented on Jun 7, 2018

    @osana
    Contributor
  3. freszu commented on Jun 7, 2018

    @freszu
    ContributorAuthor

    Haven't seen this was updated back to 1.8 in 12041. No one had a chance to cause him any issues there yet most likely though.
    If MapBox decided to stay with 1.8 it would be nice to have it explicitly written to change the compile options in readme and other places (website) , this will be especially the case for main mapbox dependency when it gets updated as many people that are using kotlin and don't have java 1.8 options enabled will stumble upon this. The error logs from compiler are nowhere helpfull and suggest that only possible solution is jumping on 24 sdk and it's the first time i am coming across such issue.

    Anyway for me that seems to fix the issue as the app started to compile back again thanks for fast response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions