USER9561
USER9561

Reputation: 1084

MissingPluginException after upgrading to Android embedding v2

I need to implement a plugin in my app. For this, I needed to migrate to Android embedding v2. Through the documentation, I tried upgrading. Below is the documentation I referred:

https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

For upgrading, I changed my imports in MainActivity.kt

to import io.flutter.embedding.android.FlutterActivity and removed the onCreate Method as well.

In AndroidManifest.xml I added the below meta-data

   <meta-data
    android:name="io.flutter.embedding.android.NormalTheme"
    android:resource="@style/NormalTheme"
   />
  <meta-data android:name="flutterEmbedding" android:value="2"/>
  <meta-data
    android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
    android:value="true" />

After adding this I got some error so I changed the Application.java to this

 public class Application extends FlutterApplication implements PluginRegistrantCallback {
   @Override
   public void onCreate() {
   super.onCreate();
   FlutterFirebaseMessagingService.setPluginRegistrant(this);
   }

   @Override
   public void registerWith(PluginRegistry registry) {
      //GeneratedPluginRegistrant.registerWith(registry);
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));

  }
}

The application is installing but I am getting below errors after

 Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)



 MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)

I tried uninstalling and reinstalling the app. Tried flutter clean and flutter pub cache repair as well but nothing works.

Upvotes: 0

Views: 771

Answers (1)

Andrious Solutions
Andrious Solutions

Reputation: 728

If you're getting the error, MissingPluginException, bon't forget this last bit in your AndroidManifest:

       </activity>
   </application>
   <meta-data
    android:name="flutterEmbedding"
    android:value="2" />
 </manifest>

Upvotes: 1

Related Questions