android - 如何防止错误膨胀类 com.google.android.exoplayer2.ui.PlayerView?
问题描述
Exoplayer2 在三星、Vivo、小米等设备上的发布和调试版本都运行良好。但是当我在 Play 商店上发布我的应用程序时,它会在一些设备上抛出错误,比如 nexus、像素手机。
Crashlytics showing this error: Caused by android.view.InflateException:
Binary XML file line #11: Error inflating class com.google.android.exoplayer2.ui.PlayerView
我发现已经针对同一问题提出了一些类似的问题,但对我没有任何用处。(我使用的是没有任何自定义的默认播放器)有人可以帮我解决这个问题吗?
我的代码:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/playerView"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
var player:SimpleExoPlayer?=null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.pdf_view_normal)
player = ExoPlayerFactory.newSimpleInstance(this)
val mediaDataSourceFactory = DefaultDataSourceFactory(this, getUserAgent(this, "demo.smart.com"))
val mediaSource = ProgressiveMediaSource.Factory(mediaDataSourceFactory)
.createMediaSource(Uri.parse(""))
with(player) {
this!!.prepare(mediaSource, false, false)
playWhenReady = true
}
playerView.setShutterBackgroundColor(Color.TRANSPARENT)
playerView.player = player
playerView.requestFocus()
}
override fun onDestroy() {
super.onDestroy()
if(player!=null){
player!!.stop()
}
}
摇篮
android{
kotlinOptions {
jvmTarget = "1.8"
}
..
}
implementation 'com.google.android.exoplayer:exoplayer:2.10.8'
所有日志供您参考
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{demo.smart.com.Viewer}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.exoplayer2.ui.PlayerView
Caused by android.view.InflateException
Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.exoplayer2.ui.PlayerView
解决方案
推荐阅读
- php - Laravel Passport Auth::attempt() 在我安装默认 laravel 授权后总是返回 false
- flutter - 使用 Bloc 列出项目
- php - 有没有人有在浏览器中打开 PHP/HTML/JS 以获取可视代码的经验?
- gradle - 将环境变量传递给 gradle.properties
- php - Bootstrap navbar-default 隐藏表单内容
- reactjs - 它不会进入我的循环,但它像条件一样优越
- reactjs - 我不能在 Create React App + node-sass setup 的 sass 文件中使用 @use
- swift - 为什么 DispatchGroup 无法正常工作
- typescript - npm 包与旧版本的包依赖项兼容
- xamarin - Xamarin.forms- 具有多个值的 Firebase 数据库更新 (Android)