12

I have error like this after trying to build my apps in Emulator

/Users/joel/.gradle/caches/transforms-3/06231cc1265260b25a06bafce7a4176f/transformed/core-1.7.0-alpha02/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

I don't know what causes this error. After digging some answer which has similarly error (but in flutter) Problem. But still not solved my issue.

I have this dependency in my project

buildscript {
    repositories {
        google()
        maven { url 'https://plugins.gradle.org/m2/' }
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.crashlytics'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://maven.google.com' }
    maven { url  "https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod"}
    mavenCentral()

}

android {
    compileSdkVersion 29
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "mobile.apps.my"
        minSdkVersion 17
        targetSdkVersion 29
        multiDexEnabled true
        versionCode 152
        versionName "8.1.7"
        vectorDrawables.useSupportLibrary = true // This line hereP
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dataBinding {
        enabled = true
    }

    buildTypes {
        debug {
            firebaseCrashlytics {
                mappingFileUploadEnabled false
            }
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0-beta01', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.4.0-alpha03'
    implementation "androidx.appcompat:appcompat-resources:1.4.0-alpha03"

    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'androidx.preference:preference:1.1.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'

    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
    implementation 'it.sephiroth.android.library.imagezoom:imagezoom:2.3.0'
    testImplementation 'org.json:json:20140107'
    implementation 'com.comscore:android-analytics:6.1.0'
    implementation 'com.android.support:customtabs:29.0.0'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.android.support:customtabs:29.0.0'

    // Kodein Dependency Injection
    implementation 'org.kodein.di:kodein-di-generic-jvm:6.2.1'
    implementation 'org.kodein.di:kodein-di-framework-android-x:6.2.1'

    // RETROFIT
    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.retrofit2:converter-scalars:2.1.0' // for test String


    // Room components
    implementation "androidx.room:room-runtime:2.2.5"
    kapt "androidx.room:room-compiler:2.2.5"
    implementation "androidx.room:room-ktx:2.2.5"
    androidTestImplementation "androidx.room:room-testing:2.2.5"

    // Lifecycle components
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'androidx.paging:paging-runtime:2.1.2'

    // UI
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.geniusforapp.fancydialog:FancyDialog:0.1.4'
    implementation 'com.github.bluzwong:swipeback:0.2.0@aar'
    implementation 'com.airbnb.android:lottie:3.6.0'

    implementation 'com.veinhorn.scrollgalleryview:library:1.2.6'
    implementation 'com.veinhorn.scrollgalleryview:picasso-loader:1.2.4'
    implementation 'com.github.rubensousa:bottomsheetbuilder:1.6.1'
    implementation "com.andkulikov:transitionseverywhere:1.8.1"


    // HTTP LOGGING
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'org.jsoup:jsoup:1.13.1'
    implementation 'androidx.multidex:multidex:2.0.1'


    // ADS
    implementation 'com.android.support:support-annotations:28.0.0'
    // Required Dependency by Audience Network SDK
    implementation 'com.google.android.gms:play-services-ads:19.7.0'
    implementation 'com.google.android.gms:play-services-basement:17.6.0'
    implementation("tv.teads.sdk.android:sdk:4.7.2@aar") {
        transitive = true
    }
    implementation 'com.criteo.publisher:criteo-publisher-sdk:4.0.0'
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
    implementation 'com.google.android.gms:play-services-base:17.6.0'

    implementation ('com.facebook.android:audience-network-sdk:5.5.0'){
        exclude group: 'com.google.android.gms'
    }

    implementation 'com.google.firebase:firebase-crashlytics:17.4.0'

    implementation "androidx.core:core-ktx:1.6.0"  // I have update this based on other solution
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // COROUTINES
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'

    // Kotlin + coroutines
    implementation "androidx.work:work-runtime-ktx:2.5.0"

    implementation 'com.github.mumayank:AirLocation:1.3.1'
    androidTestImplementation 'androidx.test:rules:1.3.0-beta01'

    implementation 'com.android.installreferrer:installreferrer:2.2'

    //ANIMATION
    implementation 'com.daimajia.androidanimations:library:2.4@aar'
    implementation 'com.infideap.drawerbehavior:drawer-behavior:1.0.4'
    implementation 'com.romandanylyk:pageindicatorview:1.0.3'

    implementation 'org.ocpsoft.prettytime:prettytime:5.0.0.Final'

    //SOCIAL
    implementation 'com.google.android.gms:play-services-auth:19.0.0'

}

I have tried to upgrade version of androidx.core:core-ktx:1.6.0 then sync or invalidate cache/restart. But none of them give me good result. I am sure yesterday my project was alright with same dependency. Someone please help me, if this question unclear let me add more information. Thanks

Nanda Z
  • 1,604
  • 4
  • 15
  • 37
  • 4
    It seems that at least one of your dependencies is already using `lStar` which is a system attribute that's new as of API level 31, but your build tools are only aware of things up to 29. Simply increasing your `compileSdkVersion` to 31 should allow that attribute to be resolved. Can you do that for this project? – Mike M. Sep 03 '21 at 10:40
  • 1
    This is due to the new `1.7.0-alpha02` version of the core androidx dependency which is causing the issue, simply switch to any stable version, this question has already been posted here so many times now – gtxtreme Sep 03 '21 at 10:52
  • [Here](https://developer.android.com/jetpack/androidx/releases/core) is all the list of releases of this dependency , so you should switch to the stable version to be safe – gtxtreme Sep 03 '21 at 10:54
  • @gtxtreme This isn't a [react-native] question. It is not advisable to downgrade anything if they can simply update their build tools. – Mike M. Sep 03 '21 at 10:54
  • @MikeM. yes, I was just going to add that if you upgrade to `1.7.0-alpha02` then you have to use `targetSdk 31` i.e. Android 12, and this issue is just Google preparing for stable Android 12 release and things like these, happen every year – gtxtreme Sep 03 '21 at 10:57
  • @MikeM. I can not switch `compileSDKVersion` to 31 because i need to use ` implementation 'com.android.support:customtabs:29.0.0'` this dependency will be red light – Nanda Z Sep 03 '21 at 12:21
  • @gtxtreme i have tried androidx.core:core-ktx:1.2.0, 1.6.0 ,and 1.7.0-alpha02 but no luck. in the Past i use 1.2.0 and no issue. could it be `implementation "androidx.work:work-runtime-ktx:2.5.0"` causing this problem. Because this is newest dependency that i added, yesterday everything is fine i even can run workmanager feature with old dependency core (1.2.0) – Nanda Z Sep 03 '21 at 12:39
  • Yes, as I said, this is because google is moving everything to be ready for Android 12 and a stable release is expected soon, but the issue is with the core dependency only, did your try to clean and rebuild after downgrading? – gtxtreme Sep 03 '21 at 12:41
  • @gtxtreme i reverted all my dependency that same with release version apk and now it became error with same error. This is weird – Nanda Z Sep 03 '21 at 12:56
  • I am sure in released apk i use androidx.core:core-ktx:1.2.0 and androidx.work:work-runtime-ktx:2.5.0 and both of them are works but now after bulding my project become error – Nanda Z Sep 03 '21 at 12:58
  • This is one of the worst plagues on Android currently. Even if you manage to fix it, you can be guaranteed that it will be back. – Johann Jan 14 '22 at 09:06
  • If you're getting this error in November 2022 you can may be encountering [this bug](https://github.com/facebook/react-native/issues/35210) that Facebook introduced on Nov 4th. It's a quick fix in your `build.gradle` file. – chichilatte Nov 06 '22 at 21:51

5 Answers5

14

QUICK FIX

In build.gradle(:app) file change version of appcompat to 1.3.0:

implementation 'androidx.appcompat:appcompat:1.3.0'
PRANAV SINGH
  • 1,000
  • 11
  • 17
13

I managed to fix this by upgrading compileSdk to 31 and kotlin gradle plugin to 1.5.10

compileSdk = 31

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10'
fetchSerotonin
  • 192
  • 1
  • 9
3

In my case, I was using a library which recently upgraded to androidx.appcompat:appcompat:1.4.1 and since then I started getting this error.

So, till the time the author's of this library do not provide any fix I forced the appcompat version to 1.3.0

configurations.all {
        resolutionStrategy.force 'androidx.appcompat:appcompat:1.3.0'
    }
Astha Garg
  • 1,022
  • 7
  • 21
1

I changed version of appcompat from 1.4.0 to androidx.appcompat:appcompat:1.1.0 in the build.gradle, and it worked for me.

Haleh
  • 19
  • 1
0

1.7.0-alpha02 requires targetSdk 31.

So upgrade your sdk values.

You can use this:

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        androidXCore = "1.6.0"
     }
}
hkniyi
  • 263
  • 3
  • 7