flutter 开源插件camera fluwx本地搭建、anroid混编

fluwx、camera等开源插件。android模块编译。

android目录build.gradle调整,红色字体为增加部分。参考普通的flutter项目,android gradle配置引入flutter库。

group 'io.flutter.plugins.camera'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        google()
        jcenter()
    }

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

rootProject.allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        google()
        jcenter()
    }
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.library'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"



android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 21
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
        abortOnError false
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
    dependencies {
        implementation 'androidx.annotation:annotation:1.0.0'
        implementation 'androidx.core:core:1.0.0'
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }

}

// 只有一层目录,到当前应用根目录,否则.packages找不到编译过不去,第三方插件lib/main.dart找不到无所谓。
flutter {
    source '../'
}

dependencies {
    testImplementation 'junit:junit:4.12'
}

至此android中就可以混编flutter。

import io.flutter.plugin.common...等包就可顺利找到

-------------------------------

pubspec.yaml

#引入本地下载好的 camera插件
camera:
  path: ../camera-source

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值