Detox
Detox copied to clipboard
Detox can't seem to connect to the test app on android.
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?
- [X] I have tested this issue on the latest Detox release and it still reproduces.
Did your test throw out a timeout?
- [x] I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
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
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
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 https://github.com/android/android-test/issues/999
@grgmo in which file I need to add those lines, please?
@grgmo in which file I need to add those lines, please?
It should be in android/app/build.gradle
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.
Still occurs in Detox 20.6
On Tue, Apr 11, 2023 at 6:57 AM stale[bot] @.***> wrote:
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 https://github.com/wix/Detox/issues/1305.
— Reply to this email directly, view it on GitHub https://github.com/wix/Detox/issues/3957#issuecomment-1503109964, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUX6WV2EIJLARVNBP5LUQO3XAU2KPANCNFSM6AAAAAAVKLML7E . You are receiving this because you commented.Message ID: @.***>
The issue has been closed for inactivity.
still happens on Detox 20.9
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!
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.
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 : https://github.com/wix/Detox/issues/3487
still occurring in 20.13.1
This fixed my issue: gradle 7.2.2 https://stackoverflow.com/questions/72564710/react-native-crash-release-build-fatal-exception-create-react-context