Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with react-native-curved-bottom-bar After Updating to React Native 0.76.5 only on Android #82

Open
dheerajkumar003 opened this issue Dec 27, 2024 · 6 comments

Comments

@dheerajkumar003
Copy link

Recently updated to React Native version 0.76.5 and encountered an issue with react-native-curved-bottom-bar:
Attempt to invoke virtual method 'com.facebook.react.uimanager.events.EventDispatcher com.facebook.react.uimanager.UIManagerModule.getEventDispatcher()' on a null object reference.
I have also attached a screenshot.

Screenshot_20241227_174210

@dheerajkumar003
Copy link
Author

Also tried updating libraries like react-navigation/bottom-tabs, react-navigation/native, and react-native-svg , but I'm still facing the same issue.

@dheerajkumar003 dheerajkumar003 changed the title Issue with react-native-curved-bottom-bar After Updating to React Native 0.76.5 Issue with react-native-curved-bottom-bar After Updating to React Native 0.76.5 only on Android Jan 6, 2025
@rushant11
Copy link

Also tried updating libraries like react-navigation/bottom-tabs, react-navigation/native, and react-native-svg , but I'm still facing the same issue.

i have solution

@dheerajkumar003
Copy link
Author

Also tried updating libraries like react-navigation/bottom-tabs, react-navigation/native, and react-native-svg , but I'm still facing the same issue.

i have solution

Could you please help me with it

@rushant11
Copy link

@dheerajkumar003 @Lucasmellof @hoaphantn7604 everyone replace this file with this code and patch the changes and reinstall node module and build

FilePath: node_modules/curvded_bottom-tabbar/android/src/main/java/com/curvedbottombar/ShadowListener.java



package com.curvedbottombar;

import android.os.CountDownTimer;
import android.view.View;
import android.view.ViewGroup;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.EventDispatcherListener;
import com.facebook.react.views.image.ReactImageView;
import com.facebook.react.views.view.ReactViewGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ShadowListener implements EventDispatcherListener {

private Map<Integer, ShadowLayout> imageIds = new HashMap<>();
private List viewsToFadeIn = new ArrayList<>();
private ReactContext reactContext;
private EventDispatcher eventDispatcher;

private CountDownTimer fadeTimer;

public ShadowListener(ReactContext reactContext) {
this.reactContext = reactContext;

if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
  // Utiliser le nouvel UIManager pour Fabric
  eventDispatcher =
    UIManagerHelper
      .getUIManager(reactContext, UIManagerType.FABRIC)
      .getEventDispatcher();
} else {
  // Architecture ancienne
  eventDispatcher =
    reactContext
      .getNativeModule(com.facebook.react.uimanager.UIManagerModule.class)
      .getEventDispatcher();
}

if (eventDispatcher != null) {
  eventDispatcher.addListener(this);
}

}

public void onAddView(ShadowLayout parent, View child) {
if (child instanceof ReactImageView) {
((ReactImageView) child).setShouldNotifyLoadEvents(true);
this.imageIds.put(child.getId(), parent);
} else if (child instanceof ReactViewGroup) {
for (
int index = 0;
index < ((ViewGroup) child).getChildCount();
++index
) {
View nextChild = ((ViewGroup) child).getChildAt(index);
this.onAddView(parent, nextChild);
}
}
}

@OverRide
public void onEventDispatch(final Event event) {
if (UiThreadUtil.isOnUiThread()) {
handleEvent(event);
} else {
UiThreadUtil.runOnUiThread(() -> handleEvent(event));
}
}

private void handleEvent(Event event) {
if (
"topLoadEnd".equals(event.getEventName()) &&
this.imageIds.containsKey(event.getViewTag())
) {
ShadowLayout layout = this.imageIds.get(event.getViewTag());
this.viewsToFadeIn.add(layout);
if (this.fadeTimer != null) this.fadeTimer.cancel();
this.fadeTimer =
new CountDownTimer(500, 33) {
@OverRide
public void onTick(long millisUntilFinished) {
for (ShadowLayout view : viewsToFadeIn) view.invalidate();
}

      @Override
      public void onFinish() {
        for (ShadowLayout view : viewsToFadeIn) view.invalidate();
        viewsToFadeIn.clear();
      }
    }
      .start();
}

}

public void tearDown() {
if (eventDispatcher != null) {
eventDispatcher.removeListener(this);
}
}
}

@dheerajkumar003
Copy link
Author

@rushant11 bro I am getting below error when I tried running project after successful gradle clean

C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:61: error: cannot find symbol
@OverRide
^
symbol: class OverRide
location: class ShadowListener
C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:78: error: cannot find symbol
@OverRide
^
symbol: class OverRide
C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:80: error: incompatible types: Object cannot be converted to ShadowLayout
for (ShadowLayout view : viewsToFadeIn)
^
C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:86: error: incompatible types: Object cannot be converted to ShadowLayout
for (ShadowLayout view : viewsToFadeIn)
^
Note: C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-curved-bottom-bar:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --info option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 1m 3s

@dheerajkumar003
Copy link
Author

dheerajkumar003 commented Jan 9, 2025

@rushant11 bro I am getting below error when I tried running project after successful gradle clean

C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:61: error: cannot find symbol @OverRide ^ symbol: class OverRide location: class ShadowListener C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:78: error: cannot find symbol @OverRide ^ symbol: class OverRide C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:80: error: incompatible types: Object cannot be converted to ShadowLayout for (ShadowLayout view : viewsToFadeIn) ^ C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java:86: error: incompatible types: Object cannot be converted to ShadowLayout for (ShadowLayout view : viewsToFadeIn) ^ Note: C:\Users\Dheeraj\Admin\housivity-app\node_modules\react-native-curved-bottom-bar\android\src\main\java\com\curvedbottombar\ShadowListener.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-curved-bottom-bar:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --info option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 1m 3s

Ok so issue was Override should be used instead of OverRide
also used : private List viewsToFadeIn = new ArrayList<>();
instead of : private List viewsToFadeIn = new ArrayList<>();

in ShadowListener.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants