1
resposta

Erro ao rodar pela primeira vez

Baixei o projeto inicial do curso, e quando tento rodar, ele me retorna esse erro:


* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-30).
        Dependency: androidx.window:window-java:1.0.0-beta04.
        AAR metadata file: /home/gws38/.gradle/caches/transforms-3/7484751697f9313134f9ca837ee708ea/transformed/jetified-window-java-1.0.0-beta04/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-30).
        Dependency: androidx.window:window:1.0.0-beta04.
        AAR metadata file: /home/gws38/.gradle/caches/transforms-3/2d192076eaeb78ddf15d15263a0118b4/transformed/jetified-window-1.0.0-beta04/META-INF/com/android/build/gradle/aar-metadata.properties.

* 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 25s

┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a higher compileSdkVersion.                                   │
│ Fix this issue by bumping the compileSdkVersion in /home/gws38/Área de Trabalho/Flutter │
│ /notifications/flutter-notifications-start/android/app/build.gradle:                    │
│ android {                                                                               │
│   compileSdkVersion 31                                                                  │
│ }                                                                                       │
└─────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
1 resposta

Olá, Vitor.

Tudo bem?

O erro que você está enfrentando ocorre porque a versão do compileSdkVersion no seu projeto é a 30, enquanto a dependência androidx.window:window-java:1.0.0-beta04 requer a versão 31.

Para corrigir esse erro, você precisa atualizar a versão do compileSdkVersion no arquivo build.gradle do seu projeto. Abra o arquivo /home/gws38/Área de Trabalho/Flutter/notifications/flutter-notifications-start/android/app/build.gradle e altere a linha compileSdkVersion 30 para compileSdkVersion 31.

Depois de fazer essa alteração, tente rodar o projeto novamente e veja se o erro persiste.

Espero que isso resolva o problema! Se tiver mais alguma dúvida, é só me dizer. Espero ter ajudado e bons estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software