24

I cannot import MediaSessionCompat. The import statement for importing the whole android.support.v4.media library does not show up in the Android Studio "IntelliSense" and it cannot resolve the symbol for anything inside it.

Do I have to make some kind of extra configuration to get this import, like in app build.gradle?

Tomas Jablonskis
  • 4,246
  • 4
  • 22
  • 40
Emil Walser
  • 615
  • 2
  • 7
  • 14

3 Answers3

62

Add these to your dependencies and sync Gradle:


Pre-AndroidX

implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'

Post-AndroidX

implementation 'androidx.core:core:1.8.0'
implementation 'androidx.media:media:1.6.0'

Note from official documentation:

With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components. You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library. We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.

Tomas Jablonskis
  • 4,246
  • 4
  • 22
  • 40
  • 1
    The latest dependencies as at (September 30th, 2020) are: implementation 'androidx.core:core:1.3.1' and implementation 'androidx.media:media:1.2.0' – Kenny Dabiri Sep 30 '20 at 00:14
16

The latest dependencies are:

implementation 'androidx.core:core:1.1.0'
implementation 'androidx.media:media:1.1.0'
Silambarasan
  • 645
  • 1
  • 7
  • 13
  • 1
    The latest dependencies as at (September 30th, 2020) are: implementation 'androidx.core:core:1.3.1' and implementation 'androidx.media:media:1.2.0' – Kenny Dabiri Sep 30 '20 at 00:13
0
 def core_version = "1.9.0"

// Java language implementation
implementation "androidx.core:core:$core_version"
// Kotlin
implementation "androidx.core:core-ktx:$core_version"

implementation "androidx.media:media:1.6.0"