Я пытаюсь сделать apk из приложения флаттера, поэтому после создания проекта флаттера:
flutter create release_app_test
В соответствии с официальным сайтом я создаю ключ подписи.
Это полная сборка сборки:
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
Ни один из apks не установлен.
После поиска в Google я добавил в модуль 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
Апксы собраны:
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, но он поврежден и может не работает на эмуляторе. Потому что, как вы можете видеть, его размер составляет 1 МБ.
И моя версия флаттера SDK: flutter_linux_v1.12.13 + hotfix.9-stable