skip to Main Content

I’m trying to run an end to end test on my device thus I have to ask permission to access position through adb
When I run the command from a terminal it’s working as expected but when dart:io is executing it throw this exception (and it’s the same for every adb commands)

Enviroment :

  • MacOs
  • Android Studio

Code :

void main() {
  group('Testing full app flow', () {
    IntegrationTestWidgetsFlutterBinding.ensureInitialized();

    setUpAll(() async {
      await Process.run('adb' , ['shell' ,'pm', 'grant', 'com.MYSERVICE', 'android.permission.ACCESS_FINE_LOCATION']); 
    });

    testWidgets('test the password input on real device/emulator', (tester) async {

     //TESTS

    });

  });
}

2

Answers


  1. Chosen as BEST ANSWER

    I figured out how to make it properly : Now the adb commands needs to be in the driver because the test is running on the device (and it obviously cant adb itself)

    it should be something like that :

    import 'dart:io';
    
    import 'package:integration_test/integration_test_driver.dart';
    
    Future<void> main() async {
      await Process.run('adb' , ['shell' ,'pm', 'grant', 'com.myapp','android.permission.ACCESS_FINE_LOCATION']);
      await Process.run('adb' , ['shell' ,'pm', 'grant', 'com.myapp','android.permission.ACCESS_COARSE_LOCATION']);
      await integrationDriver();
    }
    

    as described here : https://github.com/flutter/flutter/issues/12561

    I did not made it on iOS for the moment but will update later

    PS : the run command is still :

    flutter drive
    --driver=integration_test/driver.dart
    --target=integration_test/app_test.dart
    -d DEVICE

    But Flutter_blue still consider the Bluetooth disabled


  2. Try with superuser:

    sudo flutter run
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search