Closed naveen-chimaniya closed 4 years ago
Same issues as #34. In short you can currently only work around it by moving the web view into a separate activity.
If you want to try something out, you can however also try out this way, which is not yet available in the normal version of ViewPump.
Add this temporary versions of ViewPump & Reword in your build.gradle:
// ViewPump
implementation "com.github.B3nedikt:ViewPump:add_update_context_method-SNAPSHOT"
// Reword
implementation "com.github.B3nedikt:reword:update_build-SNAPSHOT"
Then in your BaseFragment, or if you don't have one in every fragment add:
abstract class BaseFragment : Fragment() {
override fun onResume() {
super.onResume()
ViewPump.setOverwriteContext(AppLocale.wrap(requireContext()))
}
override fun onGetLayoutInflater(savedInstanceState: Bundle?): LayoutInflater {
val wrappedContext = ViewPumpContextWrapper.wrap(AppLocale.wrap(requireContext()))
return wrappedContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
}
}
This may fix the bug as well, I am still working on these new versions though ;)
@B3nedikt Getting below after add B3nedikt:ViewPump
Duplicate class io.github.inflationx.viewpump.FallbackViewCreator found in modules ViewPump-add_update_context_method-SNAPSHOT-runtime.jar (com.github.B3nedikt:ViewPump:add_update_context_method-SNAPSHOT:v2.0.3-ge9153f7-3) and viewpump-2.0.3-runtime.jar (io.github.inflationx:viewpump:2.0.3)
And what is AppLocale in above code. I am using this version implementation 'dev.b3nedikt.restring:restring:4.0.6'
Ah, sorry. This does not work yet, I would need to generate a custom version of restring for this. AppLocale is a similar library, that can be used with restring. Correct would be like this:
abstract class BaseFragment : Fragment() {
override fun onResume() {
super.onResume()
ViewPump.setOverwriteContext(Restring.wrap(requireContext()))
}
override fun onGetLayoutInflater(savedInstanceState: Bundle?): LayoutInflater {
val wrappedContext = ViewPumpContextWrapper.wrap(Restring.wrap(requireContext()))
return wrappedContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
}
}
The crash is due to the same class existing twice, I will create a new version with this fixed later today.
I fixed the issue you can now update restring to 4.0.7: implementation 'dev.b3nedikt.restring:restring:4.0.7'
@B3nedikt Still same issue is coming with below dependency as well
implementation 'dev.b3nedikt.restring:restring:4.0.7'
// ViewPump
implementation "com.github.B3nedikt:ViewPump:add_update_context_method-SNAPSHOT"
// Reword
implementation "com.github.B3nedikt:reword:update_build-SNAPSHOT"
@naveen-chimaniya You mean the duplicate class exception or the web view crash?
Web view crashing
On Wed, 2 Sep 2020, 22:28 Benedikt Löbbecke, notifications@github.com wrote:
@naveen-chimaniya https://github.com/naveen-chimaniya You mean the duplicate class exception or the web view crash?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/B3nedikt/restring/issues/42#issuecomment-685867810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOOYLYGE6DXBJT5D4P62XPLSDZ2UFANCNFSM4QSTTD4A .
WebView long click crash is probably not due to Restring, but appcompat earlier alpha versions. Check if your appcompat is 1.1.0 (1.2.0 for me does not work properly with day/night modes when using Restring though, but has webview long click resolved).
I am using appCompatVersion = '1.3.0-alpha02' .I tried 1.2.0 as well but but webivew crashing issue not fixed (its coming while long press or open dialog in weview)
@naveen-chimaniya , @edgar-zigis This issue should be fixed in Restring 5.0.0 now. As this is a complete rework of the API, migration might be a bit more complex though ;)
In Restring 5.0.0 Webview long press has fixed but webview spinner still there, getting below error while click on webview spinner
--------- beginning of crash
2020-09-15 11:22:47.396 17186-17186/com.xxx.xx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 17186
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:276)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2382)
at android.content.res.Resources.getLayout(Resources.java:1276)
at dev.b3nedikt.restring.internal.RestringResources.getLayout(RestringResources.kt:160)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at dev.b3nedikt.viewpump.internal.-ViewPumpLayoutInflater.inflate(-ViewPumpLayoutInflater.kt:54)
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:428)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:419)
at KA.getView(PG:2)
at android.widget.AbsListView.obtainView(AbsListView.java:3271)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1464)
at android.widget.ListView.onMeasure(ListView.java:1370)
at android.view.View.measure(View.java:26414)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:26414)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:26414)
at com.android.internal.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:146)
at com.android.internal.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:71)
at android.view.View.measure(View.java:26414)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:26414)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:26414)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1016)
at android.view.View.measure(View.java:26414)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3609)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2325)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2644)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2204)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9069)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:999)
at android.view.Choreographer.doCallbacks(Choreographer.java:797)
at android.view.Choreographer.doFrame(Choreographer.java:732)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:984)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
@naveen-chimaniya Thanks for testing! Which device + android version did you get above crash on?
@B3nedikt it is the same issue I had before with WebView spinners. I did not manage to resolve it, I just push webviews to separate activity without Restring.
I am using samsung galaxy M31s, Android 10
On Tue, 15 Sep 2020, 13:01 Benedikt Löbbecke, notifications@github.com wrote:
@naveen-chimaniya https://github.com/naveen-chimaniya Thanks for testing! Which device + android version did you get above crash on?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/B3nedikt/restring/issues/42#issuecomment-692524925, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOOYLYA5ARG7RCOFKZQ74XLSF4J4BANCNFSM4QSTTD4A .
It does not matter which the device is, it is 100% reproducible anywhere.
@edgar-zigis , @naveen-chimaniya I am actually not sure if it is independent of the device, I think it is connected to some libraries not working together well.
I created this sample: https://github.com/B3nedikt/restring/tree/web_view_spinner_test
For me this works on a Xiaomi Mi Note 10, I can switch between "Volvo, Saab, Opel & Audi" just fine without a crash. This should in theory only work on a real device with restring 5 as in the sample, not with older versions. But I am still looking into it ;)
Will test it for you.
On my Samsung S8 when clicking on the webview spinner in your sample app:
2020-09-17 12:39:19.442 31968-31968/dev.b3nedikt.restring.example E/chromium: [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/dev.b3nedikt.restring.example/cache/WebView/Crashpad: No such file or directory (2)
2020-09-17 12:40:14.263 31968-31968/dev.b3nedikt.restring.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: dev.b3nedikt.restring.example, PID: 31968
android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class CheckedTextView
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class CheckedTextView
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:538)
at android.widget.TextView.<init>(TextView.java:1255)
at android.widget.CheckedTextView.<init>(CheckedTextView.java:92)
at android.widget.CheckedTextView.<init>(CheckedTextView.java:88)
@edgar-zigis Thanks, that is the same crash I get on my Nexus 5X running android 8.1.0. On the Xiaomi, everything works perfect though... Also I observed, that if I restart the activity, e.g. by turning the phone up side down to switch from portrait to landscape mode and back, everything works as expected without crashes!
I am still not sure why this crash happens, it seems to LayoutInflater uses a wrong context out of sync with the AssetManager on some devices? I think I am getting closer though xD
Yeah, it is related with Android version. It works fine on Android 9 & 10, but fails to work on Android 8.
@B3nedikt I have revert restring code and again integrate restring with app compact version 1.1.0 then Issue has been resolved :) Now webview long press and webview spinner both are working
Yeah, for us changing between night/day modes started crashing app when Restring updated its appcompat version to 1.2.0 in version 4.0.5. I would suggest downgrading it.. appcompat team is known to be lousy, leave bugs and fix them like in 6 months..
@edgar-zigis I think I have fixed with a new ViewPump version ;) If you pull the latest version of my web view demo it should now work on older android versions as well. At least it does so on my Nexus 5X with android 8.1. Can you confirm it with your device?
@B3nedikt night/day mode works! And also another issue was fixed when switching between RTL and non RTL locales activity relaunch was needed :) now recreate is enough :)
Will check webviews now.
Webview works too! Yay! :)
Good to hear it finally works :)
Cool :)
On Fri, 18 Sep 2020, 19:32 Benedikt Löbbecke, notifications@github.com wrote:
Good to hear it finally works :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/B3nedikt/restring/issues/42#issuecomment-694886574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOOYLYE7KHRAAMPAMLJZL2TSGNR6VANCNFSM4QSTTD4A .
Ha ha, Benedikt is on fire 👍 Thank you!
@Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(ViewPumpContextWrapper.wrap(Restring.wrapContext(newBase))); }
After Override above method my app is crashing while Long press or opening spinner in webview
Error log
2020-09-01 17:54:27.910 23346-23346/com.xx.mexxna E/AndroidRuntime: FATAL EXCEPTION: main Process: com.xx.xx, PID: 23346 android.content.res.Resources$NotFoundException: Resource ID #0x0 at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:276) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2382) at android.content.res.Resources.getLayout(Resources.java:1276) at android.view.LayoutInflater.inflate(LayoutInflater.java:532) at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.inflate(-ViewPumpLayoutInflater.kt:48) at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:428) at android.widget.ArrayAdapter.getView(ArrayAdapter.java:419) at KA.getView(PG:2) at android.widget.AbsListView.obtainView(AbsListView.java:3271) at android.widget.ListView.measureHeightOfChildren(ListView.java:1464) at android.widget.ListView.onMeasure(ListView.java:1370) at android.view.View.measure(View.java:26414) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26414) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26414) at com.android.internal.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:146) at com.android.internal.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:71) at android.view.View.measure(View.java:26414) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26414) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26414) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1016) at android.view.View.measure(View.java:26414) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3609) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2325) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2644) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2204) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9069) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:999) at android.view.Choreographer.doCallbacks(Choreographer.java:797) at android.view.Choreographer.doFrame(Choreographer.java:732) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:984) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8107) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)