Flutter – 如何在应用程序包中修复问题?

huangapple go评论61阅读模式
英文:

Flutter - how fix issue in appbudle?

问题

我有一个用于Android的Flutter应用程序(与网络一起工作)。该应用程序在调试模式下正常运行。我创建了App Bundle - 将控制台下载到Google,然后下载通用的APK文件(适用于所有平台)。但是,当我从商店安装应用程序(即针对特定设备 - 特定平台),应用程序的运行出现问题。

我成功地在计算机上本地重现了这个问题:

  • 我创建App Bundle
  • 我使用BundleTool从App Bundle创建一组APK文件
  • 然后我使用BundleTool将APK安装到我的手机上 - 出现相同的问题

似乎问题与ABI相关。这是我的build.gradle文件中的代码:

buildTypes {
    release {
        minifyEnabled false
        zipAlignEnabled false
        shrinkResources false
        signingConfig signingConfigs.release
        ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
    }
    debug {
        minifyEnabled false
        zipAlignEnabled false
        shrinkResources false
        signingConfig signingConfigs.release
        ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
    }
}
splits {
    abi {
        enable true // 启用ABI拆分机制
        reset() // 重置要包括的ABI列表为空字符串
        include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
        universalApk true
    }
}
...
project.ext.versionCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.outputFileName = "myapp_" + variant.versionName + "_" + output.getFilter(com.android.build.OutputFile.ABI) + ".apk"
        output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) *
                        1000000 + android.defaultConfig.versionCode
    }
}

调试和发布的配置几乎相同,但在调试模式下应用程序正常运行。

如何理解错误的原因?如何将调试模式与发布APK合并 - 但这可能是不可能的。

任何建议 - 我将非常感激。

英文:

I have Flutter app for android(work with the network). the application works in debug mode. I create appbundle - download the console to Google, then download the universal apk file (for all platforms). But when I install the application from the store (that is, for a certain device - a certain platform), I have a problem with the operation of the application.
I managed to reproduce this issue locally on the computer:

  • I create appbundle
  • I will create a set of apks from appbundle(with bundletool)
  • then I install the apk on my phone(with bundletool) - the same problem

it also seems that the problem is related to abi. This is my code from build.gradle:

buildTypes {
        release {
            minifyEnabled false
            zipAlignEnabled false
            shrinkResources false
            signingConfig signingConfigs.release
            ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
        }
        debug {
            minifyEnabled false
            zipAlignEnabled false
            shrinkResources false
            signingConfig signingConfigs.release
            ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
        }
    }
    splits {
        abi {
            enable true //enables the ABIs split mechanism
            reset() //reset the list of ABIs to be included to an empty string
            include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
            universalApk true
        }
    }
..........

project.ext.versionCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.outputFileName = "myapp_" + variant.versionName + "_" + output.getFilter(com.android.build.OutputFile.ABI) + ".apk"
        output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) *
                        1000000 + android.defaultConfig.versionCode
    }
}

Configs for debug and release are same almost the same. but when i run in debug the app works.

how can I understand what is the cause of the error?
how could I join in debug mode to the release apk - but it's probably not possible.

any advice - I will be very grateful

答案1

得分: 1

考虑移除 x86,因为 Flutter 不支持它,并且这将正常工作。

使用以下内容替代:

release {
    minifyEnabled false
    zipAlignEnabled false
    shrinkResources false
    signingConfig signingConfigs.release
    ndk.abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}

而不是:

release {
    minifyEnabled false
    zipAlignEnabled false
    shrinkResources false
    signingConfig signingConfigs.release
    ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
英文:

Consider removing x86 because flutter doesn't support it . and it will work fine.

put this :

release {
            minifyEnabled false
            zipAlignEnabled false
            shrinkResources false
            signingConfig signingConfigs.release
            ndk.abiFilters 'x86_64', 'armeabi-v7a', 'arm64-v8a'
        }

instead of this :

release {
            minifyEnabled false
            zipAlignEnabled false
            shrinkResources false
            signingConfig signingConfigs.release
            ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
        }

答案2

得分: 0

我修复了这个问题 - 将以下行添加到gradle.properties中:

android.bundle.enableUncompressedNativeLibs=false
英文:

I fixed this issue - added it line to gradle.properties

  android.bundle.enableUncompressedNativeLibs=false

答案3

得分: 0

Removed the ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'

Automatically showing google play store and apk install

buildTypes {
release {
debuggable false /// upload apk false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

英文:

Flutter – 如何在应用程序包中修复问题?Removed the ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'

Automatically showing google play store
and apk install

buildTypes {
release {
debuggable fale /// upload apk false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

Flutter – 如何在应用程序包中修复问题?

答案4

得分: 0

'ndk.abiFilters'中的文本是:'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
为什么需要ABI过滤器?您尝试过删除上面的行吗?

英文:

ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
why do you need abi filters? Did you try removing the above line?

huangapple
  • 本文由 发表于 2023年3月15日 18:57:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743777.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定