0

Before I published it here, I searched a lot, but I could not find a solution.

why CoordinatorLayout not found on my project ?

screenshot

enter image description here

gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.salah250.forvo"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    //Material Design
    implementation 'com.android.support:design:27.1.1'
    //Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    //GSON
    implementation 'com.google.code.gson:gson:2.8.5'
    //Event Bus
    implementation 'org.greenrobot:eventbus:3.1.1'
    //Picasso
    implementation 'com.squareup.picasso:picasso:2.71828'
    //Butter knife
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    //Circle Image
    implementation 'de.hdodenhof:circleimageview:2.2.0'
}

I hope to find a solution to this problem..............................

3 Answers 3

3

If you checked the dependencies (com.android.support:appcompat-v7:27.1.1) and in the layout which starts by: androidx.coordinatorlayout It means you're still using Support Library dependencies but you are trying to use AndroidX CoordinatorLayout.

Use Migrate to AndroidX from Refactor or, use Support Library CoordinatorLayout:

<android.support.design.widget.CoordinatorLayout>
</android.support.design.widget.CoordinatorLayout>

Read: https://developer.android.com/jetpack/androidx/migrate

0

There are some pre-requisities for setting up AndroidX. You can find some of them in the Using AndroidX section of the documentation as well as in the Migrate an existing project using Android Studio.

The first and only thing I can notice from the snippet you have provided, you have not set the compileSdkVersion to 28, but please check the links that I have provided you with. There may be more to it.

3
  • compileSdkVersion was 28 but I changed to 27 because not working
    – Taha Sami
    Oct 15, 2018 at 15:07
  • Try to have compileSdkVersion 28 in your gradle file and android.useAndroidX=true android.enableJetifier=true in your gradle.properties file. If this doesn't work, refer to the documentation for more.
    – Galatia
    Oct 15, 2018 at 15:18
  • 1
    @NiravKotecha happy to help :)
    – Galatia
    Jul 3, 2019 at 14:31
-1

just put these two lines in your gradle.properties -file:

android.useAndroidX=true
android.enableJetifier=true

Do a gradle sync and you're set :)

2
  • where inside what ?
    – Taha Sami
    Oct 15, 2018 at 15:16
  • You have a file named gradle.properties in your project's folder. You have to add the mentioned lines here, make a gradle sync and after this you should find CoordinatorLayout with androidX
    – Zholoth
    Oct 15, 2018 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.