I searched and tryed some solutions but it didn't work for me.
AndroidManifest.xml bottom
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxx116788401~8xxxxxxxxx"/>
In AdvertClass
import 'dart:io';
class AdvertService {
static final AdvertService _instance = AdvertService._internal();
factory AdvertService() => _instance;
MobileAdTargetingInfo _targetingInfo;
final String _bannerAd = Platform.isAndroid
? 'ca-app-pub-6xxxxxxxxx01/xxxxxx5'
: 'ca-app-pub-67xxxxxxxx01/2xxxxxx';
AdvertService._internal() {
_targetingInfo = MobileAdTargetingInfo();
}
showBanner() {
print(_bannerAd);
BannerAd banner = BannerAd(
adUnitId: _bannerAd,
size: AdSize.smartBanner,
targetingInfo: _targetingInfo);
banner
..load()
..show();
banner.dispose();
}
}
build.gradle file android to buttom
android {
compileSdkVersion 28
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_app"
minSdkVersion 28
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
This code works with test id
InterstitialAd(adUnitId: InterstitialAd.testAdUnitId , targetingInfo: _targetingInfo);
But when I change it to my admob id gives error
Admob error
Also
I got verified Admob account.
I created key
I added my test device in
_targetingInfo = MobileAdTargetingInfo( testDevices: <String>["54a0a4f2"]);
Also I see it now it says
Firebase error
but My pubsec.yaml gots
firebase_admob: ^0.9.3+4
firebase_auth: ^0.16.0
cloud_firestore: ^0.13.5
firebase_core: ^0.4.4+3
I createa firebase app ,downlaod the json file and add it then it says this steps but I can't find it
Google json file
The error Missing google_app_id is only because of you didn't implement Firebase Analytics, it is only a reminder, and it doesn't affect the ads.
Initialized AdMob with appID before showing the banner ad
FirebaseAdMob.instance.initialize(appId: appId);
Also set test device id Found in your Admob error to prevent showing real ads in debug mode
MobileAdTargetingInfo(
...
testDevices: <String>["Your device id"], // Android emulators are considered test devices
);
Real Ads will be shown by the following steps:
Verified AdMob ac.
Sign Your App
Build Release if you have set your device test ID in Targeting Info.
Connect to Firebase Project
Related
void _handleSetLocationShared() {
print("Paylaşılan konumu true olarak ayarlama");
OneSignal.shared.setLocationShared(true);
}
TableRow(children: [
OneSignalButton("Paylaşılan Konumu Ayarla",
_handleSetLocationShared, !_enableConsentButton)
])
My OneSignal Inapp message image
*
I Get Error In Apply The Error I Get: "Location Unavailable It seems there are no location services configured in this app. Please refer to the OneSignal documentation for more information.*
Picture of the Error I Get
Add the following code to debug/AndroidManifest.xml and profile/AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Add the following code to the main.dart file
OneSignal.shared.addTrigger("location_prompt", "true");
and then set the image from OneSignal
OneSignal image
I am writing a flutter app for recording voice using flutter_sound package
environment:
sdk: ">=2.15.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_sound: ^9.1.2
permission_handler: ^8.3.0
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart';
Future init() async {
_audioRecorder = FlutterSoundRecorder();
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted){
throw RecordingPermissionException('Microphone permission denied.');
}
await _audioRecorder!.openAudioSession();
_isRecorderInitiated = true;
}
I am getting this error
The method 'openAudioSession' isn't defined for the type 'FlutterSoundRecorder'.
Can anybody help me in finding out what's wrong with the code?
It seems to have been removed in version 9, but the documentation has not been updated. You can use openRecorder() instead or switch to an older version of the library.
How to get user mobile number in flutter android and iOS.
final String mobileNumber = await MobileNumber.mobileNumber;
simple complete example
flutter main.dart file
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mobile_number/mobile_number.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _mobileNumber = '';
List<SimCard> _simCard = <SimCard>[];
#override
void initState() {
super.initState();
MobileNumber.listenPhonePermission((isPermissionGranted) {
if (isPermissionGranted) {
initMobileNumberState();
} else {}
});
initMobileNumberState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initMobileNumberState() async {
if (!await MobileNumber.hasPhonePermission) {
await MobileNumber.requestPhonePermission;
return;
}
String mobileNumber = '';
// Platform messages may fail, so we use a try/catch PlatformException.
try {
mobileNumber = (await MobileNumber.mobileNumber)!;
_simCard = (await MobileNumber.getSimCards)!;
} on PlatformException catch (e) {
debugPrint("Failed to get mobile number because of '${e.message}'");
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_mobileNumber = mobileNumber;
});
}
Widget fillCards() {
List<Widget> widgets = _simCard
.map((SimCard sim) => Text(
'Sim Card Number: (${sim.countryPhonePrefix}) - ${sim.number}\nCarrier Name: ${sim.carrierName}\nCountry Iso: ${sim.countryIso}\nDisplay Name: ${sim.displayName}\nSim Slot Index: ${sim.slotIndex}\n\n'))
.toList();
return Column(children: widgets);
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: <Widget>[
Text('Running on: $_mobileNumber\n'),
fillCards()
],
),
),
),
);
}
}
pubspec.yaml file
name: flutter_mobilenumber
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
mobile_number: ^1.0.4
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
android app build.gradle file
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_mobilenumber"
minSdkVersion 17
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
here result :
[![enter image description here][1]][1]
details in link
It works good when I tab on selecting image from camera. After selecting image from camera it suddenly crashes and goes back to previous screen .. terminal is show no error .. m using try & catch method but it catch no error as well.
Future pickimage() async {
try{
await ImagePicker.pickImage(
source: ImageSource.camera,
imageQuality: 50,
).then((img) => setState(() {
immage = img;
imagefile = File(immage.path);
}));
if (imagefile != null) {
print('heloo data is saving to database');
await saveimage();
}
}catch(e){
print(e);
}
}
m using latest image_picker() version this is my pub dependences
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: ^1.0.0
carousel_slider: ^2.3.1
animated_text_kit: ^1.3.1
cloud_firestore: ^0.14.3
progress_dialog: ^1.2.4
firebase_auth: ^0.18.4+1
firebase_core: ^0.5.3
google_maps_flutter: ^1.0.6
geolocator: ^6.1.5
geoflutterfire: ^2.2.1
image_picker: ^0.6.7+22
firebase_storage: ^5.2.0
latlng: ^0.0.2
location: ^3.1.0
simple_animations: ^2.4.0
liquid_swipe: ^1.5.0
otp_text_field: ^1.0.1
charts_flutter: ^0.9.0
flutter_echarts: ^1.5.0
flutter_staggered_animations: "^0.1.2"
Have you added few lines of configuration on AndroidManifest.xml ?
You should add:
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"/>
check this url: https://pub.dev/packages/image_cropper/versions/1.3.1
and section: How to install
This is an error in the plugin. You can track the similar issues on GitHub (for example here and here) and provide your error and device hardware info for developers.
Any Feedback on this?
It seems it happening every time i call pickImage.
Future getImage() async {
final _imageFiles =
await ImagePicker().getImage(source: ImageSource.gallery);
if (_imageFiles != null) {
File _imageFile = await Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ImageCropper(file: File(_imageFiles.path))),
);
if (_imageFile != null) {
setState(() {
profilePicChange = _imageFile.path;
// Navigator.pop(context);
});
}
}
In my case apps crush with message "Lost connection to device." both on real device and on simulator.
Trying to fetch some data into the cloud firestore database and when I do this I get this error Failed to get token: com.google.firebase.firestore.FirebaseFirestoreException: getToken aborted due to token change..
pubspec.yaml
cloud_firestore: ^0.9.7
firebase_auth: ^0.8.1+4
android/build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.1.0'
}
Method that fetched the employee_information:
static addEmployee(Map<String, dynamic> snapshot){
Firestore.instance.runTransaction((Transaction tx) async{
await tx.set(Firestore.instance.collection('employee').document(),snapshot);
});
}
If you've come across this issue let me know, thanks!
for ERROR [FirestoreCallCredentials]: Failed to get token:
go to https://console.cloud.google.com/ - select your project
Select API&Services
Select Credentials
and Update the values in API Keys