Flutter在调试模式下运行,但是无法在发布模式下构建

时间:2019-07-28 14:10:59

标签: flutter release androidx

我正在尝试创建一个Flutter应用程序。由于开发过程中AndroidX不兼容,我遇到了一些问题,但设法解决了这些问题。现在,即使在实际设备上,该应用程序也可以在调试模式下正常运行,但是在发布模式下它将失败。

这两个命令均失败:

flutter run --release
flutter build appbundle

错误代码是:

Gradle task bundleRelease failed with exit code 1

我的依赖项:

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  firebase_messaging: ^5.0.1+1
  http: ^0.12.0+2
  shared_preferences: ^0.5.2
  permission: ^0.1.2
  contacts_service: ^0.2.8
  cached_network_image: ^0.8.0
  provider: ^2.0.1+1
  firebase_auth: ^0.11.1+7
  cloud_firestore: ^0.12.7
  cloud_functions: ^0.4.0+2
  firebase_storage: ^3.0.2
  quiver: ^2.0.3
  file_picker: ^1.3.8
  camera: ^0.5.2+1
  video_player: ^0.10.1+5
  native_device_orientation: ^0.2.0
  flutter_local_notifications: ^0.8.0
  flutter_ffmpeg:
   git:
    url: git://github.com/tanersener/flutter-ffmpeg.git
    ref: v0.2.5
    path: packages/flutter_ffmpeg_https-gpl

我的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 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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.dating"
        minSdkVersion 24
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    signingConfigs {
        release {
            // You need to specify either an absolute path or include the
            // keystore file in the same directory as the build.gradle file.
            storeFile file("wingman.jks")
            storePassword "*****"
            keyAlias "wingman"
            keyPassword "*****"
        }
    }

    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.release
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            multiDexEnabled true ;
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
}

apply plugin: 'com.google.gms.google-services'

如果错误确实是由于androidx不兼容引起的,那么它是否不会在调试模式下失败。

0 个答案:

没有答案