no permissions found in manifest for : 2 [flutter] - flutter

im using permission_handle to take permission for location.
and it always saying "No permissions found in manifest"
even i tried "flutter clean"
import 'package:permission_handler/permission_handler.dart';
class PermissionsService {
final PermissionHandler _permissionHandler = PermissionHandler();
Future<bool> _requestPermission(PermissionGroup permission) async {
var result = await _permissionHandler.requestPermissions([permission]);
if (result[permission] == PermissionStatus.granted) {
print('innnn');
return true;
}
return false;
}
Future<bool> requestLocationPermission({Function onPermissionDenied} ) async {
// return _requestPermission(PermissionGroup.locationWhenInUse);
var granted = await _requestPermission(PermissionGroup.location );
if(!granted){
onPermissionDenied();
}
return granted;
}
}
my Manifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.artistry">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

You added permission in the Wrong Manifest File, You have to add location permission inside Android Manifest of this Directory android\app\src\main\AndroidManifest

You need to set permissions in main AndroidManifest.xml.
There are three folders debug, main and profile.
Run flutter clean.
See my example:
.../main/AndoridManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.packange.name">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Test app"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round">
<activity
android:name="test.packange.name.MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
main.dart
Future<void> requestPermission(PermissionGroup permission) async {
final List<PermissionGroup> permissions = <PermissionGroup>[permission];
final Map<PermissionGroup, PermissionStatus> permissionRequestResult =
await PermissionHandler().requestPermissions(permissions);
print(permissionRequestResult);
_permissionStatus = permissionRequestResult[permission];
if (_permissionStatus == PermissionStatus.granted) {
initLocationStreamer();
}
print(_permissionStatus);
}
Update plugin https://github.com/Baseflow/flutter-permission-handler. See example and issues.

Related

Location Permission Status - always getting as denied in Flutter

I have created below method to check the location permission status in my flutter application:
Future<void> checkLocationPermission(
BuildContext context, UserCredential userCredential) async {
locationPermissionStatus = await permission_status.Permission.location
.request()
.then((value) async {
if (locationPermissionStatus.isGranted) {
displayToast("granted");
await getCurrentLocation(context, userCredential);
} else {
displayToast("not granted");
}
return locationPermissionStatus;
});
}
Where, PermissionStatus is declared as below:
permission_status.PermissionStatus locationPermissionStatus =
permission_status.PermissionStatus.denied;
Imports as below:
import 'package:location/location.dart';
import 'package:permission_handler/permission_handler.dart' as permission_status;
Used below plugins:
permission_handler: ^10.2.0
location: ^4.4.0
But In App, When Location Permission pops up, I am tapping on option "While Using the App"
But I am always getting the toast display as "not granted"
What might be the issue? Thanks in Advance.
EDIT:
Already added below permissions for Android:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
</manifest>
Adding to the #Romil Mavani answer, you first have to add permissions in AndroidManifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
But it also seems that you are using async/await with the combination of then which is very error-prone. You should either use one or the other.
Future<void> checkLocationPermission(
BuildContext context, UserCredential userCredential) async {
locationPermissionStatus =
await permission_status.Permission.location.request();
if (locationPermissionStatus.isGranted) {
displayToast("granted");
await getCurrentLocation(context, userCredential);
} else {
displayToast("not granted");
}
}
You have to add permission in manifest.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Like this : https://i.stack.imgur.com/PgdNF.png
Also permission status is not working correctly for only location permission so you have check and request permission using location package and it will works fine.
I Hope this things are solve your issue.
If you're using a Windows Emulator
I've faced the same issue before, but when I opened the application setting of my mobile's emulator to confirm, the location permission was not granted (off).
So, I granted it manually from the app settings.
Emulator: Setting/apps/allApps/myApp/permisson
This solution works for me.

How to solve "No permissions found in manifest for: []9" in flutter

