Futter问题:本机崩溃

时间:2019-04-10 02:23:40

标签: flutter

在Google Play上部署我的Flutter应用后,启动时会崩溃。它适用于2台设备(Google Play Play测试设备),而其他设备却出现以下错误。

  

问题:java.lang.UnsatisfiedLinkError:dalvik.system.PathClassLoader [DexPathList [[zip file“ /data/app/abc.pota.tallxy-1/base.apk"],nativeLibraryDirectories=[/data/app/ abc.pota.tallxy-1 / lib / arm64,/ data / app / abc / pot.tallxy-1 / base.apk!/ lib / arm64-v8a,/ system / lib64,/ vendor / lib64,/ system / vendor / lib64,/ product / lib64]]]找不到“ libflutter.so”

所以我将以下代码放入我的app / build.gradle文件中。

defaultConfig {
    ..
    ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}

但不是在所有的Google Test设备上,甚至在我的手机上(当我从Google Play下载时),它都因以下错误而崩溃。

问题:abc.pota.tallxy的本机崩溃

  
     

04-09 18:33:39.560:E / HwSystemManager(1901):HandleInstalledPackageInfoService:第二个操作:pkgData为null   04-09 18:33:39.683:E / HwLauncher(2408):PowerSaveLauncherModel onPackage已添加:不在PowerSaveLauncher中   04-09 18:33:39.908:E / fm_if.c(16065):找到id:fm并开始打开设备   04-09 18:33:39.939:E / Finsky(6061):[135] com.google.android.finsky.setup.ae.a(52):预取预载时出错   04-09 18:33:39.939:E / Finsky(6061):com.google.android.finsky.setup.fetchers.RawDocumentsFetchException [reason = pai_config,account = [3IPbcy9bVZDdTfTescMyODo8-OY]]   04-09 18:33:39.939:E / Finsky(6061):at com.google.android.finsky.setup.ae.a(SourceFile:31)   04-09 18:33:39.939:E / Finsky(6061):at com.google.android.finsky.setup.ag.call(来源不明)   04-09 18:33:39.939:E / Finsky(6061):at java.util.concurrent.FutureTask.run(FutureTask.java:237)   04-09 18:33:39.939:E / Finsky(6061):at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)   04-09 18:33:39.939:E / Finsky(6061):at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:607)   04-09 18:33:39.939:E / Finsky(6061):at java.lang.Thread.run(Thread.java:776)   04-09 18:33:40.174:W / System(16106):ClassLoader引用的未知路径:/ system / app / YouTube / lib / arm64

异常删除所有proguard代码之后。 Google控制台表示以下四种设备均失败。

  

有问题的设备   Google Pixel 2(角膜白斑)-Android 8.1   华为伴侣9(HWMHA)-Android 7.0   Google Pixel(sailfish)-安卓7.1   三星Galaxy S9(美国)(starqlteue)-安卓8.0

     

java.lang.UnsatisfiedLinkError:dalvik.system.PathClassLoader [DexPathList [[zip文件“ /data/app/abc.pota.tallxy-xsLCE7j_6PxDsQ0AqFF1ZA==/base.apk"],nativeLibraryDirectories=[/data/app/ abc.pota.tallxy-xsLCE7j_6PxDsQ0AqFF1ZA == / lib / arm64,/ data / app / abc.pota.tallxy-xsLCE7j_6PxDsQ0AqFF1ZA == / base.apk!/ lib / arm64-v8a,/ system / lib64]]找到“ libflutter.so”   java.lang.UnsatisfiedLinkError:dalvik.system.PathClassLoader [DexPathList [[zip文件“ /data/app/abc.pota.tallxy-1/base.apk"],nativeLibraryDirectories=[/data/app/abc.pota.tallxy -1 / lib / arm64,/ data / app / abc.pota.tallxy-1 / base.apk!/ lib / arm64-v8a,/ system / lib64,/ vendor / lib64,/ system / vendor / lib64,

我的 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 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"

        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 {
                applicationId "abc.pota.tallxy"
                minSdkVersion 21
                targetSdkVersion 28
                multiDexEnabled true
                versionCode 5
                versionName flutterVersionName
                testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
                ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
            }

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

            buildTypes {
                release {
                    signingConfig signingConfigs.release

                }
            }
        }

        flutter {
            source '../..'
        }

        dependencies {
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'androidx.test:runner:1.1.1'
            androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
            implementation 'com.google.firebase:firebase-core:16.0.8'
            implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
            implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        }

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

谢谢您的时间

1 个答案:

答案 0 :(得分:0)

如果您使用的是minifyEnabled true,则必须面对这个问题。


解决方案1 ​​

在您的build.gradle文件中删除此行。


解决方案2

如果您仍然想使用minifyEnabled,则还必须遵循以下步骤。

I。将extra-gen-snapshot-options=--obfuscate添加到您的android/gradle.properties

II。创建/android/app/proguard-rules.pro文件并添加下面列出的规则。

#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

III。在您的build.gradle(app)中,添加此

buildTypes {

    release {

        signingConfig signingConfigs.debug

        minifyEnabled true
        useProguard true

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

    }
}