Flutter 应用程序在 android 10 & R 上崩溃,没有静态方法 isAtLeastR
Flutter app crashing on android 10 & R with No static method isAtLeastR
我在 Stack overflow 上看到了一些类似的问题,但没有一个与相同的库完全相关。
我正在尝试在 flutter 中使用 2 个插件
flutter_geofence 和地理定位器
它们都运行良好,但从昨天开始,一旦调用位置播放服务,我就会让应用程序退出,堆栈跟踪类似于以下内容:
E/flutter (11478): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.NoSuchMethodError: No static method isAtLeastR()Z in class Landroidx/core/os/BuildCompat; or its super classes (declaration of 'androidx.core.os.BuildCompat' appears in /data/app/com.mypossibleself.app-FTu9V5QDAKR_ngQmuPzg7Q==/base.apk!classes2.dex)
E/flutter (11478): at com.google.android.gms.common.util.PlatformVersion.isAtLeastR(com.google.android.gms:play-services-basement@@17.2.1:21)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.zaa(com.google.android.gms:play-services-base@@17.2.1:128)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base@@17.2.1:41)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base@@17.2.1:56)
E/flutter (11478): at com.google.android.gms.location.FusedLocationProviderClient.<init>(Unknown Source:8)
E/flutter (11478): at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:2)
E/flutter (11478): at com.baseflow.geolocator.tasks.LocationUpdatesUsingLocationServicesTask.<init>(LocationUpdatesUsingLocationServicesTask.java:29)
E/flutter (11478): at com.baseflow.geolocator.tasks.TaskFactory.createStreamLocationUpdatesTask(TaskFactory.java:120)
E/flutter (11478): at com.baseflow.geolocator.GeolocatorPlugin.onListen(GeolocatorPlugin.java:110)
E/flutter (11478): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:193)
E/flutter (11478): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:172)
E/flutter (11478): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/flutter (11478): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/flutter (11478): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (11478): at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (11478): at android.os.Looper.loop(Looper.java:174)
E/flutter (11478): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter (11478): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11478): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter (11478): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
所以它抱怨缺少方法 isAtLeastR
我看到的其他参考资料提到了导致此问题的 com.google.android.gms:play-services-base 的特定版本,但它已在 com.google.android.gms:play-services-base:17.2 中修复。 1
这些库都没有在它们的 build.gradle 文件中实现该包,所以我不知道需要做什么来解决这个问题。
在 app/build.gradle 添加 com.google.android.gms:play-services-base:17.2.1
这应该使库使用特定版本的播放服务。
如果没有帮助,可能需要
configurations.all {
resolutionStrategy {
force 'com.google.needed_dependency'
}
}
https://flutter.dev/docs/development/packages-and-plugins/using-packages#conflict-resolution
根据安德鲁斯的建议编辑:
17.2.1 不起作用,但 17.0.0 可以。
implementation("com.google.android.gms:play-services-base:17.0.0"){ force = true }
resolutionStrategy {
force 'com.google.android.gms:play-services-base:17.1.0'
}
}
这就是为我解决的问题。
我在 Stack overflow 上看到了一些类似的问题,但没有一个与相同的库完全相关。
我正在尝试在 flutter 中使用 2 个插件 flutter_geofence 和地理定位器
它们都运行良好,但从昨天开始,一旦调用位置播放服务,我就会让应用程序退出,堆栈跟踪类似于以下内容:
E/flutter (11478): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.NoSuchMethodError: No static method isAtLeastR()Z in class Landroidx/core/os/BuildCompat; or its super classes (declaration of 'androidx.core.os.BuildCompat' appears in /data/app/com.mypossibleself.app-FTu9V5QDAKR_ngQmuPzg7Q==/base.apk!classes2.dex)
E/flutter (11478): at com.google.android.gms.common.util.PlatformVersion.isAtLeastR(com.google.android.gms:play-services-basement@@17.2.1:21)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.zaa(com.google.android.gms:play-services-base@@17.2.1:128)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base@@17.2.1:41)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base@@17.2.1:56)
E/flutter (11478): at com.google.android.gms.location.FusedLocationProviderClient.<init>(Unknown Source:8)
E/flutter (11478): at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:2)
E/flutter (11478): at com.baseflow.geolocator.tasks.LocationUpdatesUsingLocationServicesTask.<init>(LocationUpdatesUsingLocationServicesTask.java:29)
E/flutter (11478): at com.baseflow.geolocator.tasks.TaskFactory.createStreamLocationUpdatesTask(TaskFactory.java:120)
E/flutter (11478): at com.baseflow.geolocator.GeolocatorPlugin.onListen(GeolocatorPlugin.java:110)
E/flutter (11478): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:193)
E/flutter (11478): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:172)
E/flutter (11478): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/flutter (11478): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/flutter (11478): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (11478): at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (11478): at android.os.Looper.loop(Looper.java:174)
E/flutter (11478): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter (11478): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11478): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter (11478): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
所以它抱怨缺少方法 isAtLeastR
我看到的其他参考资料提到了导致此问题的 com.google.android.gms:play-services-base 的特定版本,但它已在 com.google.android.gms:play-services-base:17.2 中修复。 1
这些库都没有在它们的 build.gradle 文件中实现该包,所以我不知道需要做什么来解决这个问题。
在 app/build.gradle 添加 com.google.android.gms:play-services-base:17.2.1
这应该使库使用特定版本的播放服务。
如果没有帮助,可能需要
configurations.all {
resolutionStrategy {
force 'com.google.needed_dependency'
}
}
https://flutter.dev/docs/development/packages-and-plugins/using-packages#conflict-resolution
根据安德鲁斯的建议编辑:
17.2.1 不起作用,但 17.0.0 可以。
implementation("com.google.android.gms:play-services-base:17.0.0"){ force = true }
resolutionStrategy {
force 'com.google.android.gms:play-services-base:17.1.0'
}
}
这就是为我解决的问题。