I am trying to write integration_test for my location app. I need to allow location permission from my integration_test.
I have set ANDROID_SDK_ROOT in my windows environment variable. I have tested from command prompt & Android Studio terminal and it shows fine from both. https://i.ibb.co/4gDPs3Z/echo-android-sdk-root.jpg
Unfortunately, I am getting ANDROID_SDK_ROOT value null from Platform.environment. I have attached screen shot https://i.ibb.co/t2Y3fBc/android-sdk-root-not-found.jpg
If I hard coded envVars to my windows machine's android location C:/Users/User/AppData/Local/Android/Sdk/platform-tools/adb.exe, then it throws error
No such file or directory Command: C:/Users/User/AppData/Local/Android/Sdk/platform-tools/adb.exe shell pm grant com.dealerapp.mlink android.permission.ACCESS_COARSE_LOCATION
below is my source code
Future<void> grantLocationPermission() async{
final Map<String, String> envVars = Platform.environment;
print('evnVars = $envVars');
print('ANDROID_SDK_ROOT = ${envVars['ANDROID_SDK_ROOT']}');
final String adbPath = envVars['ANDROID_SDK_ROOT']! + '/platform-tools/adb.exe';
await Process.run(adbPath, [
'shell',
'pm',
'grant',
'com.abcd.efgh', //my app package
'android.permission.ACCESS_COARSE_LOCATION'
]);
await Process.run(adbPath, [
'shell',
'pm',
'grant',
'com.abcd.efgh', //my app package
'android.permission.ACCESS_FINE_LOCATION'
]);
await integrationDriver();
}
Any suggesion will be highly appreciated. Thanks in Advance.