Skip to content

React Native Android Runtime issue #767

Closed

Description

@AlirezaHadjar

Bug report

Summary

Hi, I have recently updated the lib package from 6.7.5 to 7.1.0. and I ran into this error only on Android:

Screenshot_1686643712

I searched the issue and in all cases, the problem was caused by a duplicate of importing the packages in the MainApplication.java file. but There is no reference to this lib in my MainApplication.java. I have no issue in v6.7.5 and this only happens on >= v7.0.0 and on Android.

Reproducible sample code

This is my MainApplication.java file:

package com.omp.mobile.apps;
import android.content.res.Configuration;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;

import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import java.util.List;
import androidx.multidex.MultiDexApplication;

public class MainApplication extends MultiDexApplication implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
      new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return packages;
        }

        @Override
        protected String getJSMainModuleName() {
          return "index";
        }

        @Override
        protected boolean isNewArchEnabled() {
          return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
        }

        @Override
        protected Boolean isHermesEnabled() {
          return BuildConfig.IS_HERMES_ENABLED;
        }
      });

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
      // If you opted-in for the New Architecture, we load the native entry point for this app.
      DefaultNewArchitectureEntryPoint.load();
    }
    ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
    ApplicationLifecycleDispatcher.onApplicationCreate(this);
  }

  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
  }
}

Environment info

npx react-native info output:

System:
    OS: macOS 13.4
    CPU: (8) arm64 Apple M1 Pro
    Memory: 109.14 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.0 - /usr/local/bin/npm
    Watchman: 2023.04.10.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK:
      API Levels: 27, 29, 30, 31, 33, 33
      Build Tools: 30.0.3, 33.0.0, 33.0.2
      System Images: android-33 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9619390
    Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.18 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.10 => 0.71.10 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

datetimepicker version: 7.1.0

iOS / Android version: android Tiramisu

Activity

  1. vonovak commented on Jun 13, 2023

    @vonovak
    Member

    Hello and thanks for reporting,

    please provide a runnable repro that can be used to reproduce the problem - I'll need a full RN project in order to debug this.

    Thank you 🙂

  2. AlirezaHadjar commented on Jun 15, 2023

    @AlirezaHadjar
    Author

    @vonovak thanks for the feedback.
    I'm a little bit busy this week. I'll try to share a repro next week.

  3. hugoalvares commented on Jun 21, 2023

    @hugoalvares

    I had the same issue and the cause was a conflicting library that uses @react-native-community/datetimepicker under the hood (react-native-date-picker in my case). Removing it solved the issue.

  4. AlirezaHadjar commented on Jun 21, 2023

    @AlirezaHadjar
    Author

    Yeah, that might be the issue. I use react-native-wheel-pick which uses @react-native-community/datetimepicker under the hood. But I can't remove the library. Actually, I'm only using react-native-wheel-pick.

    @vonovak do you have any idea, how to fix this issue? I can't share a snack because the relying library doesn't support the expo. But I can share a minimal GitHub repo if you want. basically, you need to have both mentioned libraries installed.

  5. itsramiel commented on Jul 11, 2023

    @itsramiel
    Contributor

    Hey @vonovak 👋. I am facing the same issue on android when I upgraded to expo sdk 49 which bumped @react-native-community/datetimepicker from 6.7.3 to 7.2.0. I also have react-native-date-picker as a dependency. The issue is the following:

    react-native-date-picker is registering its android module under the name RNDatePicker, and this library used to register its android module under RNDatePickerAndroid which was fine. Then in this pull request, the android module name changed to RNDatePicker which conflicts with the other library. Do you still need a reproducible?

    I have the following proposal:

    Can we change the name of the module to RNCDatePicker since this is part of the react-native-community packages and others such as @react-native-community/slider register the module under RNCSlider and @react-native-community/progress-view register its module under RNCProgressView. This keeps the modules consistent and resolves the conflict with the other package.

    If this sounds like a good idea, let me know to submit a pr 🌱

  6. vonovak commented on Jul 11, 2023

    @vonovak
    Member

    @itsramiel thank you for providing a useful insight.
    Please, open the PR as you suggested. Thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions