title: Flutter Error: Mapbox java.lang.IllegalAccessError when building in release mode
body: <p>I'm building a mobile app using flutter. Because i needed a map in this project i added Mapbox Gl form pub.dev.
  When i build the project in debug mode, everything works correctly but in release mode via flutter run --release or flutter build apk
  i get the error below
  #java.lang.IllegalAccessError</p>
  <blockquote>
  <p>E/AndroidRuntime(17468): FATAL EXCEPTION: main
  E/AndroidRuntime(17468): Process: com.example.connectiv, PID: 17468
  E/AndroidRuntime(17468): java.lang.IllegalAccessError: Interface
  androidx.lifecy cle.b implemented by class
  com.mapbox.mapboxgl.MapboxMapController is inaccessib le (declaration
  of 'com.mapbox.mapboxgl.MapboxMapController' appears in /data/ap
  p/~~cfRuPsC3U_WxCb2HWrdntg==/com.example.connectiv-hDsXcUANkWTvGTdp92h8zA==/base
  .apk)</p>
  </blockquote>
  <p>here are the different versions used in the project</p>
  <p>Flutter: flutter_windows_2.10.0-stable
  Mapbox Gl: mapbox_gl: ^0.15.0.</p>
  <p>Below my pubspect.yaml file</p>
  <pre><code>name: projectname
  description: A new Flutter project.
  publish_to: 'none'
  version: 1.0.0+1
  environment:
    sdk: &quot;&gt;=2.15.1 &lt;3.0.0&quot;
  dependencies:
    flutter:
      sdk: flutter
    cupertino_icons: ^1.0.2
    mapbox_gl: ^0.15.0
    location: ^4.2.0
    http: ^0.13.4
    circular_menu: ^1.2.3
    video_player: ^2.2.16
    flutter_launcher_icons: ^0.9.2
  dev_dependencies:
    flutter_test:
      sdk: flutter
    flutter_lints: ^1.0.0
    uses-material-design: true
    assets:
      - assets/images/
      - assets/videos/
      - assets/json/
  </code></pre>
  <p>And finally my mapScreen.dart</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:mapbox_gl/mapbox_gl.dart';
  
  class Exemple extends StatefulWidget {
    const Exemple({ Key? key }) : super(key: key);
  
    @override
    _ExempleState createState() =&gt; _ExempleState();
  }
  
  class _ExempleState extends State&lt;Exemple&gt; {
     MapboxMapController? mapController;
    var isLight = true;
  
    _onMapCreated(MapboxMapController controller) {
      mapController = controller;
    }
  
    _onStyleLoadedCallback() {
      ScaffoldMessenger.of(context).showSnackBar(SnackBar(
        content: Text(&quot;Style loaded :)&quot;),
        backgroundColor: Theme.of(context).primaryColor,
        duration: Duration(seconds: 1),
      ));
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          floatingActionButton: Padding(
            padding: const EdgeInsets.all(32.0),
            child: FloatingActionButton(
              child: const Icon(Icons.swap_horiz),
              onPressed: () =&gt; setState(
                () =&gt; isLight = !isLight,
              ),
            ),
          ),
          body: MapboxMap(
            styleString: isLight ? MapboxStyles.LIGHT : MapboxStyles.DARK,
            accessToken: &quot;my_mapbox_public_access_token&quot;,
            onMapCreated: _onMapCreated,
            initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)),
            onStyleLoadedCallback: _onStyleLoadedCallback,
          ));
    }
  }
  </code></pre>
  <p><strong>Really need help, i tried many things to solve this problem but none worked</strong></p>