I am trying to add native ads using the plugin flutter_native_admob but I always get this error:
E/flutter ( 6504): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method initialize on channel flutter_native_admob)
E/flutter ( 6504): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
E/flutter ( 6504): <asynchronous suspension>
E/flutter ( 6504): #1 NativeAdmob.initialize (package:flutter_native_admob/flutter_native_admob.dart:105:20)
E/flutter ( 6504): #2 HomePageState.initState (package:spanglishcards/view/card/HomePage.dart:67:19)
E/flutter ( 6504): #3 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
I tried to add it in my Home page:
class HomePage extends StatefulWidget {
HomePage({
this.user,
});
final User user;
#override
State<StatefulWidget> createState() => HomePageState();
}
class HomePageState extends State<HomePage> {
final _nativeAdmobs = NativeAdmob();
Future initState() {
super.initState();
_nativeAdmobs.initialize(appID:"ca-app-pub-XXX~XXX" );
}
}
And also in the main.dart:
final _nativeAdmobs = NativeAdmob();
void main(){
WidgetsFlutterBinding.ensureInitialized();
_nativeAdmobs.initialize(appID:"ca-app-pub-XXX~XXX" );
runApp(MyApp());
}
I also tried to run flutter clean / flutter run before just in case, but it doesn't work either. Any solution?
To discard issues with my appID, the plugin firebase_admob (doesn't support native ads) works.
Related
I'm trying to use SQLite database using the sqflite plugin. Running the app below results in Unhandled Exception: MissingPluginException error.
Here's my code:
main.dart:
...
late final Database database;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
database = await openDatabase(
join(await getDatabasesPath(), 'mydb.db'),
version: 1,
onCreate: (db, version) {
return db.execute('CREATE TABLE config(key TEXT PRIMARY KEY, value TEXT)');
},
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
title: 'MyApp',
initialRoute: '/',
onGenerateRoute: (settings) => onGenerateRoute(settings),
onUnknownRoute: pageNotImplementedRoute,
);
}
}
Route? onGenerateRoute(RouteSettings settings) {
...
}
Route pageNotImplementedRoute(RouteSettings settings) {
return MaterialPageRoute<void>(...);
}
Here's the output from the run:
Launching lib\main.dart on Android SDK built for x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
? Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:56398/fJzrmThsqQA=/ws
Syncing files to device Android SDK built for x86 64...
E/flutter ( 6173): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
E/flutter ( 6173): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
E/flutter ( 6173): <asynchronous suspension>
E/flutter ( 6173): #1 wrapDatabaseException (package:sqflite/src/exception_impl.dart:7:20)
E/flutter ( 6173): <asynchronous suspension>
E/flutter ( 6173): #2 SqfliteDatabaseFactoryMixin.getDatabasesPath (package:sqflite_common/src/factory_mixin.dart:152:20)
E/flutter ( 6173): <asynchronous suspension>
E/flutter ( 6173): #3 main (package:mymedica/main.dart:76:10)
E/flutter ( 6173): <asynchronous suspension>
E/flutter ( 6173):
Anyone has any idea what's wrong?
This error is just because the SQFLite dependency not get it's package. you should follow this steps. It's Work for me...
flutter clean
File > Invalide caches & Restart
flutter pub get
And you will get your desired outcome.!
I am building a desktop application using flutter where I need to play audio files from local storage and for this I am using just_audio flutter package since it supports Windows. But I Couldn't find any examples of it for windows. I have coded something like this-
import 'package:just_audio/just_audio.dart';
...
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final _player = AudioPlayer();
#override
void initState() {
super.initState();
...
_init();
}
Future<void> _init() async {
await _Player.setFilePath('C:/Users/Admin/Downloads/test.wav', preload: true);
}
...
The await call never finishes and I am getting the following error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
<asynchronous suspension>
#1 MethodChannelJustAudio.init (package:just_audio_platform_interface/method_channel_just_audio.dart:13:5)
<asynchronous suspension>
#2 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1255:13)
<asynchronous suspension>
#3 AudioPlayer.load (package:just_audio/just_audio.dart:708:26)
<asynchronous suspension>
#4 AudioPlayer.setAudioSource (package:just_audio/just_audio.dart:683:18)
<asynchronous suspension>
just_audio doesn't include a Windows implementation. As it says in the README, you need to include another package such as just_audio_libwinmedia that provides a Windows implementation of the package.
Hi If you have used some package, then after pub get try to restart app(Not hot restart, build it again) then it will work.
Iam trying to add two permissions i.e. storage and camera. I have done the required setup in androidmanifest.xml file and in the main.dart called both the requests using switch. It gives the error but the app works and the permissions are also updated
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:teamup/Connectivity/network_binding.dart';
import 'package:teamup/Views/Login/sign_in.dart';
import 'package:teamup/Views/OnboardingScreen/onboarding_screen.dart';
import 'Views/OnboardingScreen/onboarding_constants.dart';
void main() async {
await GetStorage.init();
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
#override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late Permission cameraPermission;
late Permission storagePermission;
PermissionStatus cameraPermissionStatus = PermissionStatus.denied;
PermissionStatus storagePermissionStatus = PermissionStatus.denied;
void _listenForPermission() async {
final cameraStatus = await Permission.camera.status;
final storageStatus = await Permission.storage.status;
setState(() {
cameraPermissionStatus = cameraStatus;
storagePermissionStatus = storageStatus;
});
switch (cameraStatus) {
case PermissionStatus.denied:
requestForPermission();
break;
case PermissionStatus.granted:
break;
case PermissionStatus.restricted:
Navigator.pop(context);
break;
case PermissionStatus.limited:
Navigator.pop(context);
break;
case PermissionStatus.permanentlyDenied:
Navigator.pop(context);
break;
}
switch (storageStatus) {
case PermissionStatus.denied:
requestForPermission();
break;
case PermissionStatus.granted:
break;
case PermissionStatus.restricted:
Navigator.pop(context);
break;
case PermissionStatus.limited:
Navigator.pop(context);
break;
case PermissionStatus.permanentlyDenied:
Navigator.pop(context);
break;
}
}
Future<void> requestForPermission() async {
final cameraStatus = await Permission.camera.request();
final storageStatus = await Permission.storage.request();
setState(() {
cameraPermissionStatus = cameraStatus;
storagePermissionStatus = storageStatus;
});
}
#override
void initState() {
super.initState();
_listenForPermission();
isViewed.writeIfNull('key', 0);
print(isViewed.read('key'));
}
#override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.blue, fontFamily: 'Glory'),
initialBinding: NetworkBinding() ,
home: isViewed.read('key') != 0
? const SignInPage()
: const OnboardingPage(),
);
}
}
This is the message that was displayed after installation
Launching lib\main.dart on Redmi Note 4 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
W/FlutterActivityAndFragmentDelegate(21677): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Debug service listening on ws://127.0.0.1:56092/dh3Yn3XCkGg=/ws
Syncing files to device Redmi Note 4...
I/FA (21677): Tag Manager is not found and thus will not be used
I/flutter (21677): 0
[GETX] Instance "GetMaterialController" has been created
[GETX] Instance "GetMaterialController" has been initialized
[GETX] Instance "GetXNetworkManager" has been created
[GETX] Instance "GetXNetworkManager" has been initialized
I/Timeline(21677): Timeline: Activity_launch_request time:267480997 intent:Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.packageinstaller (has extras) }
E/flutter (21677): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null, null)
E/flutter (21677): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (21677): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (21677): <asynchronous suspension>
E/flutter (21677): #2 MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:71:9)
E/flutter (21677): <asynchronous suspension>
E/flutter (21677): #3 PermissionActions.request (package:permission_handler/permission_handler.dart:44:31)
E/flutter (21677): <asynchronous suspension>
E/flutter (21677): #4 _MyAppState.requestForPermission (package:teamup/main.dart:75:26)
E/flutter (21677): <asynchronous suspension>
E/flutter (21677):
I/Timeline(21677): Timeline: Activity_launch_request time:267501469 intent:Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.packageinstaller (has extras) }
The switch-statements in _listenForPermission will call requestForPermission twice, if both cameraStatus and storageStatus have status PermissionStatus.denied. Therefore you get the exception:
PlatformException(PermissionHandler.PermissionManager, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null, null)
The permission_handler package allows you to request multiple permission in one call like this:
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
Permission.storage,
].request();
print(statuses[Permission.location]);
I want to get the HERE credentials from a web service and not from the android manifest or info.plist as stated in the HERE documentation, but at this point I get an error.
Here Flutter SDK version 4.8.0.0
import 'package:flutter/material.dart';
import 'package:here_sdk/core.dart';
import 'package:here_sdk/core.engine.dart';
import 'package:here_sdk/core.errors.dart';
import 'package:here_sdk/mapview.dart';
void main() {
SDKOptions sdkOptions = SDKOptions.withAccessKeySecretAndCachePath(
"YOUR_ACCESS_KEY_ID", "YOUR_ACCESS_KEY_SECRET", "");
SDKNativeEngine sdkNativeEngine;
try {
sdkNativeEngine = SDKNativeEngine(sdkOptions);
SDKNativeEngine.sharedInstance = sdkNativeEngine;
} on InstantiationException {
// Handle exception.
}
SdkContext.init(IsolateOrigin.main);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'HERE SDK for Flutter - Hello Map!',
home: HereMap(onMapCreated: _onMapCreated),
);
}
void _onMapCreated(HereMapController hereMapController) {
hereMapController.mapScene.loadSceneForMapScheme(MapScheme.normalDay,
(MapError? error) {
if (error != null) {
print('Map scene not loaded. MapError: ${error.toString()}');
return;
}
const double distanceToEarthInMeters = 8000;
hereMapController.camera.lookAtPointWithDistance(
GeoCoordinates(52.530932, 13.384915), distanceToEarthInMeters);
});
}
}
An error occurred
E/flutter (16773): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Invalid argument(s): Failed to resolve an FFI function. Perhaps `LibraryContext.init()` was not called.
E/flutter (16773): Failed to lookup symbol (undefined symbol: here_sdk_sdk_core_engine_SDKOptions_make__String_String_String)
E/flutter (16773): #0 catchArgumentError (package:here_sdk/src/_library_context.dart:39:5)
E/flutter (16773): #1 SDKOptions._withAccessKeySecretAndCachePath (package:here_sdk/src/sdk/core/engine/s_d_k_options.dart:207:49)
E/flutter (16773): #2 new SDKOptions.withAccessKeySecretAndCachePath (package:here_sdk/src/sdk/core/engine/s_d_k_options.dart:94:121)
E/flutter (16773): #3 main (package:here_example/main.dart:8:38)
E/flutter (16773): #4 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:142:25)
E/flutter (16773): #5 _rootRun (dart:async/zone.dart:1354:13)
How can I implement LibraryContext.init()?
Can you share code snippet about that?
Thanks.
Make sure to init the SDKContext before initializing the HERE SDK. I wish this would have been stated in the documentation, but apparently it is not.
So, instead of calling it after creating the SDKNativeEngine, call it like so:
void main() {
SdkContext.init(IsolateOrigin.main);
// Clear the cache occupied by a previous instance.
await SDKNativeEngine.sharedInstance?.dispose();
SDKOptions sdkOptions = SDKOptions.withAccessKeySecretAndCachePath(
"YOUR_ACCESS_KEY_ID", "YOUR_ACCESS_KEY_SECRET", "");
SDKNativeEngine sdkNativeEngine;
try {
sdkNativeEngine = SDKNativeEngine(sdkOptions);
SDKNativeEngine.sharedInstance = sdkNativeEngine;
} on InstantiationException {
// Handle exception.
}
runApp(MyApp());
}
I'm trying to access the device microphone on press with the aim of recording a voice-note. I have tried to access the current permission value but get the following error:
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method checkPermissionStatus on channel flutter.baseflow.com/permissions/methods)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
<asynchronous suspension>
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
#2 MethodChannelPermissionHandler.checkPermissionStatus (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:15:41)
#3 PermissionActions.status (package:permission_handler/permission_handler.dart:30:51)
#4 _InsideLeftState.build.<anonymous closure> (package:easy_tiger/screens/order_card_flow/insideleft.dart:19:62)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
#6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
#7 BaseTapGestureRecognizer._checkUp (pa<…>
[VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
Here is the code for my screen:
import 'package:flutter/material.dart';
import 'package:audio_recorder/audio_recorder.dart';
import 'package:permission_handler/permission_handler.dart';
class InsideLeft extends StatefulWidget {
#override
_InsideLeftState createState() => _InsideLeftState();
}
class _InsideLeftState extends State<InsideLeft> {
#override
Widget build(BuildContext context) {
return Container(
child: GestureDetector(
child: Icon(Icons.mic),
onTap: () async {
PermissionStatus mic = await Permission.microphone.status;
print('microphone permission? ${mic.toString()}');
// try {
//// if (mic != PermissionStatus.granted) {
//// await Permission.microphone.request();
//// }
//// } catch (e) {
//// print(e);
//// }
},
),
);
}
}
Any thoughts how to get around this?
can you please try these things :
Migrate to androidX using android Studio
delete gradle caches
Good post about this topic: Flutter MissingPluginException with several plugins