cannot resolve symbol for v4 media and app classes

Viewed 2045

I'm trying to import the following classes for my media player, but my app does not recognize them:

import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaControllerCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v7.app.NotificationCompat;

I've tried as others suggested (File->Invalidate Caches/restart), but the error remains.

gradle:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    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 'com.android.support:recyclerview-v7:28.0.0-rc02'
    implementation 'com.android.support:cardview-v7:28.0.0-rc02'
    implementation 'com.android.support:design:28.0.0-rc02'
    implementation group: 'com.google.code.gson', name: 'gson', version: '2.7', changing: true
}
3 Answers

Add this dependencies to your gradle ;

com.android.support:support-v4:YOUR_VERSION 

in long way ;

  • Project Structure --> Dependencies --> Click Plus sign -> Go to "Library dependency"
  • Select which support library "support-v4 (com.android.support:support-v4:YOUR_VERSION)"
  • Be sure about Android Support Library has been added to your dependencies.

Rebuild and work it.

Just Add Dependencies in our Gradle File

dependencies {
    ......
implementation 'com.android.support:support-v4:VERSION'
    .....
}

Ex

dependencies {
        ......
    implementation 'com.android.support:support-v4:27.0.1'
        .....
    }

For android x based projects, add this

implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Related