i was trying to make upload features, so users can upload file into firebase account
in the past, it run well, but yesterday, it wont show the files
there is the code
uploadImage() async {
final storage = FirebaseStorage.instance;
final picker = ImagePicker();
PickedFile? image;
//Check Permissions
await Permission.photos.request();
var permissionStatus = await Permission.photos.status;
if (permissionStatus.isGranted) {
//Select Image
image = await picker.getImage(source: ImageSource.gallery);
var file = File(image!.path);
final fileName = basename(file.path);
final destination = 'user/$emaila/identitas/$fileName';
if (image != null) {
//Upload to Firebase
var snapshot = await storage
.ref()
.child(destination)
.putFile(file)
.whenComplete(() => null);
var downloadUrl = await snapshot.ref.getDownloadURL();
setState(() {
imageUrlidentitas = downloadUrl;
});
} else {
print('No Path Received');
}
} else {
print('Grant Permissions and try again');
}
}
here is android manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rekammedis">
<uses-permission android:name="android.permission.INTERNET"/>
<!-- Permissions options for the `storage` group -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- Permissions options for the `camera` group -->
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:label="rekammedis"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
and the compiler says
D/permissions_handler( 9318): No permissions found in manifest for: []9
D/permissions_handler( 9318): No permissions found in manifest for: []9
I/flutter ( 9318): Grant Permissions and try again
how to solve this ? anyone know ?
i try looking in stackoverflow, but none of them are explain the answer
This is a recent bug which was introduced by the new version of the permissionhandler in 10.2.0. It is discussed here https://github.com/Baseflow/flutter-permission-handler/issues/944 and I will copy the answer to this question as well. This solution was also working for me.
I've fixed this by checking for Permissions.storage.status when the device is Android 12.0 or below, else I use the Permissions.photos.status. I use the device_info_plus plugin to check the Android version:
I added the following to my AndroidManifest.kt
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
and in flutter:
if (Platform.isAndroid) {
final androidInfo = await DeviceInfoPlugin().androidInfo;
if (androidInfo.version.sdkInt <= 32) {
/// use [Permissions.storage.status]
} else {
/// use [Permissions.photos.status]
}
}
all credits belong to HinrikHelga on github
Check your targetSdkVersion in build.gradle file.
If you are using targetSdkVersion = 30, you will need to write storage permission in a different way. I think you can try the solution discussed in this post

Flutter Unhandled Exception: FileSystemException: Creation failed, path = 'storage/emulated/0/newcreatefoldr' ( Operation not permitted, errno = 1)

Flutter/ This is my code for creating folder using pathProdiver package
note: i have set the permission in manifest file as a
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I do not what is the real problem here, the compiler says permission is denied but i set all the permissions.
Future<String> askForPermission() async {
final folderName = "newcreatefoldr";
final path = Directory("storage/emulated/0/$folderName");
var status=await Permission.storage.status;
if(!status.isGranted){
await Permission.storage.request();
}
if(await path.exists()){
return path.path;
}else{
path.create();
return path.path;
}
}
and the error saying ....
E/flutter (24174): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: FileSystemException: Creation failed, path = 'storage/emulated/0/newcreatefoldr' (OS Error: Operation not permitted, errno = 1)
for more detailed this is my manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cameraapp">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:label="cameraapp"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
I solved this problem with the following solutions: For android 10/Q, I have added this permission in the androidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
and add this line in application tag:
android:requestLegacyExternalStorage="true"
like this:
<application
...
android:requestLegacyExternalStorage="true">
For android 11/R, add this permission:
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
In app-user permission handler I'm checking permissions with the following function:
Future<bool> _hasAcceptedPermissions() async {
if (Platform.isAndroid) {
if (await _requestPermission(Permission.storage) &&
// access media location needed for android 10/Q
await _requestPermission(Permission.accessMediaLocation) &&
// manage external storage needed for android 11/R
await _requestPermission(Permission.manageExternalStorage)) {
return true;
} else {
return false;
}
}
if (Platform.isIOS) {
if (await _requestPermission(Permission.photos)) {
return true;
} else {
return false;
}
} else {
// not android or ios
return false;
}}

Display notification when app is closed flutter

