configuring project ‘:flutter_keyboard_visibility’


Avatar de Pierre Courtois

Il est possible qu’un message d’erreur s’affiche dans VS code après avoir mis à jour votre gradle. Dans ce guide, je vous explique comment régler ça très facilement.


flutter-keyboard-visibility

Comment résoudre le problème A problem occurred configuring project ‘:flutter_keyboard_visibility’ dans Flutter ?

Après avoir mis à jour votre gradle dans Android Studio, il est possible que vous ayez ce message d’erreur au moment de relancer votre application dans Visual Studio :

* What went wrong:
A problem occurred configuring project ':flutter_keyboard_visibility'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Specify a namespace in the module's build file: /Users/votre_nom/.pub-cache/hosted/pub.dev/flutter_keyboard_visibility-5.4.1/android/build.gradle. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

Pour le régler, rendez-vous dans votre dossier android, puis dans le fichier build.gradle (avec un éléphant bleu).

Ajoutez ce bloc ce code :

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}

Juste après :

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'

Si ce n’est pas déjà fait, pensez aussi à retirer le nom de votre application dans le fichier AndroidManifest.xml, comme suggéré dans la suite du message d’erreur :

     If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

Enfin, relancez votre application avec la commande flutter run pour vous assurer que tout fonctionne correctement.

Avatar de Pierre Courtois