繁体   English   中英

找不到 androidx.legacy:legacy-support-v4:27.0.2

[英]Could not find androidx.legacy:legacy-support-v4:27.0.2

我添加了地理定位器依赖项,然后出现 android x 不兼容的错误。 有什么可以帮助我摆脱这种情况吗?

Launching lib\main.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find androidx.legacy:legacy-support-v4:27.0.2.
     Searched in the following locations:
       - file:/C:/Users/Rutvik/AppData/Local/Android/sdk/extras/m2repository/androidx/legacy/legacy-support-v4/27.0.2/legacy-support-v4-27.0.2.pom
     Required by:
         project :app > project :image_picker

* 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 1m 7s
****************************************************

我得到这个错误

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.

将所有依赖项迁移到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兼容是您可以尝试的最佳方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM