Cannot start android app because one of the tests fail
Your Environment
- Plugin version: 0.6.3
- Platform: Android
- OS version: 9
- Device manufacturer and model: Pocophone (Tested on other devices, getting same error)
- Running in Simulator: no
- React Native version: 0.61
- Plugin configuration options:
- Link to your project:
Context
When I run:
react-native run-android --deviceId=<<my device id>>
Console throws the following error and app stops building
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTaskShouldRejectAfterShutdown FAILED
java.lang.AssertionError
46 tests completed, 1 failed
> Task :@mauron85_react-native-background-geolocation-common:testDebugUnitTest FAILED
FAILURE: Build failed with an exception.
Expected Behavior
The app should build without a problem
Actual Behavior
Console throws an error and app stops building
Possible Fix
I could track down the issue to the following test:
@Test
public void persistTaskShouldRejectAfterShutdown() {
exception.expect(RejectedExecutionException.class);
LocationDAO mockDAO = mock(LocationDAO.class);
PostLocationTaskListener mockListener = mock(PostLocationTaskListener.class);
PostLocationTask task = new PostLocationTask(mockDAO,mockListener, connectivityListener);
Config config = Config.getDefault();
config.setUrl(TEST_PROTOCOL + "://localhost:3000/locations");
config.setSyncUrl(TEST_PROTOCOL + "://localhost:3000/sync");
task.setConfig(config);
for (int i = 0; i < 10; i++) {
task.add(new BackgroundLocation());
}
task.shutdown();
task.add(new BackgroundLocation());
}
PostLocationsTask.add does not throw the expected error
Steps to Reproduce
- react-native run-android --deviceId=
- Build fails
Context
I cannot continue my app development without commenting persistTaskShouldRejectAfterShutdown test
Debug logs
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 4265 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Building the app...
> Task :@mauron85_react-native-background-geolocation-common:testDebugUnitTest
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTaskShouldRejectAfterShutdown FAILED
java.lang.AssertionError
46 tests completed, 1 failed
> Task :@mauron85_react-native-background-geolocation-common:testDebugUnitTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':@mauron85_react-native-background-geolocation-common:testDebugUnitTest'.
> There were failing tests. See the report at: file:///home/mikail/code/undp/app/node_modules/@mauron85/react-native-background-geolocation/android/common/build/reports/tests/testDebugUnitTest/index.html
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 19s
101 actionable tasks: 2 executed, 99 up-to-date
error Failed to build the app. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew build -x lint
at makeError (/home/mikail/code/undp/app/node_modules/execa/index.js:174:9)
at Function.module.exports.sync (/home/mikail/code/undp/app/node_modules/execa/index.js:338:15)
at buildApk (/home/mikail/code/undp/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:190:22)
at runOnSpecificDevice (/home/mikail/code/undp/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:171:7)
at buildAndRun (/home/mikail/code/undp/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:156:12)
at then.result (/home/mikail/code/undp/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
I'm also getting test failures when specifing a device id on the react-native run-android command (react-native run-android --deviceId=...), even more than described above. Relevant output is
> Task :@mauron85_react-native-background-geolocation-common:testDebugUnitTest FAILED
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONShouldPostHeaders FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONObjectNull FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testJSONPostFileProgressListener FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONThrowsUnknownHostException FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONThrowsMalformedURLException FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONArray FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostStream FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostString FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONArrayNull FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONObject FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testPostJSONResult FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.HttpPostServiceTest > testJSONPostFile FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTask FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTaskShouldRejectAfterShutdown FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTaskOnShutdown FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTaskSetUnsyncedOnShutdown FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchFieldException
com.marianhello.backgroundgeolocation.BackgroundLocationTest > olderLocationShouldBeWorse FAILED
junit.framework.AssertionFailedError at BackgroundLocationTest.java:105
com.marianhello.backgroundgeolocation.BackgroundLocationTest > newerLocationShouldBeBetter FAILED
junit.framework.AssertionFailedError at BackgroundLocationTest.java:126
46 tests completed, 18 failed
FAILURE: Build failed with an exception.
Without specifying a device id (just running react-native run-android), the build is executed successfully though, both with an android simulator as well as a physical device connected. So my assumption is it has something to do with the deviceId parameter. I tried running the command with and without deviceId parameter set with the same phone connected, and it only worked without specifying the device id.
@jaktonn Yes! I tested without the deviceId and it is working now.
I am facing test failure when I try to build project
./gradlew build
Task :@mauron85_react-native-background-geolocation-common:testDebugUnitTest
com.marianhello.backgroundgeolocation.PostLocationTaskTest > persistTaskShouldRejectAfterShutdown FAILED java.lang.AssertionError
46 tests completed, 1 failed
@jaktonn I'm facing the same issue. I can not test my app on multiple emulators :(
Work around
https://github.com/react-native-image-picker/react-native-image-picker/issues/1142#issuecomment-718659512
project(':@mauron85_react-native-background-geolocation-common').tasks.withType(Test) {
enabled = false
}