Flutter test finished with error: ProcessException: Permission denied

449

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

Share:
449
louis habert
Author by

louis habert

French CS student

Updated on December 07, 2022

Comments

  • louis habert
    louis habert over 1 year

    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
    
        });
    
      });
    }
    
  • louis habert
    louis habert over 2 years
    it does not work because it's nor an issue of (owner) rights, the problem was the structure of integration tests that changed when diver_test became integration_test as explained in my answer