title: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. in flutter
body: <p>Using the plugin image_picker_saver: ^0.1.0 plugin in flutter</p>
  
  <p>getting this error:
  `       PS E:\PROJECTS\Flutter Projects\signature_view_new> flutter run
      Launching lib/main.dart on Nokia 8 1 in debug mode...
      Initializing gradle...                                       4.0s
      Resolving dependencies...                                    9.0s
      Gradle task 'assembleDebug'...</p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
  &gt; com.android.build.api.transform.TransformException: Error while generating the main dex list.
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 1m 13s
  Gradle task 'assembleDebug'... Done                         75.5s
  Gradle task assembleDebug failed with exit code 1`
  </code></pre>
  
  <p>pubspec.yaml:</p>
  
  <pre><code>name: signature_view_new
  description: A new Flutter project.
  
  # The following defines the version and build number for your application.
  # A version number is three numbers separated by dots, like 1.2.43
  # followed by an optional build number separated by a +.
  # Both the version and the builder number may be overridden in flutter
  # build by specifying --build-name and --build-number, respectively.
  # Read more about versioning at semver.org.
  version: 1.0.0+1
  
  environment:
    sdk: "&gt;=2.0.0-dev.68.0 &lt;3.0.0"
  
  dependencies:
    flutter:
      sdk: flutter
  
    # The following adds the Cupertino Icons font to your application.
    # Use with the CupertinoIcons class for iOS style icons.
    cupertino_icons: ^0.1.2
    # package for saving the screenshot
    image_picker_saver: ^0.1.0
    # pacakge for toast-msg
    fluttertoast: ^3.0.0
  
  dev_dependencies:
    flutter_test:
      sdk: flutter
  
  
  # For information on the generic Dart part of this file, see the
  # following page: https://www.dartlang.org/tools/pub/pubspec
  
  # The following section is specific to Flutter.
  flutter:
  
    # The following line ensures that the Material Icons font is
    # included with your application, so that you can use the icons in
    # the material Icons class.
    uses-material-design: true
  
    # To add assets to your application, add an assets section, like this:
    # assets:
    #  - images/a_dot_burr.jpeg
    #  - images/a_dot_ham.jpeg
  
    # An image asset can refer to one or more resolution-specific "variants", see
    # https://flutter.io/assets-and-images/#resolution-aware.
  
    # For details regarding adding assets from package dependencies, see
    # https://flutter.io/assets-and-images/#from-packages
  
    # To add custom fonts to your application, add a fonts section here,
    # in this "flutter" section. Each entry in this list should have a
    # "family" key with the font family name, and a "fonts" key with a
    # list giving the asset and other descriptors for the font. For
    # example:
    # fonts:
    #   - family: Schyler
    #     fonts:
    #       - asset: fonts/Schyler-Regular.ttf
    #       - asset: fonts/Schyler-Italic.ttf
    #         style: italic
    #   - family: Trajan Pro
    #     fonts:
    #       - asset: fonts/TrajanPro.ttf
    #       - asset: fonts/TrajanPro_Bold.ttf
    #         weight: 700
    #
    # For details regarding fonts from package dependencies,
    # see https://flutter.io/custom-fonts/#from-packages
  </code></pre>
  
  <p>main.dart:</p>
  
  <pre><code>import 'dart:typed_data';
  import 'dart:ui' as ui;
  import 'package:flutter/material.dart';
  import 'package:flutter/rendering.dart';
  import 'package:signature_view_new/signature.dart';
  import 'package:image_picker_saver/image_picker_saver.dart';
  import "package:fluttertoast/fluttertoast.dart";
  
  void main() =&gt; runApp(MaterialApp(
        home: SignatureView(),
        debugShowCheckedModeBanner: false,
      ));
  
  class SignatureView extends StatefulWidget {
    _SignatureViewState createState() =&gt; _SignatureViewState();
  }
  
  class _SignatureViewState extends State&lt;SignatureView&gt; {
    static GlobalKey previewContainer = new GlobalKey();
    List&lt;Offset&gt; _points = &lt;Offset&gt;[];
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: RepaintBoundary(
          key: previewContainer,
          child: Container(
            width: double.infinity,
            color: Colors.white,
            child: GestureDetector(
              onPanUpdate: (DragUpdateDetails details) {
                setState(() {
                  RenderBox object = context.findRenderObject();
                  Offset _localPosition =
                      object.globalToLocal(details.globalPosition);
                  _points = List.from(_points)..add(_localPosition);
                });
              },
              onPanEnd: (DragEndDetails details) =&gt; _points.add(null),
              child: CustomPaint(
                painter: Signature(points: _points),
                size: Size.infinite,
              ),
            ),
          ),
        ),
        floatingActionButton: Stack(
          children: &lt;Widget&gt;[
            Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: &lt;Widget&gt;[
                FloatingActionButton(
                  child: Icon(Icons.screen_share),
                  onPressed: _takeScreenShot,
                ),
                FloatingActionButton(
                  child: Icon(Icons.clear),
                  onPressed: () =&gt; _points.clear(),
                ),
              ],
            ),
          ],
        ),
      );
    }
  
    void _takeScreenShot() async {
      RenderRepaintBoundary boundary =
          previewContainer.currentContext.findRenderObject();
      ui.Image image = await boundary.toImage();
      ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
      Uint8List pngBytes = byteData.buffer.asUint8List();
      print(pngBytes);
      var filePath = await ImagePickerSaver.saveFile(fileData: pngBytes);
      toastMsg(filePath.toString());
      print(filePath);
    }
  
    toastMsg(String path) {
      var toast = Fluttertoast.showToast(
          msg: "Saved on $path",
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.BOTTOM,
          timeInSecForIos: 3,
          backgroundColor: Colors.red,
          textColor: Colors.white,
          fontSize: 16.0);
  
      print("inside toastMsg");
      return toast;
    }
  }
  </code></pre>
  
  <p>signature.dart:</p>
  
  <pre><code>    import 'package:flutter/material.dart';
  
  class Signature extends CustomPainter{
    List&lt;Offset&gt; points;
  
    Signature({this.points});
  
    @override
    void paint(Canvas canvas, Size size) {
      Paint paint = Paint()
        ..color = Colors.black
        ..strokeCap = StrokeCap.round
        ..strokeWidth = 10.0;
  
        for(int i = 0; i &lt; points.length -1; i++){
          if(points[i] != null &amp;&amp; points[i+1] != null){
            canvas.drawLine(points[i], points[i+1], paint);
          }
        }
    }
  
    @override
    bool shouldRepaint(Signature oldDelegate) =&gt; oldDelegate.points != points;
  }
  </code></pre>
  
  <p>I tried migrating the project to androidX but getting this error:
  <a href="https://i.stack.imgur.com/dDaOb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dDaOb.jpg" alt="enter image description here"></a></p>
  
  <p>build.gradle(app module):</p>
  
  <pre><code>def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  if (localPropertiesFile.exists()) {
      localPropertiesFile.withReader('UTF-8') { reader -&gt;
          localProperties.load(reader)
      }
  }
  
  def flutterRoot = localProperties.getProperty('flutter.sdk')
  if (flutterRoot == null) {
      throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
  }
  
  def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
  if (flutterVersionCode == null) {
      flutterVersionCode = '1'
  }
  
  def flutterVersionName = localProperties.getProperty('flutter.versionName')
  if (flutterVersionName == null) {
      flutterVersionName = '1.0'
  }
  
  apply plugin: 'com.android.application'
  apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
  
  android {
      compileSdkVersion 28
  
      lintOptions {
          disable 'InvalidPackage'
      }
  
      defaultConfig {
          // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
          applicationId "com.example.signatureviewnew"
          minSdkVersion 16
          targetSdkVersion 28
          versionCode flutterVersionCode.toInteger()
          versionName flutterVersionName
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          multiDexEnabled true
      }
  
      buildTypes {
          release {
              // TODO: Add your own signing config for the release build.
              // Signing with the debug keys for now, so `flutter run --release` works.
              signingConfig signingConfigs.debug
          }
      }
  }
  
  flutter {
      source '../..'
  }
  
  dependencies {
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  }
  </code></pre>