Build failing with androidx.navigation.safeargs.kotlin - android-studio

I am unable to add navigation components to my project.
I am constantly getting following error:
An exception occurred applying plugin request [id: 'androidx.navigation.safeargs.kotlin']
Failed to apply plugin 'androidx.navigation.safeargs.kotlin'.
safeargs plugin must be used with android plugin
My build gradle looks like this:
id 'androidx.navigation.safeargs.kotlin'
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdk 33
defaultConfig {
applicationId "com.mushroomgathererv1"
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'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//additional dependency
implementation 'com.google.android.gms:play-services-location:20.0.0'
// Navigation Component
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
// Room components
implementation "androidx.room:room-runtime:2.4.3"
kapt "androidx.room:room-compiler:2.4.3"
implementation "androidx.room:room-ktx:2.4.3"
androidTestImplementation "androidx.room:room-testing:2.4.3"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1"
}
And the other one:
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'androidx.navigation.safeargs' version '2.5.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Is there anything that I am missing here?

Related

After updating compileSdk to version 33, part of the attributes in design stopped being displayed

After updating the androidx.appcompat library:appcompat:1.5.1 to version 1.6.0 android studio gave me this error message:
error message
I have updated compileSdk and versionSdk from version 32 to version 33. After that, most of the attributes were no longer displayed in the Design mode for the elements.
attributes before | attributes after
build.gradle (app):
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
android {
compileSdk 33
defaultConfig {
applicationId "com.gramzin.kilo"
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 platform('com.google.firebase:firebase-bom:31.2.0')
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-database-ktx:20.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'androidx.activity:activity-ktx:1.5.1'
}
I tried changing the gradle version to 7.4.2 and the android gradle plugin version to 7.2.2, but it doesn't help.
I updated android studio and gradle to the latest version and everything worked

Android resource linking failed, error: failed parsing overlays Android

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.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. error in android studio version dolphin 2021.3.1

My Android Studio Current version Dolphin 2021.3.1 patch 1, in my project I am getting following build error in empty project while adding a fresh dependency. ie.
implementation 'io.github.amrdeveloper:codeview:1.3.7'
getting from here >>> https://amrdeveloper.github.io/CodeView/install/#main-features
I have already checked lots of Solutions related this question but no luck.
build.gradle:project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
build.gradle:module
plugins {
id 'com.android.application'
}
android {
namespace 'com.myvpn.myapp'
compileSdk 32
defaultConfig {
applicationId "com.myvpn.myapp"
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
}
}
dependencies {
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'
//added these two dependencies
implementation 'io.github.amrdeveloper:codeview:1.3.7'
implementation 'com.github.AmrDeveloper:CodeView:1.3.7'
}
Build Output.
enter image description here
i have tried turn off the Toggle Offline Mode .
enter image description here

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' }

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