I Have try to display notification in flutter app
When app is open the notification is display but
when flutter app is Closed but it is not working or notification is not display I have share my AndroidManifest.xml
file please check it and help me , I'am new in flutter
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tv_dashboard">
<!-- Internet Connection -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Display Notifications -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Leads"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:showWhenLocked="true"
android:turnScreenOn="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
You can do by using this-
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:workmanager/workmanager.dart';
void main() {
// needed if you intend to initialize in the `main` function
WidgetsFlutterBinding.ensureInitialized();
Workmanager.initialize(
// The top level function, aka callbackDispatcher
callbackDispatcher,
// If enabled it will post a notification whenever
// the task is running. Handy for debugging tasks
isInDebugMode: true
);
// Periodic task registration
Workmanager.registerPeriodicTask(
"2",
//This is the value that will be
// returned in the callbackDispatcher
"simplePeriodicTask",
// When no frequency is provided
// the default 15 minutes is set.
// Minimum frequency is 15 min.
// Android will automatically change
// your frequency to 15 min
// if you have configured a lower frequency.
frequency: Duration(minutes: 15),
);
runApp(MyApp());
}
void callbackDispatcher() {
Workmanager.executeTask((task, inputData) {
// initialise the plugin of flutterlocalnotifications.
FlutterLocalNotificationsPlugin flip = new
FlutterLocalNotificationsPlugin();
// app_icon needs to be a added as a drawable
// resource to the Android head project.
var android = new AndroidInitializationSettings('#mipmap/ic_launcher');
var IOS = new IOSInitializationSettings();
// initialise settings for both Android and iOS device.
var settings = new InitializationSettings(android, IOS);
flip.initialize(settings);
_showNotificationWithDefaultSound(flip);
return Future.value(true);
});
}
Future _showNotificationWithDefaultSound(flip) async {
// Show a notification after every 15 minute with the first
// appearance happening a minute after invoking the method
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your channel id',
'your channel name',
'your channel description',
importance: Importance.Max,
priority: Priority.High
);
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
// initialise channel platform for both Android and iOS device.
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics,
iOSPlatformChannelSpecifics
);
await flip.show(0, 'GeeksforGeeks',
'Your are one step away to connect with GeeksforGeeks',
platformChannelSpecifics, payload: 'Default_Sound'
);
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Geeks Demo',
theme: ThemeData(
// This is the theme
// of your application.
primarySwatch: Colors.green,
),
home: HomePage(title: "GeeksforGeeks"),
);
}
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
// This method is rerun every time setState is called.
// The Flutter framework has been optimized
// to make rerunning build methods
// fast, so that you can just rebuild
// anything that needs updating rather
// than having to individually change
//instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from
// the MyHomePage object that was created by
// the App.build method, and use it
// to set our appbar title.
title: Text(widget.title),
),
body: new Container(),
);
}
}
dependencies
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
# Use with the Workmanger class for background jobs headless execution.
workmanager: ^0.2.3
# Use with FlutterLocalNotificationsPlugin class for local push notifications.
flutter_local_notifications: ^1.4.4+2
And
<!-- Add below permission inside 'manifest' tag -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- Add below permission inside 'application' tag -->
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
and use for more
flutter_local_notifications
thank you

How to send email with flutter?

I tried all packages to send email ( flutter_email_sender - flutter_mailer -url_launcher), copy and paste the example, but always the same error message : " MissingPluginException(No implementation found for methode ...), I serach a simple example to send email on press button.
thank you
To use latest version of url_launcher or above version of 4.1.0+1
, you have to migrate to android x.
[https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility][1]
Example:
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class SendEmail extends StatelessWidget {
void _contact() async {
final url = 'mailto:dude#gmail.com';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
#override
Widget build(BuildContext context) {
return RaisedButton(
onPressed: (){_contact()},
child: Text('Mail'),
),
}
}
try adding these lines on AndroidManifest.xml
<!-- Provide required visibility configuration for API level 30 and above -->
<queries>
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
</queries>
then run flutter clean, then build again
it work for me but this is specific for url_launcher