Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detox + android Compiling DetoxTest.java fails

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

like image 790
Henry Avatar asked Dec 24 '22 06:12

Henry


2 Answers

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.

like image 173
Olivier Avatar answered Dec 25 '22 22:12

Olivier


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

like image 32
Karlis Filipsons Avatar answered Dec 25 '22 23:12

Karlis Filipsons