我添加了geolocator依赖项,然后出现android x不兼容的错误。有什么可以帮助我摆脱困境的吗?
[0-9][\u2070\u2071\u00b9\u00b2\u00b3\u2074-\u207F]
⁰ ⁱ ¹ ² ³ ⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿ
答案 0 :(得分:1)
我收到此错误
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:14: error: package android.support.annotation does not exist
import android.support.annotation.MainThread;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:15: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:16: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:17: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:18: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:193: error: cannot find symbol
int permissionState = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION);
^
symbol: variable ActivityCompat
location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:198: error: cannot find symbol
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
^
symbol: variable ActivityCompat
location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:203: error: cannot find symbol
return ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION);
^
symbol: variable ActivityCompat
location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:296: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^
symbol: class NonNull
9 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':location:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for 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.
答案 1 :(得分:0)
将所有依赖项迁移到andriodx软件包将解决此问题。 https://developer.android.com/jetpack/androidx/migrate
这里,您的地理定位器最新使用androidx软件包,其中image_picker依赖项使用android软件包。您需要将image_picker库更新为最新的https://pub.dev/packages/image_picker#-changelog-tab-
或
快速修复:将地理位置定位器降级为2.1.1,以解决此问题。这不是最佳方法。
将所有依赖关系升级到androidx兼容是您可以尝试的最佳方法。