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

Detox build for android fails when assembleAndroidTest is added in the build #3387

Closed
Anantha-sb opened this issue May 12, 2022 · 0 comments
Closed

Comments

@Anantha-sb
Copy link

Anantha-sb commented May 12, 2022

Description

I am trying to setup Detox / cucumber with my already built react-native app. I followed the steps in Detox for Android to setup.

My build passes when I run cd android && ./gradlew clean && ./gradlew assembleDebug but if I add assembleAndroidTest -DtestBuildType=debug && cd .. to my build, detox build fails. I found this out when I tried to run gradle commands separately.

My .detoxrc.js config file:

`// Device Configuration file - So Detox can understand what device & app to use
   module.exports = {
        "runner-config": "e2e/.mocharc.json",
        "specs": process.env.DETOX_EXPOSE_GLOBALS === '0' ? 'e2eExplicitRequire' : 'e2e',
        "behavior": {
          "init": {
            "exposeGlobals": process.env.DETOX_EXPOSE_GLOBALS === '0' ? false : true,
          },
        },
    "devices": {
      "android.attached": {
        "type": "android.attached",
        "device": {
          "adbName": "19287B294E"
        }
      }
    },
    
    "apps": {
      "android.debug": {
        "type": "android.apk",
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        // "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd .."
        "build": "cd android && ./gradlew clean && ./gradlew assembleDebug"
      },
    },
    "session": {
      //add session information here
      "server":  "ws://localhost:4723",
       "sessionId": "com.wix.demo.react.native"
    },
    "configurations": {
      "android.att.debug": {
        "device": "android.attached",
        "app": "android.debug"
      },
      "android.att.release": {
        "device": "android.attached",
        "app": "android.release"
      }
    }
}    

`

I have tried to run ./gradlew assembleAndroidTest on Android studio as well but it fails.

The error:

> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
/Users/asb/Downloads/DroidApp/android/app/src/androidTest/java/com/DroidApp/DetoxTest.java:20: error: cannot find symbol
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
                            ^
  symbol:   class MainActivity
  location: class DetoxTest
/Users/asb/Downloads/DroidApp/android/app/src/androidTest/java/com/DroidApp/DetoxTest.java:20: error: cannot find symbol
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
                                                                                 ^
  symbol:   class MainActivity
  location: class DetoxTest
/Users/asb/Downloads/DroidApp/android/app/src/androidTest/java/com/DroidApp/DetoxTest.java:32: error: cannot find symbol
        detoxConfig.rnContextLoadTimeoutSec = (com.nanosonics.audit_proBuildConfig.DEBUG ? 180 : 60);
                                                             ^
  symbol:   class audit_proBuildConfig
  location: package com.nanosonics
Note: /Users/asb/Downloads/DroidApp/android/app/src/androidTest/java/com/DroidApp/DetoxTest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 22s
299 actionable tasks: 27 executed, 272 up-to-date
16:37:20.196 detox[73423] WARN:  [build.js] 

Important: 'detox build' is a convenience shortcut for calling your own build command, as provided in the config file.
Failures in this build command are not the responsibility of Detox. You are responsible for maintaining this command.

16:37:20.206 detox[73423] ERROR: [cli.js] Command failed: cd android && ./gradlew clean && ./gradlew assembleDebug && ./gradlew assembleAndroidTest -DtestBuildType=debug && cd ..

error Command failed with exit code 1.

I'm using Mac OS 12.3, have the latest android studio, used the latest Kotlin version.

In my package.json, I have the following scripts:

"detox:e2e:ios-debug": "DETOX_CONFIGURATION=ios.sim.debug npx cucumber-js", "detox:build:android-debug": "detox build --configuration android.att.debug", "detox:e2e:android-debug": "DETOX_CONFIGURATION=android.att.debug npx cucumber-js"

Your environment

Detox version: 19.6.9
React Native version: 0.64.2 / react-native-cli: 2.0.1
Node version: v18.0.0
Device model: MacBook Pro
OS: 12.3
Test-runner (select one): cucumber

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

No branches or pull requests

1 participant