How to solve build failed due to use of deprecated android v1 embedding



If you're seeing a "build failed due to use of deprecated android v1 embedding" error in Flutter, it means that your project is still using the old Android embedding system, which has been deprecated in favor of the new Android v2 embedding system.

Here are the steps you can follow to migrate your Flutter project to the new Android v2 embedding system:

  1. Check Flutter version Make sure you're using a version of Flutter that supports the new Android v2 embedding system. You can check your Flutter version by running the following command in your terminal:
css
flutter --version

If your Flutter version is older than 1.12.13, you should update Flutter to the latest version by running the following command:

flutter upgrade
  1. Update dependencies Open your android/app/build.gradle file and add the following dependencies to the dependencies section:
javascript
dependencies { // ... implementation 'com.android.support:multidex:1.0.3' implementation 'androidx.multidex:multidex:2.0.1' }

This will add the necessary dependencies for the new Android v2 embedding system.

  1. Update gradle.properties Open your android/gradle.properties file and add the following line of code:
javascript
android.enableR8=true

This enables R8 code shrinking, which is necessary for the new Android v2 embedding system.

  1. Enable multiDex Open your android/app/build.gradle file and add the following code to the android section:
javascript
android { defaultConfig { // ... multiDexEnabled true } }

This enables multiDex, which is necessary for the new Android v2 embedding system.

  1. Replace old embedding system Update your Flutter code to use the new Android v2 embedding system. Follow the instructions in the Flutter documentation: https://flutter.dev/docs/development/add-to-app/android/project-setup

  2. Clean and rebuild Run the following command to clean your project:

flutter clean

Then run the following command to rebuild your project:

flutter build apk

This should resolve the "build failed due to use of deprecated android v1 embedding" error.

If you're still having trouble, you may want to consult the Flutter documentation or seek help from the Flutter community on GitHub or other forums.

Post a Comment

Previous Post Next Post