gpt4 book ai didi

android - Flutter:Android模拟器上未安装发布apk

转载 作者:行者123 更新时间:2023-12-03 05:25:23 27 4
gpt4 key购买 nike

我正在尝试从flutter应用程序制作apk,所以在创建flutter项目之后:

flutter create release_app_test

根据 official站点我创建了一个签名 key 。

这是一个完整的构建 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 plugin: 'kotlin-android'
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

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

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.release_app_test"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

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

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

我通过这个命令制作了apk:
tazik@mx-linux:/mnt/Project/Flutter/my_practises/release_app_test
$ flutter build apk --split-per-abi
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 11.4s
✓ Built build/app/outputs/apk/release/app-armeabi-v7a-release.apk (5.1MB).
✓ Built build/app/outputs/apk/release/app-arm64-v8a-release.apk (5.4MB).
✓ Built build/app/outputs/apk/release/app-x86_64-release.apk (5.6MB).
tazik@mx-linux:/mnt/Project/Flutter/my_practises/release_app_test
$

现在创建 apk 后,我想通过 adb 命令安装它,但出现此错误:
tazik@mx-linux:/mnt/Software/Linux/Android/SDK/platform-tools
$ adb install /mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release/app-x86_64-release.apk
Performing Streamed Install
adb: failed to install /mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release/app-x86_64-release.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
tazik@mx-linux:/mnt/Software/Linux/Android/SDK/platform-tools
$ adb install /mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
Performing Streamed Install
adb: failed to install /mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release/app-armeabi-v7a-release.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
tazik@mx-linux:/mnt/Software/Linux/Android/SDK/platform-tools
$ adb install /mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release/app-arm64-v8a-release.apk
Performing Streamed Install
adb: failed to install /mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release/app-arm64-v8a-release.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
tazik@mx-linux:/mnt/Software/Linux/Android/SDK/platform-tools

没有安装任何 apk。

谷歌搜索后,我添加到模块 build.gradle 和 Android block 内
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a', 'x86_64'
universalApk true
}
}

添加此脚本后,我得到了以下结果:
tazik@mx-linux:/mnt/Project/Flutter/my_practises/release_app_test
$ flutter build apk --split-per-abi
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 13.6s
✓ Built build/app/outputs/apk/release/app-armeabi-v7a-release.apk (5.1MB).
✓ Built build/app/outputs/apk/release/app-x86_64-release.apk (5.6MB).
tazik@mx-linux:/mnt/Project/Flutter/my_practises/release_app_test

构建的apk:
tazik@mx-linux:/mnt/Project/Flutter/my_practises/release_app_test/build/app/outputs/apk/release
$ ls -l --block-size=MB
total 28MB
-rwxrwxrwx 1 root root 6MB Apr 28 12:25 app-armeabi-v7a-release.apk
-rwxrwxrwx 1 root root 16MB Apr 28 12:25 app-universal-release.apk
-rwxrwxrwx 1 root root 6MB Apr 28 12:25 app-x86_64-release.apk
-rwxrwxrwx 1 root root 1MB Apr 28 12:25 app-x86-release.apk
-rwxrwxrwx 1 root root 1MB Apr 28 12:25 output.json

只安装了 app-x86-release.apk,但它已损坏,无法在模拟器上运行。因为你可以看到它的大小是 1MB..

而我的flutter sdk版本是: flutter_linux_v1.12.13+hotfix.9-stable

最佳答案

截至目前,我们在通过在 android 模拟器中拖放来安装 flutter 释放脂肪 apk 时遇到了一些问题。

但是,您可以通过生成支持的 ABI 及其相应的模拟器来进行检查。我没试过,但如果你最多需要的话,你可以试一试。详细信息可以在下面的链接中找到。

flutter issues

关于android - Flutter:Android模拟器上未安装发布apk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61475397/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com