Android builds fine in local environment but fails on EAS build

repo to reproduce the environment

references

  • the react native library from where the builds start failing ‘react-native-esptouch2’

Hi @abhi6676

I don’t understand. Could you elaborate on what you’re trying to do and maybe post the errors from the build logs?

The linked repository does not have react-native-esptouch2 in the dependencies in package.json.

Actually, I see there’s a branch called develop which does have it in the dependencies. It would have saved me some time and confusion if you had mentioned the branch name :slight_smile:

I see you have both yarn.lock and package-lock.json. You should not mix yarn and npm for managing your dependencies. Pick one and delete the other one’s lock file.

react-native link is deprecated. I see you disabled the hook here

react-native-esptouch2 has not been updated since React Native 0.60, so the installation docs don’t mention autolinking, which is how things should be done these days.

I tried creating a new app and installing react-native-esptouch2 and got the following build error:

> Task :react-native-esptouch2:compileDebugJavaWithJavac FAILED
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:16: error: package android.support.annotation does not exist
[stderr] import android.support.annotation.NonNull;
[stderr]                                  ^
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:17: error: cannot find symbol
[stderr] import android.support.v4.app.ActivityCompat;
[stderr]                              ^
[stderr]   symbol:   class ActivityCompat
[stderr]   location: package android.support.v4.app
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:18: error: package android.support.v4.content does not exist
[stderr] import android.support.v4.content.ContextCompat;
[stderr]                                  ^
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:51: error: package ActivityCompat does not exist
[stderr] public class RNEsptouchModule extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityCompat.OnRequestPermissionsResultCallback {
[stderr]                                                                                                                   ^
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:158: error: cannot find symbol
[stderr]     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
[stderr]                                                              ^
[stderr]   symbol:   class NonNull
[stderr]   location: class com.rickl.rn.esptouch.RNEsptouchModule
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:158: error: cannot find symbol
[stderr]     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
[stderr]                                                                                             ^
[stderr]   symbol:   class NonNull
[stderr]   location: class com.rickl.rn.esptouch.RNEsptouchModule
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:137: error: cannot find symbol
[stderr]             if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.ACCESS_COARSE_LOCATION)
[stderr]                 ^
[stderr]   symbol:   variable ContextCompat
[stderr]   location: class com.rickl.rn.esptouch.RNEsptouchModule
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:140: error: cannot find symbol
[stderr]                 if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
[stderr]                     ^
[stderr]   symbol:   variable ActivityCompat
[stderr]   location: class com.rickl.rn.esptouch.RNEsptouchModule
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:146: error: cannot find symbol
[stderr]                 ActivityCompat.requestPermissions(thisActivity, permissions, REQUEST_PERMISSION);
[stderr]                 ^
[stderr]   symbol:   variable ActivityCompat
[stderr]   location: class com.rickl.rn.esptouch.RNEsptouchModule
[stderr] /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java:157: error: method does not override or implement a method from a supertype
[stderr]     @Override
[stderr]     ^
[stderr] Note: /build/workingdir/build/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java uses or overrides a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
[stderr] 10 errors
> Task :expo-dev-menu:compileDebugKotlin
w: /build/workingdir/build/node_modules/expo-dev-menu/android/src/debug/java/expo/modules/devmenu/DevMenuManager.kt: (425, 43): The corresponding parameter in the supertype 'DevMenuManagerInterface' is named 'shouldAutoLaunch'. This may cause problems when calling this function with named arguments.
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':react-native-esptouch2:compileDebugJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[stderr] 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.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 2m 37s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
301 actionable tasks: 301 executed
Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

This apparently means that react-native-esptouch2 needs to be “jetified”, which can be done with patch-package and the following patch:

$ cat patches/react-native-esptouch2+1.1.3.patch 
diff --git a/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java b/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java
index 1cd0898..46e5782 100644
--- a/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java
+++ b/node_modules/react-native-esptouch2/android/src/main/java/com/rickl/rn/esptouch/RNEsptouchModule.java
@@ -13,9 +13,9 @@ import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.AsyncTask;
 import android.os.Build;
-import android.support.annotation.NonNull;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
 import android.util.Log;
 import android.widget.Toast;
 

After that it built without complaint.

Here’s an example:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.