APK Fluter安装后Flutter App停止工作

时间:2019-05-18 07:11:56

标签: android flutter

进行开发调试时,我的应用程序运行良好。但是,当我进行Flutter构建并将Flutter安装到设备上时,请单击app,只是说停止工作了!

依赖项


environment:
  sdk: ">=2.2.0 <3.0.0"

dependencies:

 flutter:
    sdk: flutter
  firebase_auth: ^0.11.1
  google_sign_in: ^4.0.1+3
  flutter_facebook_login: ^2.0.0
  firebase_core: ^0.4.0+1
  cloud_firestore: ^0.11.0+2
  cloud_functions: ^0.3.0+1
  scoped_model: ^1.0.1
  rxdart: ^0.22.0
  intl: ^0.15.8
  moment: ^0.0.1
  http: ^0.12.0+2
  flutter_launcher_icons: "^0.7.0"
  braintree: ^0.1.2
  dio: ^2.1.3

在构建过程中出现错误或警告:

Note: C:\dev\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.11.0+2\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\dev\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.11.0+2\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\dev\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.0+1\android\src\main\java\io\flutter\plugins\firebase\core\FirebaseCorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

除此之外,没有其他实际的错误日志。

对此有什么解决方案?

这是我的应用程序级别的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 = '3'
}

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

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

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

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.app"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release

            minifyEnabled true
            useProguard true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

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

是的,我的AndroidManifest文件具有互联网许可:

<uses-permission android:name="android.permission.INTERNET" />

那么我到底在做什么错了?

1 个答案:

答案 0 :(得分:0)

我的应用的发行版遇到了类似的问题。 调试版本运行良好,但版本1无效。 当我连接物理设备并以Android Studio的发布模式运行时,我注意到尝试从Firestore本地写入下载文件时失败。

  1. 添加路径提供者:^ 0.4.1
  2. 导入'package:path_provider / path_provider.dart';
  3. 目录tempDir =等待getTemporaryDirectory(); 最终文件file = File(“ $ {tempDir.path} / $ fileName”);