• Github 中文镜像
Sign inSign up
Watch966
Star102.4k
Fork61.8k
Tag: flutter
Switch branches/tags
Branches
Tags
  • master
K / Flutter 项目升级 Kotlin、Gradle 的几个报错解决.md
移动浏览 Clone
加载中...
到移动设备上浏览
49 lines 5.88 KB
First commit on 2 Nov 2021

    用了一个新插件,报错 Kotlin 不兼容,记录升级过程中遇到的几个报错解决办法。

    报错一

    Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
    e: C:/Users/~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.30/649ffab7767038323fec0cc41e2d7b0a8f65a378/kotlin-stdlib-common-1.5.30.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
    

    解决

    Kotlin 版本低。在 YourProject\android\build.gradle 找到 ext.kotlin_version = '1.1.15',版本号改大。目前最新是 1.5.31

    报错二

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'D:\YourProject\android\app\build.gradle' line: 25
    
    * What went wrong:
    A problem occurred evaluating project ':app'.
    > Failed to apply plugin [id 'kotlin-android']
       > The current Gradle version 5.6.2 is not compatible with the Kotlin Gradle plugin. Please use Gradle 6.1.1 or newer, or the previous version of the Kotlin plugin.
    
    * 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
    

    解决

    Gradle 版本低,在 YourProject\android\gradle\wrapper\gradle-wrapper.properties 中找到 distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip,版本号改大。目前最新是 7.2

    报错三

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem was found with the configuration of task ':android_path_provider:checkReleaseManifest' (type 'CheckManifest').
      - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has @Input annotation used on property of type 'File'.
    
        Reason: A property of type 'File' annotated with @Input cannot determine how to interpret the file.
    
        Possible solutions:
          1. Annotate with @InputFile for regular files.
          2. Annotate with @InputDirectory for directories.
          3. If you want to track the path, return File.absolutePath as a String and keep @Input.
    
        Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem.
    
    * 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
    

    解决

    中文环境网上搜的答案是要在文件中加注解,但 Stackoverflow 上有一个答案提示还是检查 gradle 文件的问题。

    YourProject\android\build.gradle 找到 classpath 'com.android.tools.build:gradle:3.5.0',版本号改为 4.1.0 或者更大。