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 can't seem to connect to the test app on android. #3957

Open
2 tasks done
Tuliiiii opened this issue Feb 28, 2023 · 13 comments
Open
2 tasks done

Detox can't seem to connect to the test app on android. #3957

Tuliiiii opened this issue Feb 28, 2023 · 13 comments

Comments

@Tuliiiii
Copy link

Tuliiiii commented Feb 28, 2023

What happened?

i configured same as detox document for android, it run on ios perfectly but not on android. In android, detox is not able to connect.

DetoxTest.java ---->

             package <packagename>;                  
              import com.wix.detox.Detox;
              import com.wix.detox.config.DetoxConfig;
              
              import org.junit.Rule;
              import org.junit.Test;
              import org.junit.runner.RunWith;
              
              import androidx.test.ext.junit.runners.AndroidJUnit4;
              import androidx.test.filters.LargeTest;
              import androidx.test.rule.ActivityTestRule;
              
              @RunWith(AndroidJUnit4.class)
              @LargeTest
              public class DetoxTest {
                  @Rule
                  public ActivityTestRule<MainApplication> mActivityRule = new ActivityTestRule<>(MainApplication.class, false, false);
              
                  @Test
                  public void runDetoxTests() {
                      DetoxConfig detoxConfig = new DetoxConfig();
                      detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
                      detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
                      detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60);
              
                      Detox.runTests(mActivityRule, detoxConfig);
                  }
              }

starter.test.js ------>

                    describe('Login flow', () => {
                      beforeAll(async () => {
                        await device.launchApp();
                      });
                    
                      it('should login successfully', async () => {
                        await expect(element(by.id('login'))).toBeVisible();
                        await expect(element(by.id('username'))).toBeVisible();
                        await element(by.id('username')).typeText('tester');
                        await expect(element(by.id('password'))).toBeVisible();
                        await element(by.id('password')).typeText('password');
                        await element(by.id('signIn')).tap();
                      });
                    });
                    
                    describe('Home flow', () => {
                      it('home screen', async () => {
                        await expect(element(by.id('welcome'))).toBeVisible();
                        await element(by.id('viewHistory')).tap();
                        await element(by.id('historyBackArrow')).tap();
                        await element(by.id('settingsBottomIcon')).tap();
                      });
                    });
                    
                    describe('Settings flow', () => {
                      it('settings screen', async () => {
                        await element(by.id('signOut')).tap();
                      });
                    });

What was the expected behaviour?

The test should have run on android.

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

I followed the detox document for the setup and for writing tests, nothing extraordinary.

In what environment did this happen?

