B3nedikt / restring

Restring is a android library to replace string resources dynamically
Apache License 2.0
319 stars 31 forks source link

version 5.0.1 getting multiple crashes in crashlytics log #72

Closed naveen-chimaniya closed 4 years ago

naveen-chimaniya commented 4 years ago

1 ) Fatal Exception: java.lang.NullPointerException Parameter specified as non-null is null: method g.x.d.k.c, parameter defType dev.b3nedikt.restring.internal.RestringResources.getIdentifier (RestringResources.java:7) com.android.internal.widget.FloatingToolbar.getThemeId (FloatingToolbar.java:1998) com.android.internal.widget.FloatingToolbar.applyDefaultTheme (FloatingToolbar.java:1973) com.android.internal.widget.FloatingToolbar. (FloatingToolbar.java:194) com.android.internal.policy.HwPhoneWindow.getFloatingToolbar (HwPhoneWindow.java:286) com.android.internal.policy.DecorView.createFloatingActionMode (DecorView.java:2234) com.android.internal.policy.DecorView.createActionMode (DecorView.java:2078) com.android.internal.policy.DecorView.startActionMode (DecorView.java:1111) com.android.internal.policy.DecorView.startActionModeForChild (DecorView.java:1068) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:1054) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:1054) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:1054) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:1054) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:1054) android.view.View.startActionMode (View.java:7421) XT.a (XT.java:1) org.chromium.content.browser.selection.SelectionPopupControllerImpl.K (SelectionPopupControllerImpl.java:10) jY.a (jY.java:10) qY.i (qY.java:4) nJ.run (nJ.java:3)

2) Fatal Exception: java.lang.NullPointerException Parameter specified as non-null is null: method g.x.d.k.c, parameter defType dev.b3nedikt.restring.internal.RestringResources.getIdentifier (RestringResources.java:35) com.android.internal.widget.FloatingToolbar.getThemeId (FloatingToolbar.java:1856) com.android.internal.widget.FloatingToolbar.applyDefaultTheme (FloatingToolbar.java:1837) com.android.internal.widget.FloatingToolbar. (FloatingToolbar.java:157) com.android.internal.policy.HwPhoneWindow.getFloatingToolbar (HwPhoneWindow.java:251) com.android.internal.policy.DecorView.setHandledFloatingActionMode (DecorView.java:1809) com.android.internal.policy.DecorView.setHandledActionMode (DecorView.java:1645) com.android.internal.policy.DecorView.startActionMode (DecorView.java:909) com.android.internal.policy.DecorView.startActionModeForChild (DecorView.java:864) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.ViewGroup.startActionModeForChild (ViewGroup.java:827) android.view.View.startActionMode (View.java:5841) android.widget.Editor.startSelectionActionModeInternal (Editor.java:2054) android.widget.Editor.startSelectionActionMode (Editor.java:1990) android.widget.Editor$SelectionModifierCursorController.onTouchEvent (Editor.java:5470) android.widget.Editor.onTouchEvent (Editor.java:1394) android.widget.TextView.onTouchEvent (TextView.java:8792) android.view.View.dispatchTouchEvent (View.java:10013) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2671) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2358) com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:447) com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1871) android.app.Activity.dispatchTouchEvent (Activity.java:3213) com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:409) android.view.View.dispatchPointerEvent (View.java:10233) android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4865) android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4726) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4258) android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4311) android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4277) android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4404) android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4285) android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4461) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4258) android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4311) android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4277) android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4285) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4258) android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:6690) android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:6664) android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6625) android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6819) android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:192) android.os.MessageQueue.nativePollOnce (MessageQueue.java) android.os.MessageQueue.next (MessageQueue.java:356) android.os.Looper.loop (Looper.java:138) android.app.ActivityThread.main (ActivityThread.java:6617) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:942) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832)

B3nedikt commented 4 years ago

@naveen-chimaniya This has been fixed in Restring 5.1.0, you can just count up the version number, no migration needed :)

naveen-chimaniya commented 4 years ago

implementation 'dev.b3nedikt.restring:restring:5.1.0' implementation 'dev.b3nedikt.viewpump:viewpump:3.0.0' implementation 'dev.b3nedikt.reword:reword:2.0.0'

@B3nedikt for this do i need to upgrade viewpump:viewpump and reword:reword as well ?

B3nedikt commented 4 years ago

No, you can update restring completely independently of any other lib :)

But the new versions of ViewPump and restring contain some fixes & new features. Just look at the changelogs of the libraries to see if these would be useful for you. Btw. these libraries use strict "semantic-versioning", which basically tells you if you need to update stuff based on the version number.

naveen-chimaniya commented 4 years ago

viewpump:viewpump:3.0.0' this version getting issue with restring 5.1.0' , while changing activity text are revert to english

previously i was using in my base activity

@Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(ViewPumpContextWrapper.wrap(Restring.wrapContext(newBase))); }

@Override public Resources getResources() { return Restring.wrapContext(getBaseContext()).getResources(); }

How to migrate this code in java private val appCompatDelegate: AppCompatDelegate by lazy { ViewPumpAppCompatDelegate( baseDelegate = super.getDelegate(), baseContext = this, wrapContext = { baseContext -> Restring.wrapContext(baseContext) } ) }

override fun getDelegate(): AppCompatDelegate {
    return appCompatDelegate
}
B3nedikt commented 4 years ago

It would look in java like this:

    private AppCompatDelegate appCompatDelegate = null;

    @NonNull
    @Override
    public AppCompatDelegate getDelegate() {
        if (appCompatDelegate == null) {
            appCompatDelegate = new ViewPumpAppCompatDelegate(
                    super.getDelegate(),
                    this,
                    Restring::wrapContext
            );
        }
        return appCompatDelegate;
    }

Just look at the java-sample of this repository, on how to integrate restring in your app. The sample always uses the latest versions of my libs.