The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten

Viewed 2510

When I try to build my project I get this error:

The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten I Found many similar questions but they were not helpful to me I work with this Library:

And this is my code from Build:gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.majaxtn.codingup"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'

    implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
    implementation 'com.google.firebase:firebase-core:17.4.3'
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    implementation 'com.google.firebase:firebase-database:19.3.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'


    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'


    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'


    implementation 'androidx.appcompat:appcompat:1.1.0'




}
apply plugin: 'com.google.gms.google-services'

And below is the screen with my problem

Screenshot with error

1 Answers

I suggest you upgrade to AndroidX:

   dependencies {

   implementation 
  'com.google.android.material:material:1.1.0'
  implementation 'androidx.appcompat.appcompat:1.1.0'
   implementation 
   'androidx.constraintlayout.constraintlayout:1.1.3'
   implementation 'androidx.browser.browser:1.0.0
 }

PS: the versions are not the latest though, just pointing you in the right direction.

Remove these:

   implementation 
   'com.android.support:customtabs:28.0.0'
   implementation 'com.android.support:support-v4:28.0.0
   implementation 
  'com.android.support.constraint:constraint-layout:1.1.3'

Edit:

Add this in your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true
  

Then do a clean build after you sync.

Cheers!

Related