【问题标题】:implement external library android in flutter plugin在flutter插件中实现外部库android
【发布时间】:2019-02-11 11:08:21
【问题描述】:

我尝试在 Flutter 插件中实现一个 android 外部库,我们称之为 myPlugin。但我不知道如何构建具有外部库实现的 build.gradle。我尝试运行依赖于 myplugin 的主项目。但我仍然无法调用外部库的任何 api 这是 myplugin build.gradle :

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

rootProject.allprojects {
    repositories {
        google()
        jcenter()
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 16
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}
dependencies {
    implementation 'com.android.support:support-v4:26.1.0'
}

当我尝试导入 android.support.v4...ActivityCompat 时,它被称为无法解析符号。请告诉我如何做正确的方法。谢谢

【问题讨论】:

    标签: flutter build.gradle flutter-dependencies


    【解决方案1】:

    有 2 个 build.gradle 文件。

    • android 文件夹中的一个是项目级 build.gradle。您通常不会对其进行编辑。
    • android/app 文件夹中的一个是应用程序/模块级别的 build.gradle。将您的依赖项放在此文件中。

    【讨论】:

    • 好的。它通常用于 android studio 原生框架。感谢您的建议
    【解决方案2】:

    谢谢。我解决了。

    在android studio Project/android中打开 并用gradle包装。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-31
      • 2021-07-31
      • 1970-01-01
      • 1970-01-01
      • 2020-02-09
      • 2021-08-28
      • 2020-04-11
      • 2019-06-17
      相关资源
      最近更新 更多