美文网首页
Android Native原生集成Flutter module

Android Native原生集成Flutter module

作者: 一笑轮回吧 | 来源:发表于2023-09-13 23:03 被阅读0次

    集成文档:官方入口

    1、当我们按照官方集成好后,你会遇到第一个问题。

    问题1:Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin class 'FlutterPlugin'.

    解决方式:
    settings.gradle 中

    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    修改为:
    repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
    

    2、当我们以为完事大吉的时候,运行时又报错了

    问题2:各种库找不到,各种失败Fail


    image.png

    解决方式:
    复制下面代码到项目project的build.gradle

    allprojects {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/public' }
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }
    

    完整代码:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    plugins {
        id 'com.android.application' version '7.2.0' apply false
        id 'com.android.library' version '7.2.0' apply false
        id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
    }
    
    allprojects {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/public' }
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    在运行试下,OK~

    相关文章

      网友评论

          本文标题:Android Native原生集成Flutter module

          本文链接:https://www.haomeiwen.com/subject/ubzpvdtx.html