Since yesterday, when I use a GestureDetector with the url_launcher package I'm getting this error:
E/flutter (17573): #0 _musicAreaState._launchURL (package:GiramosApp/ui/views/home_screen/widgets/music_area.dart:37:7)
E/flutter (17573): <asynchronous suspension>
E/flutter (17573): #1 _musicAreaState.build.<anonymous closure> (package:GiramosApp/ui/views/home_screen/widgets/music_area.dart:55:13)
E/flutter (17573): #2 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (17573): #3 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (17573): #4 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (17573): #5 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:259:7)
E/flutter (17573): #6 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
E/flutter (17573): #7 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
E/flutter (17573): #8 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter (17573): #9 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:263:11)
E/flutter (17573): #10 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:157:7)
E/flutter (17573): #11 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:103:7)
E/flutter (17573): #12 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:87:7)
E/flutter (17573): #13 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (17573): #14 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (17573): #15 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (17573): #16 _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (17573): #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
E/flutter (17573): ```
Any thoughts?
I found the error, I don't know why but it works deleting the async function. So, the result it's:
launchUrl(url) {
launch(url);
}
On iOS it works with the async flavour, but not on Android.
From API30 (Android 11) onwards, your Android app has to list all apps it interacts with.
Add this in your android manifest file (android > app > src > main > AndroidManifest.xml)
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
Install the package properly using the steps given here. You should add a dependency of url_launcher in pubspec.yaml file. If you have done that,
To solve this issue you should clean the project using flutter clean, and then you upgrade your flutter using flutter upgrade. This will solve the problem for sure. If not, you create a new project and then paste the code in it.
Related
I'm trying to get the coordinations of a String address using Geocoder, my code is working well on ios devices but when I run it on Android it shows me this error
I/zygote (29355): Do partial code cache collection, code=58KB, data=46KB
I/zygote (29355): After code cache collection, code=57KB, data=46KB
I/zygote (29355): Increasing code cache capacity to 256KB
E/flutter (29355): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(failed, Failed, null)
E/flutter (29355): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:572:7)
E/flutter (29355): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:161:18)
E/flutter (29355): <asynchronous suspension>
E/flutter (29355): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
E/flutter (29355): #3 LocalGeocoding.findAddressesFromQuery (package:geocoder/services/local.dart:18:43)
E/flutter (29355): #4 _TextFieldAutoCompleteState.build.<anonymous closure> (package:label_national_h/Widgets/TextFieldAutoComplete.dart:33:46)
E/flutter (29355): <asynchronous suspension>
E/flutter (29355): #5 _TextFieldAutoCompleteState.build.<anonymous closure> (package:label_national_h/Widgets/TextFieldAutoComplete.dart)
E/flutter (29355): #6 _TextFieldSelectionGestureDetectorBuilder.onSingleTapUp (package:flutter/src/material/text_field.dart:107:26)
E/flutter (29355): #7 _TextSelectionGestureDetectorState._handleTapUp (package:flutter/src/widgets/text_selection.dart:1298:29)
E/flutter (29355): #8 TapGestureRecognizer.handleTapUp.<anonymous closure> (package:flutter/src/gestures/tap.dart:522:56)
E/flutter (29355): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
E/flutter (29355): #10 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:522:11)
E/flutter (29355): #11 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
E/flutter (29355): #12 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:256:7)
E/flutter (29355): #13 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:158:27)
E/flutter (29355): #14 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
E/flutter (29355): #15 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter (29355): #16 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
E/flutter (29355): #17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
E/flutter (29355): #18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
E/flutter (29355): #19 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (29355): #20 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (29355): #21 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (29355): #22 _invoke1 (dart:ui/hooks.dart:267:10)
E/flutter (29355): #23 _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
Here is my code
return TextField(
controller: textEditController,
onTap: () async {
p = await PlacesAutocomplete.show(
context: context,
apiKey: R.Google_api_key,
language: "fr",
components: [Component(Component.country, "fr")]);
textEditController.text = p.description;
var addresses = await Geocoder.local.findAddressesFromQuery(p.description);
schedule.UpdateListeners(addresses.first.coordinates.latitude,addresses.first.coordinates.longitude) ;
//final double distance = await distanceBetween( addresses.first.coordinates.latitude, addresses.first.coordinates.longitude, endLatitude, endLongitude);
},
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Adresse, ex. 5 Rue Thénard Paris'),
);
The place autocomplete is working well and returning the required address.
There can be many reasons of appearing this issue,
Negative Lat or lang
In emulator, it can throw exception while in real device not
Problem with api
Some people recommend to use Geocoder.google instead of Geocoder.local [Link for discussion this problem in github][1]
The problem seems to be related to the configuration of the emulator, when I tried the same program on another emulator it worked very well, I have tried to delete the emulator and install it again and the problem is solved !
I am attempting to play a simple sound using flutter's audioplayers library. When I attempt to, I get an Unable to load asset error. I've gone through several related questions on this site, and all of them seem to only suggest checking the indentation on the pubspec.yaml file and running flutter clean. I have done this several times and have had no results. Flutter Doctor finds no issues.
When I click the button that should cause the sound to play, I receive this:
E/flutter (22727): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Unable to load asset: assets/sounds/start.mp3
E/flutter (22727): #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
E/flutter (22727): <asynchronous suspension>
E/flutter (22727): #1 AudioCache._fetchAsset (package:audioplayers/audio_cache.dart:60:29)
E/flutter (22727): #2 AudioCache.fetchToMemory (package:audioplayers/audio_cache.dart:67:30)
E/flutter (22727): <asynchronous suspension>
E/flutter (22727): #3 AudioCache.load (package:audioplayers/audio_cache.dart:82:37)
E/flutter (22727): #4 AudioCache.getAbsoluteUrl (package:audioplayers/audio_cache.dart:140:23)
E/flutter (22727): #5 AudioCache.play (package:audioplayers/audio_cache.dart:103:24)
E/flutter (22727): #6 playSound (package:tick_tok_bio/player.dart:14:20)
E/flutter (22727): #7 MapsState.startNewRoute (package:tick_tok_bio/gps_tracking.dart:122:13)
E/flutter (22727): #8 MapsState.startStop.<anonymous closure> (package:tick_tok_bio/gps_tracking.dart:240:13)
E/flutter (22727): #9 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter (22727): #10 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter (22727): #11 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (22727): #12 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter (22727): #13 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (22727): #14 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter (22727): #15 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter (22727): #16 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (22727): #17 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (22727): #18 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (22727): #19 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (22727): #20 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (22727): #21 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (22727): #22 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (22727): #23 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (22727): #24 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (22727): #25 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (22727): #26 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter (22727): #27 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (22727): #28 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (22727): #29 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter (22727): #30 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
Here is the code that should play the audio file:
import 'package:audioplayers/audio_cache.dart';
import 'dart:async';
import 'package:audioplayers/audioplayers.dart';
AudioPlayer advancedPlayer;
AudioCache audioCache;
void initPlayer() {
advancedPlayer = AudioPlayer();
audioCache = AudioCache(fixedPlayer: advancedPlayer, prefix: 'sounds/');
}
Future<void> playSound(String path) async {
await audioCache.play(path);
return;
}
Here is where the methods are called:
void initState() {
super.initState();
initPlayer();
}
void startNewRoute() async {
await playSound('start.mp3');
// more code here
}
Here is the assets section of pubspec.yaml
flutter:
uses-material-design: true
assets:
- images/
- sounds/start.mp3
fonts:
- family: RobotoMono
fonts:
- asset: fonts/RobotoMono-Regular.ttf
- asset: fonts/RobotoMono-Bold.ttf
And the files are structured like this:
root
lib
[dart files]
images
[some images]
sounds
start.mp3
I can't find any discrepancies between what I've done here and the way the documentation of the library explains it should be used. Any help is appreciated, thanks.
As per by design, you should be adding "assets/" setting your pubspec.yaml like this:
assets:
- images/
- assets/sounds/start.mp3
Audio Cache official doc here
Don't forget to add these files to your pubspec.yaml file:
flutter: assets:
assets/explosion.mp3
someone had similar issue here
I am using this library to use forground service in a flutter app i am trying the sample app in the example of this package but i am getting error which i am not able to understand
Unhandled Exception: MissingPluginException(No implementation found for method foregroundServiceIsStarted on channel org.thebus.foreground_service/main)
E/flutter ( 9491): #0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:154:7)
E/flutter ( 9491): <asynchronous suspension>
E/flutter ( 9491): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter ( 9491): #2 ForegroundService._invokeMainChannel (package:foreground_service/foreground_service.dart:21:33)
E/flutter ( 9491): #3 ForegroundService.foregroundServiceIsStarted (package:foreground_service/foreground_service.dart:133:18)
E/flutter ( 9491): #4 _MyAppState._toggleForegroundServiceOnOff (package:foregroundserviceflutter/main.dart:66:50)
E/flutter ( 9491): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter ( 9491): #6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter ( 9491): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 9491): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter ( 9491): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter ( 9491): #10 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:254:7)
E/flutter ( 9491): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 9491): #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter ( 9491): #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 9491): #14 GestureBinding._handlePointerEvent
(package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 9491): #15 GestureBinding._flushPointerEventQueue
(package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 9491): #16 GestureBinding._handlePointerDataPacket
(package:flutter/src/gestures/binding.dart:86:7)
Any suggestion on what's going wrong in this
i have added the following plugin also – #Neelay Srivastava
MissingPluginException
what ever plugin you add it is not integrated in app although the plugin is get by pub
but not interacted in app for that you just have to quit app and build again
I'm trying o create a flutter application. and I have success working with login with Facebook and Twitter. there is a problem while I'm trying to login with Twitter. My device has not been installed on the twitter application and I'm facing the problem for null value assign. Have anyone maid a solution for the issue.
E/flutter (20681): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'token' was called on null.
E/flutter (20681): Receiver: null
E/flutter (20681): Tried calling: token
E/flutter (20681): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (20681): #1 _LoginScreenState._loginWithTwitter (package:c2c_app/src/screens/Account/Login/login_page.dart:104:39)
E/flutter (20681): <asynchronous suspension>
E/flutter (20681): #2 _LoginScreenState._buildLoginWidget.<anonymous closure> (package:c2c_app/src/screens/Account/Login/login_page.dart:581:40)
E/flutter (20681): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (20681): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (20681): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (20681): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (20681): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (20681): #8 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter (20681): #9 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (20681): #10 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (20681): #11 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (20681): #12 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (20681): #13 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (20681): #14 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (20681): #15 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (20681): #16 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (20681): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (20681): #18 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (20681): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter (20681):
you need to just put try and catch block inside twitter login code
I know there's a lot of information around the web and I've read all the posts and articles I found on the web and still can't figure it out and google documentation about the errors is very bad. Many people complains about it but I don't see any obvious fix and most people are using debug and development mode to avoid this setup.
I've created a flutter app that needs to make Google Sign In and of course, it don't work.
1) I've created the firebase project, activated the android app project, placed the SHA1 release and the .json on the project.
2) I've followed the flutter docs to release the app (key.properties, changing the signingConfigs and that stuff. App it's not on the Play Store, I'm testing on my phone.
2.1) keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
3) Flutter dependencies:
firebase_auth: 0.7.0
google_sign_in: 3.2.4
cloud_firestore: 0.8.2+3
fluttertoast: ^2.0.7
image_picker: 0.4.12+1
shared_preferences: 0.4.3
firebase_storage: 1.0.4
cached_network_image: ^0.7.0
intl: ^0.15.7
firebase_core: ^0.2.5
4) I'm using the new GoogleAuthProvider.getCredential and not the old SignInWithGoogle
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
4.1) Built build\app\outputs\apk\debug\app-debug.apk.
5) When I press login I get this errors:
E/flutter (23045): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
E/flutter (23045): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (23045): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter (23045): <asynchronous suspension>
E/flutter (23045): #2 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:217:58)
E/flutter (23045): <asynchronous suspension>
E/flutter (23045): #3 GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:256:20)
E/flutter (23045): #4 GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:324:48)
E/flutter (23045): #5 _LoginScreenState._handleSignIn (package:flikmechat/login_signup.dart:69:57)
E/flutter (23045): <asynchronous suspension>
E/flutter (23045): #6 _LoginScreenState._loginPage.<anonymous closure> (package:flikmechat/login_signup.dart:566:52)
E/flutter (23045): <asynchronous suspension>
E/flutter (23045): #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
E/flutter (23045): #8 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
E/flutter (23045): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
E/flutter (23045): #10 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
E/flutter (23045): #11 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:211:7)
E/flutter (23045): #12 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (23045): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:225:20)
E/flutter (23045): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:199:22)
E/flutter (23045): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (23045): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (23045): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (23045): #18 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (23045): #19 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (23045): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (23045): #21 _invoke1 (dart:ui/hooks.dart:233:10)
E/flutter (23045): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)
Please advise, I really don't know what to do. Thank you so much.
I resolved by adding the Sha1 debug key on firebase.
I thought that placing the release Sha1 was enough but it's not since when we test on mobile it uses the apk debug.
Hope this help someone.
Plenty can go wrong, as I explained in my answer to this question: Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
Make sure to have your set in your firebase project settings: