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

Not working in RN v0.72.1 #7748

Closed
1 task done
lyswhut opened this issue Jul 2, 2023 · 23 comments · Fixed by #7758
Closed
1 task done

Not working in RN v0.72.1 #7748

lyswhut opened this issue Jul 2, 2023 · 23 comments · Fixed by #7758

Comments

@lyswhut
Copy link

lyswhut commented Jul 2, 2023

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?

  • I have tested this issue on the latest react-native-navigation release and it still reproduces.

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
Copy link

having the same issue

@svbutko
Copy link
Collaborator

svbutko commented Jul 5, 2023

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
Copy link

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

@bemaverick
Copy link

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

@svbutko
Copy link
Collaborator

svbutko commented Jul 6, 2023

@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
Copy link

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
Copy link
Collaborator

svbutko commented Jul 6, 2023

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
Copy link

ertugruldogan commented Jul 6, 2023

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
Copy link
Contributor

itsam commented Jul 7, 2023

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
Copy link
Collaborator

svbutko commented Jul 7, 2023

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
Copy link
Contributor

itsam commented Jul 7, 2023

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
Copy link
Contributor

itsam commented Jul 7, 2023

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

@itsam
Copy link
Contributor

itsam commented Jul 8, 2023

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
Copy link
Contributor

Also getting this via command line only

@alexwasner
Copy link
Contributor

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)

@bemaverick
Copy link

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
Copy link
Contributor

itsam commented Jul 10, 2023

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
Copy link

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

@ertugruldogan
Copy link

ertugruldogan commented Jul 12, 2023

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

@aamernabi
Copy link

aamernabi commented Jul 30, 2023

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
Copy link

jlipps commented Jul 31, 2023

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
Copy link

jlipps commented Aug 1, 2023

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
Copy link
Collaborator

yogevbd commented Aug 1, 2023

Fixed in 7.35.2, sorry for the inconvenience.

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

Successfully merging a pull request may close this issue.