Android resource linking failed, error: failed parsing overlays Android - android-studio

Recently I got this error when I build my app. I did not modify anything from my last successful build.
here is the error that I got
Android resource linking failed
C:\Users\Asus\.gradle\caches\transforms-3\d7936c72110369b4f70374bb97b71a45\transformed\com.google.android.gms.base\drawable-hdpi-v4_common_full_open_on_phone.png.flat: error: failed to read file: magic value is 0x929c1a24 but AAPT expects 0x54504141.
error: failed parsing overlays.
Here is my build.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'kotlin-parcelize'
}
android {
namespace 'com.example.amiconnew'
compileSdk 33
defaultConfig {
applicationId "com.example.amiconnew"
minSdk 21
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_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
/*CUSTOM LIBRARY*/
// MAPS
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation "com.google.android.gms:play-services-location:20.0.0"
implementation 'com.google.maps.android:android-maps-utils:2.3.0'
//LIVE DATA
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.activity:activity-ktx:1.6.0"
//LIFECYCLE SCOPES LIBRARY
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation 'androidx.datastore:datastore-preferences:1.0.0'
// RETROFIT
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
// MATERIAL DESIGN
implementation "com.google.android.material:material:1.8.0-alpha01"
//NAVIGATION
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
//SWIPE REFRESH LAYOUT
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
}
Can someone help me?
I have cleaned and rebuild my app, I have restarted my Android Studio, I also updated to the last version of IDE but nothing seem to work.

Related

Unresolved reference: compose in RelayBaseComposable

I tried to import figma designs to Android studio using Relay to Figma tool, but it gave me this error after i fixed my HOME_JAVA problem, which it was telling me that HOME_JAVA invalid directory.
this is my code:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id'com.google.relay' //added to figma
}
android {
compileSdk 32
sourceSets {
main {
assets {
srcDir('src/main/ui-packages') //added to figma
}
}
}
defaultConfig {
applicationId "com.example.figma_layout"
minSdk 21
targetSdk 32
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_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}
Unresolved reference: compose in RelayBaseComposable -- this error message indicates that the code is attempting to access the compose function from the RelayBaseComposable class, but this class or function cannot be located.
It seems like the Relay to Figma tool requires the Relay library to be added as a dependency in your build.gradle file, but it's not specified in the dependencies block of the code you provided.
Can you try this? Add this to your dependencies block:
implementation 'com.google.relay:relay:0.1.0'
This should import the Relay library, thus resolving the reference to the compose function mentioned in your error message.

Gardle sync error due to dependency being unresolvable

I am currently developing an android app with AR features using the library com.gorisse.thomas.sceneform:sceneform:1.21.0. It was working fine up until now. Whenever I try to sync the project the dependency is not resolvable.
I once had this exact same problem, but a simple computer restart resolved the issue. Now that doesn't work anymore. I tried deleting the .idea and .gradle folders and importing the project instead of opening it.
More details:
The error I get:
Failed to resolve: com.gorisse.thomas.sceneform:sceneform:1.21.0
Show in Project Structure dialog
Show Details
Affected Modules: app
What my build.gradle looks like:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 33
packagingOptions {
resources {
pickFirsts += ['META-INF/DEPENDENCIES']
}
}
buildFeatures {
viewBinding true
}
defaultConfig {
applicationId "com.example.rocksterapp"
minSdk 29
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_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
androidResources {
noCompress 'filamat', 'ktx'
}
namespace 'com.example.<appname>'
}
dependencies {
implementation 'com.google.android.filament:filamat-android:1.21.1'
implementation 'com.gorisse.thomas.sceneform:sceneform:1.21.0'
implementation 'androidx.fragment:fragment-ktx:1.5.3'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-ui:2.5.2'
implementation 'androidx.navigation:navigation-fragment:2.5.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Edit:
I created a new project and just simply copied every file from the old one into it. Problem isn't fixed. Now not only one dependency can't be resolved but three. Sceneform is not included in these.

Failure to setup Room in build.grade

I'm trying to configure the build.grade to use Room
The error persists:
Unresolved reference: room
And, consequently, the anotation remains Unresolved
#Entity
After 7 tutorials and 3 days, I have to surrender and ask for help.
Here I paste my build.grade. I've got it from this google tutorial:
https://developer.android.com/codelabs/android-room-with-a-view-kotlin#3
Which, by the way, is completely diferent from this other google tutorial:
https://developer.android.com/training/data-storage/room
What am I doing wrong?
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.firewalker.mouth_conjugation"
minSdk 21
targetSdk 32
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_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
dependencies {
implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
implementation "androidx.activity:activity-ktx:$rootProject.activityVersion"
// Dependencies for working with Architecture components
// You'll probably have to update the version numbers in build.gradle (Project)
// Room components
implementation "androidx.room:room-ktx:$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-common-java8:$rootProject.lifecycleVersion"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"
// UI
implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"
// Testing
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
androidTestImplementation ("androidx.test.espresso:espresso-core:$rootProject.espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation "androidx.test.ext:junit:$rootProject.androidxJunitVersion"
}```
I have used these dependency for ROOM they worked find for me
kapt "androidx.room:room-compiler:2.4.2"
implementation "androidx.room:room-runtime:2.4.2"
implementation "androidx.room:room-ktx:2.4.2"
androidTestImplementation "androidx.room:room-testing:2.4.2"
And these are the Plugins:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
}
P.S it would had been great if you had shared the error code.
Thanks to Mike T and Dkathayat1, it worked. I had to set the correct versions.
The code is the folowing:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.firewalker.mouth_conjugation"
minSdk 21
targetSdk 32
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_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
dependencies {
implementation "androidx.appcompat:appcompat:1.4.1"
implementation "androidx.activity:activity-ktx:1.4.0"
// Dependencies for working with Architecture components
// You'll probably have to update the version numbers in build.gradle (Project)
// Room components
implementation "androidx.room:room-ktx:2.4.2"
implementation 'androidx.room:room-common:2.4.2'
kapt "androidx.room:room-compiler:2.4.2"
androidTestImplementation "androidx.room:room-testing:2.4.2"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.4.1"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
// UI
implementation "androidx.constraintlayout:constraintlayout:2.0.2"
implementation "com.google.android.material:material:1.2.1"
// Testing
testImplementation "junit:junit:4.13.1"
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
androidTestImplementation ("androidx.test.espresso:espresso-core:3.1.0", {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation "androidx.test.ext:1.1.2"
}
Adding kotlin-dsl in plugins of module's gradle file solved the issue for me.
plugins { 'kotlin-dsl' }

Execution failed for task ':app:mergeDebugResources' occur while running the app

I am a beginner in android studio. When I try to run the app on my mobile phone, android studio shows me this error:
"execution failed for task ':app:mergedebugresources'. A failure
occurred while executing
com.android.build.gradle.internal.res.ResourceCompilerRunnable"
My build gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.newlogin2"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
aaptOptions{
cruncherEnabled = false
useNewCruncher = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:21.0.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
implementation platform('com.google.firebase:firebase-bom:28.2.0')
implementation 'com.google.firebase:firebase-analytics'
}
Any one can help please? Thank you!
Check your code if you follow some tutorials and then
go to
file -> invalidate caches/Restart

How can I solve this error : Data Binding annotation processor version needs to match the Android Gradle Plugin version

I am trying to data bind my project but I am getting this error in my Gradle file I am a beginner so let me know which files you need or what other information do you need more?
Data Binding annotation processor version needs to match the Android Gradle Plugin version. You can remove the kapt dependency androidx.databinding:databinding-compiler:7.1.0-alpha01 and Android Gradle Plugin will inject the right version.
build.gradle (:app)
plugins {
id 'com.android.application'
id 'kotlin-android'
// id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'kotlin-parcelize'
// id "androidx.navigation.safeargs.kotlin"
id 'androidx.navigation.safeargs.kotlin'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.todoappstevdzaskillshare1"
minSdkVersion 26
targetSdkVersion 30
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_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dataBinding {
enabled = true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//DataBinding
kapt 'androidx.databinding:databinding-compiler:7.1.0-alpha01'
// Navigation Component
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
// Room components
implementation "androidx.room:room-runtime:2.3.0"
kapt "androidx.room:room-compiler:2.3.0"
implementation "androidx.room:room-ktx:2.3.0"
androidTestImplementation "androidx.room:room-testing:2.3.0"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
}
NOTE: Let me know which more files do you need and I will edit the question.
You need to delete this line of code kapt'androidx.databinding:databinding-compiler:7.1.0-alpha01' and recompile. According to Google's open databinding document, the way to open databinding is:
android {
...
dataBinding {
enabled = true
}
}
I think databinding is already enabled in your gradle. So just delete the dependency and this error shouldn't occur.

Resources