Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I import and use android x library

I want to use a library to take the date from the user.

The project I use needs to add the library and classes from the AndroidX library.

Once I add this project by adding a module or by adding a direct command to gradle, the following error is given :

Link to the used project: https://github.com/wdullaer/MaterialDateTimePicker

Error :

Failed to resolve: androidx.appcompat:appcompat:1.0.2
Failed to resolve: androidx.recyclerview:recyclerview:1.0.0

build.gradle :

 apply plugin: 'com.android.application'
 android {

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.**********"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildToolsVersion '28.0.3'
    compileOptions {

        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12'
    implementation 'com.wdullaer:materialdatetimepicker:4.1.2'
}

If the following commands are added to gradle, the following error will be seen

dependencies {
    ...

    implementation 'com.wdullaer:materialdatetimepicker:4.1.2'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'

}

Error :

Failed to resolve: androidx.appcompat:appcompat:1.0.2
Failed to resolve: androidx.recyclerview:recyclerview:1.0.0

I do not have much information about the AndroidX library, but I do not think there are such libraries.

How can I fix it?

Is there a solution to this problem?

like image 785
A.Bahrami Avatar asked Nov 07 '22 20:11

A.Bahrami


1 Answers

You can easily migrate to AndroidX with the following steps:

1- first your Android Studio version must be 3.2.+

2- from the menu select Refactor -> Migrate to AndroidX

The Android Studio will show you the references to be changed. select Do Refactor and wait a few seconds, I hope this solves your problem.

like image 192
houman.sanati Avatar answered Nov 10 '22 00:11

houman.sanati