I am trying to run my app in Android after implemented the Amplitude in flutter app but when app opens it crashes it exception
Exception has occurred. MissingPluginException (MissingPluginException(No implementation found for method setLibraryName on channel amplitude_flutter))
in Android only it is working well in iOS
can anyone solve this i really don't know where is the exactly problem is
my main.dart
import 'package:vezigo/Models/app_imports.dart';
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
try {
await Firebase.initializeApp();
print("Handling a background message: ${message.messageId}");
} catch (e) {
print("Error handling background message: $e");
}
}
Future<void> _firebaseMessagingAppOpenHandler(RemoteMessage message) async {
try {
await Firebase.initializeApp();
print("Handling a App open message: ${message.messageId}");
} catch (e) {
print("Error handling App open message: $e");
}
}
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
void initializeNotifications() async {
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('');
final InitializationSettings initializationSettings =
InitializationSettings(android: initializationSettingsAndroid);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('apiCalledThisLaunch', false);
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseMessaging.onMessageOpenedApp.listen(_firebaseMessagingAppOpenHandler);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print(
'Received a message while in the foreground: ${message.notification?.title}');
});
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
AnalyticsService();
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => ProfileProvider()),
ChangeNotifierProvider(create: (context) => SignupProvider()),
ChangeNotifierProvider(create: (context) => Cart()),
ChangeNotifierProvider(create: (context) => AddressProvider()),
ChangeNotifierProvider(create: (context) => FavoriteProvider()),
],
child: const MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
brightness: Brightness.light,
),
darkTheme: ThemeData(
brightness: Brightness.light,
),
themeMode: ThemeMode.light,
home: const SplashScreen(),
routes: {
'/cart': (context) => const CartScreen(),
},
);
}
}
I dont know where is exactly problem is so if anyone needed any other file so let me know
I am trying to run my app in Android after implemented the Amplitude in flutter app but when app opens it crashes it exception
Exception has occurred. MissingPluginException (MissingPluginException(No implementation found for method setLibraryName on channel amplitude_flutter))
in Android only it is working well in iOS
can anyone solve this i really don't know where is the exactly problem is
my main.dart
import 'package:vezigo/Models/app_imports.dart';
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
try {
await Firebase.initializeApp();
print("Handling a background message: ${message.messageId}");
} catch (e) {
print("Error handling background message: $e");
}
}
Future<void> _firebaseMessagingAppOpenHandler(RemoteMessage message) async {
try {
await Firebase.initializeApp();
print("Handling a App open message: ${message.messageId}");
} catch (e) {
print("Error handling App open message: $e");
}
}
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
void initializeNotifications() async {
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('');
final InitializationSettings initializationSettings =
InitializationSettings(android: initializationSettingsAndroid);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('apiCalledThisLaunch', false);
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseMessaging.onMessageOpenedApp.listen(_firebaseMessagingAppOpenHandler);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print(
'Received a message while in the foreground: ${message.notification?.title}');
});
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
AnalyticsService();
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => ProfileProvider()),
ChangeNotifierProvider(create: (context) => SignupProvider()),
ChangeNotifierProvider(create: (context) => Cart()),
ChangeNotifierProvider(create: (context) => AddressProvider()),
ChangeNotifierProvider(create: (context) => FavoriteProvider()),
],
child: const MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
brightness: Brightness.light,
),
darkTheme: ThemeData(
brightness: Brightness.light,
),
themeMode: ThemeMode.light,
home: const SplashScreen(),
routes: {
'/cart': (context) => const CartScreen(),
},
);
}
}
I dont know where is exactly problem is so if anyone needed any other file so let me know
Run: flutter clean
then flutter pub get
Now debug your app.