DEV Community

Cover image for Upgrading to Ladybug 🐞, led to loads of bugs πŸ›! (flutter)
Saad Alkentar
Saad Alkentar

Posted on

1

Upgrading to Ladybug 🐞, led to loads of bugs πŸ›! (flutter)

Upgrading my Android Studio version has always been a hurdle! I've always avoided it when possible, but it's a must after a while.

Errors πŸ˜“

To list a few errors that faced me when upgrading a rather small project

path_provider_android/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
Enter fullscreen mode Exit fullscreen mode
file_picker/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
Enter fullscreen mode Exit fullscreen mode
sqflite/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
Enter fullscreen mode Exit fullscreen mode
camera_android_camerax/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
Enter fullscreen mode Exit fullscreen mode
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Enter fullscreen mode Exit fullscreen mode
camera_android_camerax/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
Enter fullscreen mode Exit fullscreen mode
file_picker/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
Enter fullscreen mode Exit fullscreen mode
path_provider_android/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
Enter fullscreen mode Exit fullscreen mode
sqflite/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
Enter fullscreen mode Exit fullscreen mode

and so on! As you can see, these errors are library-related, but those are very common libraries and it is kinda tricky! it seems like a multi-dexing issue at first, those error messages don't give a good idea about the problem. finally, to the solution...

Upgrading the project! 🀩

We start by updating the gradle version in the Android folder, making sure it is 8.x. ie gradle-8.9-all.zip

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
Enter fullscreen mode Exit fullscreen mode

android/gradle/wrapper/gradle-wrapper.properties

Then, updating Gradle plugin in gradle setting file

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.3.2" apply false
    id "org.jetbrains.kotlin.android" version "2.0.20" apply false
}
Enter fullscreen mode Exit fullscreen mode

android/settings.gradle

Finally updating Java version in Android app gradle file

android {
    namespace = "com..."
    compileSdk = flutter.compileSdkVersion
    ndkVersion = "25.1.8937393"

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = 17
    }
Enter fullscreen mode Exit fullscreen mode

android/app/build.gradle

make sure to set version to Java 17. I also recommend updating pub libraries if possible using

flutter pub upgrade
flutter clean
flutter run
Enter fullscreen mode Exit fullscreen mode

That is it! I believe this covers all the steps to upgrade your flutter project. tell me if you find any unexpected issues

Stay tuned for other tips 😎

Image of Docusign

πŸ› οΈ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay