wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.02k stars 2.67k forks source link

Not working in RN v0.72.1 #7748

Closed lyswhut closed 1 year ago

lyswhut commented 1 year ago

What happened?

error Failed to install the app. Command failed with exit code 1: gradlew.bat tasks FAILURE: Build failed with an exception. * Where: Build file 'rnntest\node_modules\react-native-navigation\lib\android\app\build.gradle' line: 47 * What went wrong: Execution failed for task ':tasks'. > Could not create task ':react-native-navigation:testReactNative71DebugUnitTest'. > No signature of method: org.gradle.api.reporting.internal.TaskGeneratedSingleDirectoryReport.enabled() is applicable for argument types: (Boolean) values: [true] * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 
36s
> Task :gradle-plugin:pluginDescriptors > Task :gradle-plugin:processResources > Task :gradle-plugin:compileKotlin > Task :gradle-plugin:compileJava NO-SOURCE > Task :gradle-plugin:classes 
> Task :gradle-plugin:jar > Task :gradle-plugin:inspectClassesForKotlinIC > Task :tasks FAILED 6 actionable tasks: 6 executed.

What was the expected behaviour?

Working in RN 0.72.1

Was it tested on latest react-native-navigation?

Help us reproduce this issue!

  1. Create a latest (v0.72.1) blank RN project: npx react-native@latest init rntest
  2. install RNN yarn add react-native-navigation
  3. Run app npm run android

In what environment did this happen?

React Native Navigation version: 7.33.3-hotfix.3 React Native version: 0.72.1 Has Fabric (React Native's new rendering system) enabled: yes

harshal2030 commented 1 year ago

having the same issue

svbutko commented 1 year ago

Try this patch until 0.72 support lands, iOS should work without any patches

diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java
index 8ddc3d5..feebc7b 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java
@@ -3,16 +3,15 @@ package com.reactnativenavigation;
 import android.annotation.TargetApi;
 import android.content.Intent;
 import android.content.res.Configuration;
-import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.View;

+import com.facebook.react.ReactActivity;
 import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
 import com.facebook.react.modules.core.PermissionAwareActivity;
 import com.facebook.react.modules.core.PermissionListener;
-import com.reactnativenavigation.options.Options;
 import com.reactnativenavigation.viewcontrollers.overlay.OverlayManager;
 import com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter;
 import com.reactnativenavigation.react.JsDevReloadHandler;
@@ -25,9 +24,8 @@ import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
 import androidx.activity.OnBackPressedCallback;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;

-public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity, JsDevReloadHandler.ReloadListener {
+public class NavigationActivity extends ReactActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity, JsDevReloadHandler.ReloadListener {
     @Nullable
     private PermissionListener mPermissionListener;

@@ -104,7 +102,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
     }

     @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         getReactGateway().onActivityResult(this, requestCode, resultCode, data);
     }
@@ -126,10 +124,11 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
         return navigator;
     }

+    @Override
     @TargetApi(Build.VERSION_CODES.M)
     public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
         mPermissionListener = listener;
-        requestPermissions(permissions, requestCode);
+        super.requestPermissions(permissions, requestCode);
     }

     @Override
@@ -138,6 +137,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
         if (mPermissionListener != null && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
             mPermissionListener = null;
         }
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
     }

     @Override
diff --git a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/NavigationReactNativeHost.java b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/NavigationReactNativeHost.java
index ea48f57..9dc0b74 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/NavigationReactNativeHost.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/NavigationReactNativeHost.java
@@ -3,7 +3,7 @@ package com.reactnativenavigation.react;
 import com.facebook.infer.annotation.Assertions;
 import com.facebook.react.ReactInstanceManager;
 import com.facebook.react.ReactInstanceManagerBuilder;
-import com.facebook.react.ReactNativeHost;
+import com.facebook.react.defaults.DefaultReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.common.LifecycleState;
 import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
@@ -12,7 +12,7 @@ import com.reactnativenavigation.NavigationApplication;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;

-public abstract class NavigationReactNativeHost extends ReactNativeHost implements BundleDownloadListenerProvider {
+public abstract class NavigationReactNativeHost extends DefaultReactNativeHost implements BundleDownloadListenerProvider {

     private @Nullable NavigationDevBundleDownloadListener bundleListener;
     private final DevBundleDownloadListener bundleListenerMediator = new DevBundleDownloadListenerAdapter() {
bemaverick commented 1 year ago

the same issue with react-native 072.0 and react-native-navigation: 7.34.0

bemaverick commented 1 year ago

@svbutko Does your patch fix work with rn 0.72 and rnn 7.34.0? I tried and nothing - the same error.

svbutko commented 1 year ago

@svbutko Does your patch fix work with rn 0.72 and rnn 7.34.0? I tried and nothing - the same error.

Yes, for me it works without issues, Fabric should be disabled though, since RNN is not supporting it yet, check that you applied this patch

bemaverick commented 1 year ago

Unfortunately it doesn't work for me. Fabric is disabled, patch has been applied (files in node modules have been changed) Can you, please, share your package.json? @svbutko

svbutko commented 1 year ago

Unfortunately it doesn't work for me. Fabric is disabled, patch has been applied (files in node modules have been changed) Can you, please, share your package.json? @svbutko

You can check out the whole setup here, I use RN 0.72 since RC 1 together with RNN

https://github.com/svbutko/react-native-template-strong

ertugruldogan commented 1 year ago

not working It needs to be set according to ReactNative72. It has not yet been configured according to RN 0.72.

vb reactNative72 { dimension "RNN.reactNativeVersion" buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "72") }

node_modules\react-native-navigation\lib\android\app\build.gradle

Execution failed for task ':tasks'.

Could not create task ':react-native-navigation:testReactNative71DebugUnitTest'. No signature of method: org.gradle.api.reporting.internal.TaskGeneratedSingleDirectoryReport.enabled() is applicable for argument types: (Boolean) values: [true]

itsam commented 1 year ago

I confirm it doesn't work. Got the same error. Also tried a clean setup from @svbutko 's repository (https://github.com/svbutko/react-native-template-strong) which gives the same error (patch is applied) In iOS works fine though.

svbutko commented 1 year ago

I confirm it doesn't work. Got the same error. Also tried a clean setup from @svbutko 's repository (https://github.com/svbutko/react-native-template-strong) which gives the same error (patch is applied)

In iOS works fine though.

I have four apps running on it with RN 0.72.1 and RNN 0.34, on both Android and iOS, are you sure you did everything correctly?

itsam commented 1 year ago

I confirm it doesn't work. Got the same error. Also tried a clean setup from @svbutko 's repository (https://github.com/svbutko/react-native-template-strong) which gives the same error (patch is applied) In iOS works fine though.

I have four apps running on it with RN 0.72.1 and RNN 0.34, on both Android and iOS, are you sure you did everything correctly?

Hi @svbutko thanks for your prompt reply. Well, to be honest I just run the following

npx --force react-native init MyApp --template react-native-template-strong --npm

and then

npx react-native run-ios

which works perfectly fine

But npx react-native run-android gives the above error. I have alse run explicitly npx patch-package to be sure but still nothing...

FYI, I am using node v16.17.0 and Java openjdk 11.0.19 2023-04-18 LTS (maybe that's a problem???) and also I am running on Mac M1 (although other projects runs OK with the same versions on the same machine)

Is there any extra step I have to take? Thank you in advance

itsam commented 1 year ago

I have also tried on Linux, still got the same error

itsam commented 1 year ago

The patch seems to work now after I have updated Android Studio from Dolphin to Android Studio Flamingo | 2022.2.1 Patch 2 which caused also the installation of JDK 11 (Zulu11) and the update of AGP 7.3.1 (used by the old Android Studio) to AGP 7.4.2.

Note that it works from inside Android Studio (in Mac M1) but not from command line with npx react-native run-android but this might be just my settings...

Thanks to @svbutko for his help and of course his patch!

alexwasner commented 1 year ago

Also getting this via command line only

alexwasner commented 1 year ago

Here's a different patch you can apply. This is for a separate repo, so you'll need to apply it manually and then run patch package to save it https://github.com/wix/react-native-notifications/issues/975#issuecomment-1623856736

bemaverick commented 1 year ago

Can confirm that patch works. I am using rnn 7.34.0 with react native 0.72. Just updated adroid studio to flamingo as itsam mentioned

itsam commented 1 year ago

Here's a different patch you can apply. This is for a separate repo, so you'll need to apply it manually and then run patch package to save it wix/react-native-notifications#975 (comment)

@alexwasner thanks for this... does this actually solves running from terminal as well?

robrechtme commented 1 year ago

It's just #7738 or #7743 that needs to be merged and published, then we can use RN 0.72 without issues.

ertugruldogan commented 1 year ago

When will there be an update? RN 0.72.3 available. When will the library be updated? react-native-navigation

aamernabi commented 1 year ago

The quick workaround for now is to comment the following lines in /node_modules/react-native-navigation/lib/android/app/build.gradle

reports { html.enabled true }

testOptions {
        unitTests.includeAndroidResources = true
        unitTests.all { t ->
            maxHeapSize = "4g"
            // reports {
            //     html.enabled true
            // }
            testLogging {
            ....
jlipps commented 1 year ago

thanks @aamernabi. are you sure you didn't do anything else? merely commenting those three lines doesn't do the trick for me. I now get this error:

Could not create task ':react-native-navigation:compileReactNative71DebugAndroidTestKotlin'. Cannot use @TaskAction annotation on method AbstractKotlinCompile.execute() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

jlipps commented 1 year ago

Cannot use @TaskAction annotation on method AbstractKotlinCompile.execute() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

FYI the solution for this error was to upgrade Kotlin and the Kotlin gradle plugin (in my case, 1.9.0 worked)

yogevbd commented 1 year ago

Fixed in 7.35.2, sorry for the inconvenience.