Skip to content

[integration_test] readme about Android device testing out-of-date #62237

Closed

Description

@CareF

https://github.com/flutter/plugins/tree/master/packages/e2e#android-device-testing

Following this guide to a newly created (by flutter create) will result in fail:

+ ./gradlew app:assembleAndroidTest

> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
/Users/minglyu/tmp/ftl_dev/android/app/src/androidTest/java/com/example/ftl_dev/MainActivityTest.java:11: error: cannot find symbo
  public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, true, false);
                          ^
  symbol:   class MainActivity
  location: class MainActivityTest
/Users/minglyu/tmp/ftl_dev/android/app/src/androidTest/java/com/example/ftl_dev/MainActivityTest.java:11: error: cannot find symbol
  public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, true, false);
                                                                      ^
  symbol:   class MainActivity
  location: class MainActivityTest
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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.6.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s

It seems current flutter create is using kotlin but this guide is for java.

Activity

  1. added
    f: integration_testThe flutter/packages/integration_test plugin
    t: gradle"flutter build" and "flutter run" on Android
    on Jul 24, 2020
  2. CareF commented on Jul 24, 2020

    @CareF
    ContributorAuthor
  3. dnfield commented on Jul 24, 2020

    @dnfield
    Contributor

    We should have docs for both Kotlin and Java. It's still possible to flutter create a Java app with the right flags.

  4. CareF commented on Jul 25, 2020

    @CareF
    ContributorAuthor

    Is it possible to automatically add these files when flutter build/run/drive an e2e test?

  5. added
    P2Important issues not at the top of the work list
    on Sep 6, 2022
  6. 1 remaining item

  7. yshean commented on Feb 27, 2023

    @yshean

    What should be the code/setup for Kotlin?

  8. novas1r1 commented on Mar 15, 2023

    @novas1r1

    @yshean did you figure it out?

    I had the same problem and tried to fix it like this, but couldn't make it work.

    1. Changing the path with the MainActivityTest.java from:
      app/src/androidTest/java/com/example/myappto app/src/androidTest/kotlin/com/example/myapp

    2. Changing the MainActivityTest.java to MainActivityTest.kt

    3. Entering the following code in MainActivityTest.kt:

    package com.example.myapp
    
    import androidx.test.rule.ActivityTestRule
    import dev.flutter.plugins.integration_test.FlutterTestRunner
    import org.junit.Rule
    import org.junit.runner.RunWith
    
    @RunWith(FlutterTestRunner::class)
    class MainActivityTest {
        @get:Rule
        val rule = ActivityTestRule(MainActivity::class.java, true, false)
    }
    

    I have no idea about Kotlin, so maybe someone could verify if this is at least the right direction?

  9. adan-abdi commented on Jun 8, 2023

    @adan-abdi

    @novas1r1 @CareF Did you find any solutions for this? I am getting the same issue trying to do Android device testing and cant generate androidTestApk for FirebaseTestLab

  10. adan-abdi commented on Jun 8, 2023

    @adan-abdi

    @novas1r1 Did you ensure the line at the top of your MainActivityTest.java ==> package com.example.myapp is changed to your app package id?

  11. novas1r1 commented on Jun 8, 2023

    @novas1r1

    @Abdi-adan for me it worked the way I provided it in my answer above. Yes, you need to change the first line to your package name.

  12. nc-jeni commented on Jan 31, 2024

    @nc-jeni

    I have done the exact same, but it does not find my tests nor any errors.

    patrol test --flavor development

    No device specified, using the first one (emulator-5554)
    • Building apk with entrypoint test_bundle.dart...
    ✓ Completed building apk with entrypoint test_bundle.dart (11.7s)
    • Executing tests of apk with entrypoint test_bundle.dart on emulator-5554...
    ✓ Completed executing apk with entrypoint test_bundle.dart on emulator-5554 (7.2s)
    

    @novas1r1 (or anyone else) Do you know why?

    Please find more details here leancodepl/patrol#2082

  13. github-actions commented on Jul 14, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsd: examplesSample code and demosf: integration_testThe flutter/packages/integration_test pluginplatform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions