android 中的原生 Checkout Paypal 按钮未呈现以发布 apk

Native Checkout Paypal Button not getting rendered for release apk in android

我已经使用 kotlin 为 flutter 实现了 Native Checkout SDK。该应用程序适用于调试应用程序。它显示的屏幕是这样的。

但是当我使用“flutter build apk --release”命令构建发布 apk 时,它不会呈现。它显示加载栏然后消失。我也使用了互联网许可。那么是什么原因,我该如何解决呢?

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 GradleException("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"

 android {
  compileSdkVersion 30

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

 lintOptions {
    disable 'InvalidPackage'
    checkReleaseBuilds false
  }

 defaultConfig {
    // TODO: Specify your own unique Application ID 
(https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.flutterkotlinpypl"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

buildTypes {
    release {
        debuggable true
        // 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
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = "1.8"
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation('com.paypal.checkout:android-sdk:0.1.0')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.amplitude:android-sdk:2.31.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
}

我通过添加 shrinkResources falseminifyEnabled false[=17= 解决了这个问题] 在 buildTypes 下的 android/app/build.gradle 文件中。希望对大家有所帮助。

buildTypes {
    release {
    // Signing with the debug keys for now, so `flutter run --release` works.
    shrinkResources false
    minifyEnabled false
    signingConfig signingConfigs.debug
  }
}