5

I'm trying to run

detox build -c android.emu.release

but it fails when it tries to compile DetoxTest.java with the following errors

  ~/android/app/src/androidTest/java/<package_name>/DetoxTest.java:24: error: cannot find symbol
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
                            ^
      symbol:   class MainActivity
      location: class DetoxTest

  ~/android/app/src/androidTest/java/<package_name>/DetoxTest.java:24: error: cannot find symbol
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
                                                                                 ^
  symbol:   class MainActivity
  location: class DetoxTest

I tried importing MainActivity from the package but I get the package cannot be found.

RN 0.51.1 Detox: 7.4.3

Henry
  • 351
  • 3
  • 12
  • Have you ever managed to fix this? I have the same problem with detox 8.1.5 and react native 0.56 – terreb Aug 14 '18 at 08:11
  • 1
    Never mind, this is just me, I forgot to change package com.example at the top to my package name. – terreb Aug 14 '18 at 08:17

3 Answers3

10

To solve this issue, follow closely the README for wix/detox/AndroidSupportStatus

For example if your project name is myandroidproject (see property rootProject.name of settings.gradle below), DetoxTest.java will be at the following location inside the package com.myandroidproject.

android/app/src/androidTest/java/com/myandroidproject/DetoxTest.java

package com.myandroidproject

...

settings.gradle

rootProject.name = 'myandroidproject'

...

In your case above, you have to replace package_name appropriately.

Olivier
  • 769
  • 7
  • 10
  • This help me thank you. once i got stuck building the release version of my apk then I try using debug mode to run my E2E. first time build the debug mode failed. Once follow this it works I miss the package name inside the detox. Thank u mate – Faris Rayhan Jun 03 '20 at 04:47
2

Another issue can be if the rootProject.name has capital letters, like rootProject.name = 'SomeName'. Then it should be package com.somename

Karlis Filipsons
  • 135
  • 1
  • 12
0

Along with making sure my project name was correct in my import statements, I also had to change my directories to match my package name. Somehow I was able to build the project with a folder name different than my project name in the past but detox wasn't okay with this.

Import statement:

package com.my_package_name

Corresponding folder structures:

android/app/src/main/java/com/my_package_name
android/app/src/androidTest/java/com/my_package_name
Omegalen
  • 1,456
  • 1
  • 13
  • 18