I got Error:
android.view.InflateException: Binary XML file line #24: Error inflating class com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
I use 'com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.3'
i got same error when xml file without videoId .if you want solve this error then set autoplay false or set video id in xml file
i got same error when xml file without videoId .if you want solve this error then set autoplay false or set video id in xml file
Thanks for your solution. It works now.
I麓m having the same problem with API 21, on API 27, 28 the problem doesn麓t happen. Only on old ones ...
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:videoId="I08i3ztnJdE"
app:autoPlay="false"
app:showFullScreenButton="true" />
I doubt this is related to API level. Are you sure this is the issue you're having?
I doubt this is related to API level. Are you sure this is the issue you're having?
I麓ts a very simple activity and it麓s working on API 27, 28 simulator and real devices.
But if open this Activity on API 21 I got the error above.
If I remove the YouTubePlayerView from the Activity it opens with no erros.
I麓m already using Androidx library.
Thanks
For some reason only since updating to 10.0.4, I have this issue, but it is actually an Resources$NotFoundException: String resource ID #0x2040003 inside WebView class, which is obviously a bug on API 21 phones which don't have Android WebView updated from the PlayStore.
Both problem and the solution are explained here in detail, so it would be nice if @PierfrancescoSoffritti could try to reproduce it and include a fix in the next release: https://stackoverflow.com/questions/41025200/android-view-inflateexception-error-inflating-class-android-webkit-webview
Thanks.
Hey, I'm currently traveling and don't have my personal laptop with me. I can try fixing #430 today but won't have time for #491 (at least for the next week). Feel free to send pull requests.
internal class WebViewYouTubePlayer constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : WebView(context.applicationContext, attrs, defStyleAttr),
YouTubePlayer,
YouTubePlayerBridge.YouTubePlayerBridgeCallbacks {
Solution: https://stackoverflow.com/a/58695635/7212836
Created pull request : https://github.com/PierfrancescoSoffritti/android-youtube-player/pull/473
So this seems to be an issue with androidx.appcompat version 1.1.0. I think the best solution is to wait for the Android team to fix it.
In the meantime this is a temporary solution.
I tried this solution and not work for me, but when I add the following code in the activity where I inflate YouTubePlayerView, it's worked:
override fun applyOverrideConfiguration(overrideConfiguration: Configuration) {
if (Build.VERSION.SDK_INT in 21..22) {
return
}
super.applyOverrideConfiguration(overrideConfiguration)
}
I found the solution here: https://stackoverflow.com/a/58695635/7212836, thanks to @SJOwl
i am using this lib on my android api level 28 but it seems not working , did it mean that it doesnt have backward compatibility i am getting an error like:
android.view.InflateException: Binary XML file line #7: Error inflating class
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
and i am using it in fragment where youtubePLayerView.addYoutubeListner is not importing
youTubePlayerViewLib = mRootView.findViewById(R.id.youtubeplayer);
getActivity().getLifecycle().addObserver(youTubePlayerViewLib);
youTubePlayerViewLib.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
@Override
public void onReady(@NonNull YouTubePlayer youTubePlayer) {
String videoId = "S0Q4gqBUs7c";
youTubePlayer.loadVideo(videoId, 0);
}
});
Where youTubePlayerViewLib is YouTubePlayerView
And the thing is i can't migrate my project to androidX.
Anysolution to this is highly appreciated , as i tried above some but no one seems good for me.
It doesn't make sense to set autoplay to true without providing a video id.
It does make sense if you're just getting started and refactoring from old Youtube lib code. It would be smarted to check for this within the lib, since most use cases will use dynamic Youtube Video Ids
I agree, the current way of handling incorrect xml attributes is not great.
Most helpful comment
i got same error when xml file without videoId .if you want solve this error then set autoplay false or set video id in xml file