【问题标题】:How to fix app:lint error when building flutter app?构建颤振应用程序时如何修复应用程序:lint错误?
【发布时间】:2021-12-28 11:43:40
【问题描述】:

由于某种原因,我的应用突然无法构建了。首先我遇到了flutter devtools问题,然后我升级到了Flutter 2.8.1,现在我的应用程序无法构建。我尝试将 Gradle 升级到 7.3.3 和 JDK 17,但仍然无法构建我的应用程序,我搜索了整个 GitHub 和 StackOverflow,但找不到解决方案。

这是我的第一个错误:

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
←[33m> ←[39mUnable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @27ec650

我通过添加来修复:

--add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

到 gradle.properties。

但是现在当我尝试构建时,我又遇到了另一个错误:

* What went wrong:
Execution failed for task ':app:lint'.
←[33m> ←[39mLint found errors in the project; aborting build.

  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...
  Errors found:

  ...\android\app\src\main\AndroidManifest.xml:5: Error: Class referenced in the manifest, com.example.my_app.${applicationName}, was not found in the project or the libraries [MissingClass]
          android:name="${applicationName}"
                        ~~~~~~~~~~~~~~~~~~

这是我的flutter doctor -v

[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.22000.376], locale hr-HR)
    • Flutter version 2.8.1 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (12 days ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\domin\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] IntelliJ IDEA Community Edition (version 2021.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.63.2)
    • VS Code at C:\Users\domin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.29.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 96.0.1054.43

• No issues found!

【问题讨论】:

    标签: java android flutter dart gradle


    【解决方案1】:

    将此添加到您的 app/build.gradle 文件中

    android {
        //...
        lintOptions {
            abortOnError false
        }
    }
    

    【讨论】:

    • 这可行,但生产安全吗?
    • 是的,它是生产安全的。
    猜你喜欢
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 2021-01-05
    • 2021-03-20
    • 2021-02-18
    • 1970-01-01
    • 2021-03-01
    • 1970-01-01
    相关资源
    最近更新 更多