我正在尝试为媒体播放器导入以下类,但我的应用无法识别它们:
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;
我已经尝试过按照其他人的建议(File->Invalidate Caches/restart)
,但错误仍然存在。
等级:
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
}
答案 0 :(得分:2)
将此依赖项添加到您的gradle中;
com.android.support:support-v4:YOUR_VERSION
很远;
重建并工作。
答案 1 :(得分:1)
只需在Gradle文件中添加依赖项
dependencies {
......
implementation 'com.android.support:support-v4:VERSION'
.....
}
Ex
dependencies {
......
implementation 'com.android.support:support-v4:27.0.1'
.....
}
答案 2 :(得分:0)
对于基于android x的项目,添加此
implementation 'androidx.legacy:legacy-support-v4:1.0.0'