Android-youtube-player: App crashes on Android 5 - Resources$NotFoundException: String resource ID #0x2040002

Created on 25 Oct 2019  路  23Comments  路  Source: PierfrancescoSoffritti/android-youtube-player

The crash is continuously happening for android lollipop micromax and intex devices
here is the stacktrace

com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.WebViewYouTubePlayer. + 25聽(WebViewYouTubePlayer.java:25)

聽 | com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.WebViewYouTubePlayer. + 24聽(WebViewYouTubePlayer.java:24)
聽 | com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.LegacyYouTubePlayerView. + 34聽(LegacyYouTubePlayerView.java:34)
聽 | com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.LegacyYouTubePlayerView. + 31聽(LegacyYouTubePlayerView.java:31)
聽 | com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView. + 30聽(YouTubePlayerView.java:30)
聽 | com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView. + 27聽(YouTubePlayerView.java:27)

Please fix it asap

bug

Most helpful comment

Fairly sure the problem is androidx.appcompat version 1.1.0. Downgrading to 1.0.2 should solve the problem. https://stackoverflow.com/questions/41025200/android-view-inflateexception-error-inflating-class-android-webkit-webview

App devs can do this workaround:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation('com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5') {
    exclude group: 'androidx.appcompat'
}

All 23 comments

This is not very helpful. Let me know how to replicate this issue. Do I just need to run the sample app on any device running Android 5?

Yeah.
Just run this code
YouTubePlayerView youtubePlayerView = new YouTubePlayerView(getContext());
intex, micromax devices with api level less than equal to 22.
Intex - AquaAce mini
Micromax - Canvas 5, Canvas Spark, Canvas juice2

Unfortunately I don't own any intex, micromax device.

Hi!

I have the same problem on Android 5.1.1 (HUAWEI Y6) :

Caused by android.content.res.Resources$NotFoundException
String resource ID #0x3040005

Stacktrace:

android.content.res.HwResources.getText (HwResources.java:1299)
android.webkit.WebView.<init> (WebView.java:472)
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.WebViewYouTubePlayer.<init> (WebViewYouTubePlayer.kt:25)
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.WebViewYouTubePlayer.<init> (WebViewYouTubePlayer.kt:24)
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.LegacyYouTubePlayerView.<init> (LegacyYouTubePlayerView.kt:34)
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.LegacyYouTubePlayerView.<init> (LegacyYouTubePlayerView.kt:31)
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView.<init> (YouTubePlayerView.kt:30)
com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView.<init> (YouTubePlayerView.kt:28)
java.lang.reflect.Constructor.newInstance (Constructor.java)
android.view.LayoutInflater.inflate (LayoutInflater.java:425)
com.myapp.widget.youtube.YoutubeDialogFragment.onCreateView (YoutubeDialogFragment.java:129)

For information, the view YoutubePlayerView is put on my layout XML (very standard case):

<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
                android:id="@+id/video_player"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

Thank you very much for your great library!

Hi, this seem to be separate issue. What happens if you remove all Java code (related to the player) and to everything with xml?

<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
        android:id="@+id/youtube_player_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        app:videoId="S0Q4gqBUs7c"
        app:autoPlay="true"
        app:showFullScreenButton="false" />

Unfortunately I can't test (I don't have this mobile). It was a crash from an user.

This crash appears during Activity layout inflate process. So from this point nothing stuff is done on JAVA into my source code. So I think your idea will have no effect on this bug.

hi @PierfrancescoSoffritti ,this bug is same as https://stackoverflow.com/questions/58028821/android-q-webview-crash-on-android-5-5-1-api-21-22-resourcesnotfoundexception.your library might use webview ( i just use it,not read the source code).so might have some update for this i guess.hope to see your response!! thanks !

Thanks for the link, looks like it's the same issue. I don't know when I will have time to look into it, if someone finds a solution/more info: comments and pull requests are welcome.

@PierfrancescoSoffritti i create pull request by using Android Studio,but it keep error 403 : no permision

Fairly sure the problem is androidx.appcompat version 1.1.0. Downgrading to 1.0.2 should solve the problem. https://stackoverflow.com/questions/41025200/android-view-inflateexception-error-inflating-class-android-webkit-webview

App devs can do this workaround:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation('com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5') {
    exclude group: 'androidx.appcompat'
}

@talklittle trust me,it not work so well.i tryed and still the same problem

Yeah, I think @talklittle 's solution makes sense. Should solve the problem, at least for now.

@cuongnb96 you say you have pull request, what's your solution? (You don't need any permission to submit pull requests. Maybe you're trying to push directly on my branch?)

@PierfrancescoSoffritti oh,i just tryed @talklittle way and it still crash on my device ( i guess it not always crash on 5. devices, just few one).Please preview this https://github.com/cuongnb96/android-youtube-player/commit/d7ba58db11c57e46418312fc87030fee14b6dc8f.i fork your lib and fix it ( i found this solution and it work on my device and other 5. device) and use that instead of Webview

Yeah, I think @talklittle 's solution makes sense. Should solve the problem, at lest for now.

@cuongnb96 you say you have pull request, what's your solution? (You don't need any permission to submit pull requests. Maybe you're trying to push directly on my branch?)

i created a new branch and try to push it.but i cant.zzz.so pls check my comment above.it's the only way i can make it work on my device ( and all other )

Updating the appcompat library solved the crash for me

implementation 'androidx.appcompat:appcompat:1.2.0-beta01'

as of writing this comment, MAY 2020
Updating the appcompat library solved this crash as well as webview crash too

implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'

I 1.2.0 stable out? if yes no need to use 1.3.0-alpha

Unfortunately current stable version 1.1.0

1.2.0 stable available now.

Does 1.2.0 stable solve the problem?

We faced this crash today and I can confirm it stopped occurring when we updated to the stable implementation 'androidx.appcompat:appcompat:1.2.0' (at least in our case).

It still crashes for stable 1.2.0 on API 21/ API 22

Doesn't crash for me. Make sure that it's not crashing for other reasons.

Was this page helpful?
0 / 5 - 0 ratings