apk сборки flutter
Для отладки определенных функций моего приложения мне нужно собрать APK-файл для отладки:
flutter build apk --debug
Это не удается из-за следующей ошибки в командной строке:
Код: Выделить всё
ERROR:\build\path_provider_android\intermediates\runtime_library_classes_jar\debug\classes.jar: D8: java.lang.NullPointerException:
Cannot invoke "String.length()" because "
" is null
ERROR:\build\flutter_secure_storage\intermediates\runtime_library_classes_jar\debug\classes.jar: D8: java.lang.NullPointerException:
Cannot invoke "String.length()" because "" is null
ERROR:\build\file_picker\intermediates\runtime_library_classes_jar\debug\classes.jar: D8: java.lang.NullPointerException:
Cannot invoke "String.length()" because "" is null
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform classes.jar (project :file_picker) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE,
com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, c
om.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false,
dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: \build\file_picker\intermediates\runtime_library_classes_jar\debug\classes.jar.
> Error while dexing.
> Failed to transform classes.jar (project :flutter_secure_storage) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE,
com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: \build\flutter_secure_storage\intermediates\runtime_library_classes_jar\debug\classes.jar.
> Error while dexing.
> Failed to transform classes.jar (project :path_provider_android) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE,
com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: \build\path_provider_android\intermediates\runtime_library_classes_jar\debug\classes.jar.
> Error while dexing.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 22s
Running Gradle task 'assembleDebug'... 24.3s
Gradle task assembleDebug failed with exit code 1
Код: Выделить всё
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.19045.4529], locale en-IN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.0)
[!] Android Studio (not installed)
[√] IntelliJ IDEA Community Edition (version 2024.1)
[√] Connected device (4 available)
[√] Network resources
! Doctor found issues in 1 category.
Код: Выделить всё
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader("UTF-8") { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
flutterVersionCode = "1"
}
def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
flutterVersionName = "1.0"
}
android {
namespace = "com.example.untitled"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.untitled"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
// multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
}
}
}
flutter {
source = "../.."
}
Код: Выделить всё
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
//rootProject.buildDir = "E:\\build\\backEnd"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
//configurations.all {
// resolutionStrategy {
// force("androidx.core:core-ktx:1.9.0")
// }
//}
Код: Выделить всё
org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
Код: Выделить всё
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
Код: Выделить всё
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}
include ":app"
local.properties:
flutter.sdk=e:\\myApp\\flutter
sdk.dir=E:\\myApp\\android
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
openjdk версия «21.0.3» 16 апреля 2024 г. Среда выполнения LTS OpenJDK
Corretto-21.0.3.9.1 (сборка 21.0.3+9-LTS) 64-битная серверная виртуальная машина OpenJDK
Corretto-21.0.3.9.1 (сборка 21.0.3+9-LTS, смешанный режим, общий доступ) )
Версия Gradle:
Gradle 8.7
Время сборки: 22 марта 2024 г., 15:52:46 Версия UTC:
650af14d7653aa949fce5e886e685efc9cf97c10
Kotlin: 1.9.22 Groovy: 3.0.17 Ant: Apache Ant(TM)
версия 1.10.13, скомпилированная 4 января 2023 г. JVM: 21.0.3
(Amazon.com Inc. 21.0.3+9-LTS ) ОС: Windows 10 10.0 amd64
Что я уже пробовал:
- < li>Очистка кеша Gradle
- Следующий код в приложении и andriod build.gradle (один за другим)configurations.all {
solveStrategy {
force("androidx.core:core-ktx:1.9.0")
}
PS: Веб-сборка работает нормально
Подробнее здесь: https://stackoverflow.com/questions/787 ... or-android
Мобильная версия