liodali / osm_flutter

OpenStreetMap plugin for flutter
https://pub.dev/packages/flutter_osm_plugin
MIT License
235 stars 97 forks source link

Problem with `permission_handler` #313

Open Myzel394 opened 2 years ago

Myzel394 commented 2 years ago

I couldn't use the newest version of flutter_osm_plugin because it depends on permission_handler ^10.0.0 and this requires a compileSdkVersion of 33.

Instead, I tried to use permission_handler: ^8.3.0 and flutter_osm_plugin: ^0.30.0, but this lead to the following error:

Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...

../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/lib/src/widgets/mobile_osm_flutter.dart:103:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addObserver(this);
                   ^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/lib/src/widgets/mobile_osm_flutter.dart:145:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.removeObserver(this);
                   ^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/lib/src/widgets/mobile_osm_flutter.dart:152:22: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/binding.dart').
      WidgetsBinding.instance?.addPostFrameCallback((timeStamp) async {
                     ^
e: ~/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmPlugin.kt: (59, 63): Smart cast to 'Activity' is impossible, because 'register.activity()' is a complex expression
e: ~/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmPlugin.kt: (76, 13): Smart cast to 'OsmFactory' is impossible, because 'factory' is a mutable property that could have been changed by this time
e: ~/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/OsmFactory.kt: (14, 6): Class 'OsmFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: ~/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.30.1+2/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/OsmFactory.kt: (21, 5): 'create' overrides nothing

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_osm_plugin:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Exception: Gradle task assembleDebug failed with exit code 1

and when I simply type flutter pub add flutter_osm_plugin and let flutter determine the correct version, which results in a combi of permission_handler: ^9.0.0 and flutter_osm_plugin: ^0.28.2, the following error occurs:

e: ~/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_osm_plugin-0.28.2/android/src/main/kotlin/hamza/dali/flutter_osm_plugin/FlutterOsmPlugin.kt: (58, 75): Smart cast to 'Activity' is impossible, because 'register.activity()' is a complex expression
liodali commented 2 years ago

and you don't want to use compileSdk 33 ? add this dependency_overrides: permission_handler: ^8.3.0

Myzel394 commented 2 years ago

dependency_overrides: permission_handler: ^8.3.0

This requires a compileSdkVersion of 32

and you don't want to use compileSdk 33 ?

Not sure if I understood correctly what the compileSdkVersion means, but doesn't it mean that people will need at least a sdk version of 33 to be able to use this app? If yes, most people will not be able to use the app

liodali commented 2 years ago

that just for compile the app but minsdk will restrict for example user to download the app if their sdk api lower than what you specify in build.gradle so don't worry about that just change compileSdk to 33