lou habert
lou habert

Reputation: 196

Flutter test finished with error: ProcessException: Permission denied

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 :

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

    });

  });
}

Upvotes: 4

Views: 1627

Answers (2)

Himanshu Kumar
Himanshu Kumar

Reputation: 29

Try with superuser:

sudo flutter run

Upvotes: -1

lou habert
lou habert

Reputation: 196

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

Upvotes: 2

Related Questions