Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

[Bug] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugAarMetadata'

Bom dia a todos

Eu fui tentar rodar o emulador, no primeiro momento deu certo, mas depois nunca mais rodou, tentei achar a solução na internet, mas não deu certo.

Apareceu essa mensagem de erro:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > 2 issues were found when checking AAR metadata:

       1.  Dependency 'androidx.core:core:1.12.0-alpha04' requires libraries and applications that
           depend on it to compile against codename "UpsideDownCake" of the
           Android APIs.

           :app is currently compiled against android-33.

           Recommended action: Use a different version of dependency 'androidx.core:core:1.12.0-alpha04',
           or set compileSdkPreview to "UpsideDownCake" in your build.gradle
           file if you intend to experiment with that preview SDK.

       2.  Dependency 'androidx.core:core-ktx:1.12.0-alpha04' requires libraries and applications that
           depend on it to compile against codename "UpsideDownCake" of the
           Android APIs.

           :app is currently compiled against android-33.

           Recommended action: Use a different version of dependency 'androidx.core:core-ktx:1.12.0-alpha04',
           or set compileSdkPreview to "UpsideDownCake" in your build.gradle
           file if you intend to experiment with that preview SDK.

Meu arquivo build.gradle:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'br.com.alura.orgs'
    compileSdk 33

    defaultConfig {
        applicationId "br.com.alura.orgs"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:+'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.core:core-ktx:1.9.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

Arquivo log aparece esse erro:

2023-05-12 15:00:47,794 [2883826] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - Could not read config file C:\Users\User\.android\avd\Pixel_3a_API_33_x86_64.avd\modem_simulator\modem_nvram.json: * Line 1, Column 1
2023-05-12 15:00:47,794 [2883826] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - Android Studio Flamingo | 2022.2.1 Patch 1  Build #AI-222.4459.24.2221.9971841
2023-05-12 15:00:47,795 [2883827] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - JDK: 17.0.6; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2023-05-12 15:00:47,795 [2883827] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - OS: Windows 10
2023-05-12 15:00:47,795 [2883827]   INFO - Emulator: Pixel_3a_API_33_x86_64 - Syntax error: value, object or array expected.
2023-05-12 15:00:47,795 [2883827] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - Failed to obtain nvram config singleton
2023-05-12 15:00:47,796 [2883828] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - Android Studio Flamingo | 2022.2.1 Patch 1  Build #AI-222.4459.24.2221.9971841
2023-05-12 15:00:47,796 [2883828] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - JDK: 17.0.6; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2023-05-12 15:00:47,796 [2883828] SEVERE - Emulator: Pixel_3a_API_33_x86_64 - OS: Windows 10

Se precisar de mais detalhes, pode me falar

3 respostas

Olá, Murilo! Tudo bem?

Cara acho que o problema é a versão que você esta usando dessa lib: androidx.core:core:1.12.0-alpha04

Geralmente esse lance de alpha é meio treta mesmo, costuma quebrar mesmo.

O problema é que tu colocou pra usar sempre a mais nova que tiver: implementation 'androidx.core:core-ktx:+'

O ideial é usar uma versão estável que você sabe o que tem de novo, tenta colocar a 1.11.0 e vê se funciona certinho

Espero ter ajudado e bons estudos!

solução!

Eu tinha mudado o implemention para 'androidx.core:core-ktx:+' porque falaram na internet para fazer isso, mudei para a versão 1.11.0, ainda continuou dando errado.

O que deu certo para mim foi criar um emulador de android novo com uma versão de android 12 ( e também consegui ativar as configurações para rodar também no meu celular xiomi) Ps: esse vídeo e esse fórum me ajudaram bastante

PS: depois de alguns dias eu descobri o real motivo para eu ter esse problema. Era simplesmente o fato do drive da minha placa de vídeo estar desatualizada. No log mostrava isso:

2023-05-19 09:07:31,281 [3870424]   WARN - #c.a.ddmlib - Failed to start monitoring emulator-5554
2023-05-19 09:07:31,541 [3870684]   INFO - #c.a.t.i.d.v.VirtualDeviceChangeListener - emulator-5554 disconnected
2023-05-19 09:07:31,541 [3870684]   INFO - #c.a.t.i.a.p.ProcessNameMonitor - Removing emulator-5554: 790660712
2023-05-19 09:07:31,757 [3870900]   INFO - #c.a.t.i.s.e.EmulatorController - Disconnected from 4.65  720p (Galaxy Nexus) API 24 (5554)
2023-05-19 09:07:33,294 [3872437]   INFO - Emulator: Pixel 5 API 31 - C:\Users\User\AppData\Local\Android\Sdk\emulator\emulator.exe -netdelay none -netspeed full -avd Pixel_5_API_31 -qt-hide-window -grpc-use-token -idle-grpc-timeout 300
2023-05-19 09:07:33,362 [3872505]   INFO - Emulator: Pixel 5 API 31 - Android emulator version 32.1.12.0 (build_id 9751036) (CL:N/A)
2023-05-19 09:07:33,362 [3872505]   INFO - Emulator: Pixel 5 API 31 - Found systemPath C:\Users\User\AppData\Local\Android\Sdk\system-images\android-31\google_apis\x86_64\
2023-05-19 09:07:33,594 [3872737]   WARN - Emulator: Pixel 5 API 31 - Please update the emulator to one that supports the feature(s): Vulkan
2023-05-19 09:07:34,011 [3873154]   WARN - Emulator: Pixel 5 API 31 - Your GPU drivers may have a bug. Switching to software rendering.

E se alguém tiver algum tipo de problema no emulador, vai no arquivo.idea que está nesta pasta:

C:\seuusuario\AppData\Local\Google\AndroidStudio2022.2\log

E tenta achar o log de erro pelo texto e pelo o horario que deu erro

Boa tarde galera!

O que resolveu pra mim foi alterar a versão do core-ktx no arquivo build.gradle

DE: implementation 'androidx.core:core-ktx:+'

PARA: implementation 'androidx.core:core-ktx:1.10.1'

As dependencias ficaram assim:

dependencies {
    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.5.0'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.core:core-ktx:1.10.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

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