question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot start android app because one of the tests fail

See original GitHub issue

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

  1. react-native run-android --deviceId=
  2. 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)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
mikailbayramcommented, Dec 3, 2019

@jaktonn Yes! I tested without the deviceId and it is working now.

3reactions
jaktonncommented, Dec 3, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run Android instrumented tests fail - Stack Overflow
It basically amounts to unchecking the box next to Run Android instrumented tests using Gradle in the testing settings. This worked for me....
Read more >
Android Emulator app test failing with the error ... - Sauce Labs
When tests fail with this error, the response to the POST session ... Original error: Cannot start the 'com.swaglabsmobileapp' application.
Read more >
Troubleshoot known issues with Android Emulator
On ChromeOS, Android Virtual Devices (AVDs) might fail to launch because the libnss3 dependency is missing. To launch the AVDs successfully, run ...
Read more >
Fix an installed Android app that isn't working - Google Support
Step 1: Restart & update · Step 2: Check for a larger app issue.
Read more >
Get started testing for Android with Firebase Test Lab - Google
When you run a test or a set of test cases against devices and configurations you've selected, Test Lab runs the test against...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found