运行Flutter项目时Your app isn't using AndroidX.

报了如下错误:

Launching lib/main.dart on sdk gphone x86 in debug mode...
[!] Your app isn't using AndroidX.
To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
Running Gradle task 'assembleDebug'...
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:javaPreCompileDebug'.

Could not resolve all files for configuration ':app:debugCompileClasspath'.
Could not download x86_debug.jar (io.flutter:x86_debug:1.0.0-5aff3119480996ca014ec0f8d26d74db617b5852)
Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-5aff3119480996ca014ec0f8d26d74db617b5852/x86_debug-1.0.0-5aff3119480996ca014ec0f8d26d74db617b5852.jar'.
Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-5aff3119480996ca014ec0f8d26d74db617b5852/x86_debug-1.0.0-5aff3119480996ca014ec0f8d26d74db617b5852.jar'.
Read timed out

  • 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 3m 37s
Exception: Gradle task assembleDebug failed with exit code 1

原因

字面意思:你的app没有使用AndroidX
那就让app使用AndroidX,在gradle.properties中添加:

android.enableJetifier=true
android.useAndroidX=true
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容