Detox version: 20.1.5
React Native version: 0.70.6
Has Fabric (React Native's new rendering system) enabled: (yes/no) no
Node version: 16.18.1
Device model:
Android version: 11.0.11
Test-runner : jest

Detox logs

Detox logs
paste logs here!

Device logs

Device logs
paste your device.log here!

More data, please!

No response

@Rzr7
Copy link

Rzr7 commented Mar 3, 2023

This has happened to me as well after updating from 20.0.3 to >20.1.2.
Looks like this lines are causing problems with connecting to Android emu accordingly to this answer

Related: #3944

More Detox logs
--------- beginning of main
03-03 13:03:47.159  4712  4712 I iderapp.preliv: The ClassLoaderContext is a special shared library.
03-03 13:03:47.160  4712  4712 I iderapp.preliv: The ClassLoaderContext is a special shared library.
03-03 13:03:47.212  4712  4712 W iderapp.preliv: ClassLoaderContext classpath size mismatch. expected=0, found=3 (PCL[] | PCL[/system/framework/android.test.runner.jar*3312018701:/system/framework/android.test.mock.jar*3601177991:/data/app/com.npopov.app.test-IWTnigwJSpZ-fifWHi5NLQ==/base.apk*2961417685])
03-03 13:03:47.213  4712  4712 W iderapp.preliv: Found duplicate classes, falling back to extracting from APK : /data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk
03-03 13:03:47.213  4712  4712 W iderapp.preliv: NOTE: This wastes RAM and hurts startup performance.
03-03 13:03:47.213  4712  4712 W iderapp.preliv: Found duplicated class when checking oat files: 'Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream;' in /data/app/com.npopov.app-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk!classes2.dex and /data/app/com.npopov.app.test-IWTnigwJSpZ-fifWHi5NLQ==/base.apk
03-03 13:03:47.213  4712  4712 W iderapp.preliv: 
03-03 13:03:47.425  4712  4712 I iderapp.preliv: The ClassLoaderContext is a special shared library.
03-03 13:03:47.425  4712  4712 I iderapp.preliv: The ClassLoaderContext is a special shared library.
03-03 13:03:47.479  4712  4712 W iderapp.preliv: ClassLoaderContext classpath size mismatch. expected=0, found=3 (PCL[] | PCL[/system/framework/android.test.runner.jar*3312018701:/system/framework/android.test.mock.jar*3601177991:/data/app/com.npopov.app.test-IWTnigwJSpZ-fifWHi5NLQ==/base.apk*2961417685];PCL[/system/framework/android.test.runner.jar*3312018701:/system/framework/android.test.mock.jar*3601177991:/data/app/com.npopov.app.test-IWTnigwJSpZ-fifWHi5NLQ==/base.apk*2961417685:/data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk*1145765854:/data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk!classes2.dex*3022457123:/data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk!classes3.dex*1180953520])
03-03 13:03:47.479  4712  4712 W iderapp.preliv: Found duplicate classes, falling back to extracting from APK : /data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk
03-03 13:03:47.479  4712  4712 W iderapp.preliv: NOTE: This wastes RAM and hurts startup performance.
03-03 13:03:47.479  4712  4712 W iderapp.preliv: Found duplicated class when checking oat files: 'L$r8$backportedMethods$utility$Boolean$1$hashCode;' in /data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk and /data/app/com.npopov.app.test-PMOo-fG8eBaw2W2pkK5RSQ==/base.apk
03-03 13:03:47.479  4712  4712 W iderapp.preliv: 
03-03 13:03:47.689  4712  4712 I MultiDex: VM with version 2.1.0 has multidex support
03-03 13:03:47.689  4712  4712 I MultiDex: Installing application
03-03 13:03:47.689  4712  4712 I MultiDex: VM has multidex support, MultiDex support library is disabled.
03-03 13:03:47.696  4712  4712 D AndroidRuntime: Shutting down VM
--------- beginning of crash
03-03 13:03:47.696  4712  4712 E AndroidRuntime: FATAL EXCEPTION: main
03-03 13:03:47.696  4712  4712 E AndroidRuntime: Process: com.npopov.app.test, PID: 4712
03-03 13:03:47.696  4712  4712 E AndroidRuntime: java.lang.NoSuchMethodError: No static method registerDefaultInstance(Ljava/lang/Class;Lcom/google/protobuf/GeneratedMessageLite;)V in class Lcom/google/protobuf/GeneratedMessageLite; or its super classes (declaration of 'com.google.protobuf.GeneratedMessageLite' appears in /data/app/com.npopov.app.test-IWTnigwJSpZ-fifWHi5NLQ==/base.apk)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.google.firebase.perf.v1.TraceMetric.<clinit>(TraceMetric.java:1945)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.google.firebase.perf.v1.TraceMetric.newBuilder(TraceMetric.java:941)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.google.firebase.perf.metrics.AppStartTrace.<init>(AppStartTrace.java:169)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.google.firebase.perf.metrics.AppStartTrace.getInstance(AppStartTrace.java:147)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.google.firebase.perf.metrics.AppStartTrace.getInstance(AppStartTrace.java:136)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.google.firebase.perf.provider.FirebasePerfProvider.attachInfo(FirebasePerfProvider.java:69)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.app.ActivityThread.access$1300(ActivityThread.java:219)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:107)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:214)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7356)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
03-03 13:03:47.696  4712  4712 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
03-03 13:03:47.697  4712  4712 I Process : Sending signal. PID: 4712 SIG: 9

@grgmo
Copy link

grgmo commented Mar 3, 2023

had the same issue with firebase and detox clashing on dependency. This worked for us

androidTestImplementation('com.wix:detox:+') {
    exclude module: "protobuf-lite"
}

similar to android/android-test#999

@anabeatrizzz
Copy link

@grgmo in which file I need to add those lines, please?

@owens-ben
Copy link

@grgmo in which file I need to add those lines, please?

It should be in android/app/build.gradle

@stale
Copy link

stale bot commented Apr 11, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

@stale stale bot added the 🏚 stale label Apr 11, 2023
@owens-ben
Copy link

owens-ben commented Apr 11, 2023 via email

@stale
Copy link

stale bot commented May 2, 2023

The issue has been closed for inactivity.

@stale stale bot closed this as completed May 2, 2023
@EJohnF
Copy link

EJohnF commented Jun 4, 2023

still happens on Detox 20.9

@pagman77
Copy link

had the same issue with firebase and detox clashing on dependency. This worked for us

androidTestImplementation('com.wix:detox:+') {
    exclude module: "protobuf-lite"
}

similar to android/android-test#999

This was a LIFESAVER, thanks!

@MayoudP
Copy link

MayoudP commented Aug 24, 2023

still happens on Detox 20.9

By any chances, did you managed to fix it ? Got the same issue. With this kind of specific logs :

artifacts-manager onLaunchApp
19:58:03.366 detox[41625] i child-process:SPAWN_STDOUT INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0

device An error occurred while waiting for the app to become ready. Waiting for disconnection...
  error: Failed to run application on the device
  
  HINT: Most likely, your tests have timed out and called detox.cleanup() while it was waiting for "ready" message (over WebSocket) from the instrumentation process.

@MayoudP
Copy link

MayoudP commented Aug 24, 2023

had the same issue with firebase and detox clashing on dependency. This worked for us

androidTestImplementation('com.wix:detox:+') {
    exclude module: "protobuf-lite"
}

similar to android/android-test#999

This plus adding
implementation 'com.facebook.soloader:soloader:0.10.4+' fixed it for me finaaaally : #3487

@1awaleed
Copy link

still occurring in 20.13.1

@cleberada
Copy link

This fixed my issue: gradle 7.2.2
https://stackoverflow.com/questions/72564710/react-native-crash-release-build-fatal-exception-create-react-context

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