flutter cognito 插件发布版本

flutter cognito plugin release build

我在 flutter 构建的 task:compileReleaseKotlin 期间遇到了这个错误, 问题参考 flutter cognito_plugin 我正在使用命令 flutter 运行 --release with signing key 它一直有效直到它在 task:compileReleaseKotlin 上停止。 并显示许多类似的行,这会阻止我的应用程序的所有发布过程并且不知道如何解决;你知道我该如何解决吗?有没有 l

.pub-cache/hosted/pub.dartlang.org/flutter_cognito_plugin-2.2.0/android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/FlutterCognitoPlugin.kt: (53, 27): Unresolved reference: createPluginScaffold
.pub-cache/hosted/pub.dartlang.org/flutter_cognito_plugin-2.2.0/android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/FlutterCognitoPlugin.kt: (55, 17): Unresolved reference: handler
.pub-cache/hosted/pub.dartlang.org/flutter_cognito_plugin-2.2.0/android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/Cognito.kt: (188, 49): Unresolved reference: trySend
.pub-cache/hosted/pub.dartlang.org/flutter_cognito_plugin-2.2.0/android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/Cognito.kt: (189, 50): Unresolved reference: sendThrowable

这是/build.gradle

buildscript {
    ext.kotlin_version = '1.3.72'
    ext {
        compileSdkVersion = 29                // or higher
        targetSdkVersion = 29                // or higher
        appCompatVersion = "1.0.2"           // or higher
        playServicesLocationVersion = "17.0.0"  // or higher
    }
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            // [required] flutter_background_geolocation
            url "${project(':flutter_background_geolocation').projectDir}/libs"
        }
        maven {
            // [required] background_fetch
            url "${project(':background_fetch').projectDir}/libs"
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是 app/build.gradle

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 FileNotFoundException("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.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

// flutter_background_geolocation (must be placed after the lines above)
Project background_geolocation = project(':flutter_background_geolocation')
apply from: "${background_geolocation.projectDir}/background_geolocation.gradle"


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "io.packoff.driver"
        minSdkVersion 21
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
//            signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            // background_geolocation requires custom Proguard Rules with minifyEnabled
            proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//    implementation 'com.android.support:multidex:1.0.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

您必须配置 proguard。我有同样的问题。

  1. android/app/build.gradle 文件的 buildTypes 部分添加以下配置。
buildTypes {
    release {
            
            // signingConfig signingConfigs.release
            multiDexEnabled true
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
            'proguard-rules.pro'
        }
}
  1. android\app\proguard-rules.pro 创建 proguard-rules.pro 文件并添加以下内容。
-keep class com.amazonaws.** { *; }
-keep class com.amazon.** { *; }
-keep class com.pycampers.** { *; }