Home Blog Page 63

The Best App Development Tools in Flutter

0
Best App Development Tools for Flutter development
Best App Development Tools for Flutter development

Hi Guys, Welcome to Proto Coders Point, In this Blog Post let’s discuss on best app development tools/kits for app build with flutter.

Below I have made a list of the most effective flutter app development tools, which you can check out, learn about it and use right now for developing the best cross-platform flutter app & user-friendly UI applications. So let’s not waste time and check out the list of best Flutter development tools – App development kits.

10 Best Flutter App Development Tools

  1. Android Studio
  2. Visual Studio Code
  3. Panache
  4. Supernova
  5. Adobe Plugin
  6. Instabug
  7. RevenueCat
  8. Count.ly
  9. Appetize.io
  10. Firebase

1. Android Studio IDE Tool

The Android Studio IDE Tool is the top best flutter software development tools, This tool comes with feature like editing support, syntax highlighting, Intelligent code Editor and also an APK analyzer that you can use to check the size of a flutter app & reduce the size of the app. IDE that enables you to develop an effective, responsive and rich flutter app, Android Studio is the best app building tool & UI design tools.

Features

  • Realtime profilers.
  • Flexible build system.
  • Intelligent code editor.
  • Fast emulator.
  • APK Analyzer.
  • Visual layout editor.

How to download android studio?

2. Visual Studio Code IDE

Visual Studio IDE is mostly used for developing Web Application but currently, Visual Studio is rapidly growing in Flutter development, Developers are using VSCode to build cross-platform app development like React Native & Flutter app.

VSCode is been developed by Microsoft and it’s a free & open-source code editor tool that is available for Windows, Linux & Mac OS.

VSCode is easy & simple to use and app build with flutter. Download VSCode

3. Panache – Flutter Material Theme editor

Panache a flutter material theme editor that helps you to create beautiful themes that you can easily integrate into your flutter applications.

Use panache to build customize widget UI Design, give shape to it and export the panache material theme as .dart file.

Currently many flutter developers are making use of this awesome flutter tool. learn more

4. Supernova

Supernova is a designing took used to create a beautiful UI code. recently supernova team has added support for the flutter platform too,

By Using supernava it is feasible to create flutter app using supernova and make modification to your flutter app in real-time.

The Best thing so supernova is it allows you to use Adobe XD UI or Sketch just by importing it here. Supernova promises you a flexible automation platform.

5. Adobe Plugin

Adobe XD has created a new plugin for flutter UI Development. This Flutter Adobe Plugin convert your mobile app designs into a flutter widget code, provide you with a .dart file that you can easily place in your flutter codebase.

6. InstaBug

Every app that is been developed will have some kind of hidden bugs that not even the developer or tester detect during the testing phase. You can use a tool called Instabug, it provides real-time contextual insights into your mobile application.

Flutter Developers use Instabug for bug reposting, in-app crash reporting, conducting a survey or ask your app users a new feature requirement request.

You can easily integrate instabugs flutter SDK in your flutter project and turn on real-time bug reposting and analysis your app usage.

7. RevenueCat

RevenueCat is very useful when you want to integrate in-app purchase or add a monthly subscription plan for your premium users. basically, RevenueCat is a purchase or subscription management tool. You can install Revenue Purchase SDK in your flutter project and easily manage your app business.

This also support in Android, iOS and many other platform where you want to integrate in-app purchase.

8. Count.ly – A Analytics tools

It’s an Open source analytic tools, Count.ly allows you to monitor your audience, and check all the analytics of how your app is performing, with this tool, you can track your app KPIs metric and check out how your apps are growing. They also provide you with a paid version using which you can send a push notification, extra feature flags, as well an A/B testing Feature.

9. Appetize.io

Run the native mobile app in your browser itself. Appetize is a cross-platform mobile app development took that allows you to run native app in any browser in HTML or JavaScript format. Appetize is used for streamline app demos, customer support, training, testing and more.

more over this tools will reduce time-to-market and lauch apps faster.

10. Firebase

A Firebase is a cross-platform solution a platform service provided by Google. Firebase is a very useful tool that you can integrate into your flutter project.

By using firebase you can build a complete back end API. This also provides real-time database, cloud database, ML function, firebase push notification, firebase cloud messaging, crash reposting, analytic and many more.

Conclusion

With the list of best app development tools, you can make your flutter app development project faster and in efficient way.

How to disable/make button invisible in flutter

0
How to disable or make button invisible in flutter
How to disable or make button invisible in flutter

Hi, Guys Welcome to Proto Coders Point, In this fluter tutorial we will learn how to disable a button in flutter & also learn how to make flutter raisedbutton invisibility when not in use so that we can prevent a button from being clicked twice accidentally.

Preventing a button from being clicked twice accidentally

Sometimes what happens is when a user wants to submit a form or perform an action when a button is clicked but accidentally a submit button or flutter raisedbutton gets clicked twice, due to flutter button getting clicked double-time accidentally, double data entry get stored or user perform task twice or face some problem while using your flutter app.

So to prevent this you need to disable further onClick event on button, until the task or the process get completed.

How to enable/disable a button in a flutter – OnClick disable button

Step to follow to enable/disable a button in flutter app.

Video Tutorial

1. Create a boolean variable isButtonClickable

Under StatefullWidget create a boolean variable that we can use to check if button is disabled or enabled.

bool isButtonClickable = true;

initially, as per your app requirement you can keep it either to true or false, in my case i am keep it to true.

2. Create a flutter button ( ElevatedButton) with onPressed property

In the below Snippet Widget Button Code, Depending on the value of isButtonClickable, I am setting text to button either Clickable or Not Clickable,

Then in onPressed() i am using if statement to check if button is Enabled, if Enabled then call the method to perform action/task else do nothing.

ElevatedButton(
              onPressed: () {
                if (isButtonClickable) {
                  ButtonClicked();
                }
              },
              child: Text(
                isButtonClickable?"Clickable":"Not Clickable",
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),

3. Create a method/function which perform some task.

Then, when a button is pressed, the method/function is called, in which by using Flutter State Management (setState()), I am updating isButtonClickable to false, Which make button disable.

That means now user will not be able to click button again twice by mistake.

NOTE: Just, for Example, I am using Future.delayed to make isButtonClickable = true after certain duration (seconds), so that it can be clickable after some time.

In your case as per your project, you can perform an action like, for example, a data is getting submitted to the database & depending on server response (success) you can clean the form and enable button or simply navigate the user to another flutter page.

Note: you may also show a circular progress indicator during a process

  void ButtonClicked() async {

    Duration time = Duration(seconds: 5);

    setState(() {
      isButtonClickable = false;                     //make the button disable to making variable false.
      print("Clicked Once");

      Future.delayed(time,(){
        setState(() {
          isButtonClickable = true;                    //future delayed to change the button back to clickable
        });

      });
    });
  }

4. [Optional] Make Button Invisible

If you want to make the button invisible, until any task or process is getting performed you can simply wrap the ElevatedButton Widget with the Visibility widget and use the visible property & set it to true or false.

Visibility(
              visible: isButtonClickable,
              child: ElevatedButton(
                onPressed: () {
                  if (isButtonClickable) {
                    ButtonClicked();
                  }
                },
                child: Text(
                  isButtonClickable?"Clickable":"Not Clickable",
                  style: TextStyle(
                    color: Colors.white,
                  ),
                ),
              ),
  ),

Complete Source Code – onClick disable button flutter

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:assets_audio_player/assets_audio_player.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: ButtonDisable(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  late AnimationController
      iconController; // make sure u have flutter sdk > 2.12.0 (null safety)

  bool isAnimated = false;
  bool showPlay = true;
  bool shopPause = false;

  AssetsAudioPlayer audioPlayer = AssetsAudioPlayer();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    iconController = AnimationController(
        vsync: this, duration: Duration(milliseconds: 1000));

    audioPlayer.open(Audio('assets/sound/bobbyrichards.mp3'),
        autoStart: false, showNotification: true);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text("Playing Audio File Flutter"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image.network(
                "https://i.pinimg.com/originals/f7/3a/5b/f73a5b4b7262440684a2b5c39e684304.jpg",
                width: 300,
              ),
              SizedBox(
                height: 30,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  InkWell(
                    child: Icon(CupertinoIcons.backward_fill),
                    onTap: () {
                      audioPlayer.seekBy(Duration(seconds: -10));
                    },
                  ),
                  GestureDetector(
                    onTap: () {
                      AnimateIcon();
                    },
                    child: AnimatedIcon(
                      icon: AnimatedIcons.play_pause,
                      progress: iconController,
                      size: 50,
                      color: Colors.black,
                    ),
                  ),
                  InkWell(
                    child: Icon(CupertinoIcons.forward_fill),
                    onTap: () {
                      audioPlayer.seekBy(Duration(seconds: 10));
                      audioPlayer.seek(Duration(seconds: 10));
                    },
                  ),
                ],
              ),
            ],
          ),
        ));
  }

  void AnimateIcon() {
    setState(() {
      isAnimated = !isAnimated;

      if (isAnimated) {
        iconController.forward();
        audioPlayer.play();
      } else {
        iconController.reverse();
        audioPlayer.pause();
      }
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    iconController.dispose();
    audioPlayer.dispose();
    super.dispose();
  }
}

class ButtonDisable extends StatefulWidget {
  @override
  _ButtonDisableState createState() => _ButtonDisableState();
}

class _ButtonDisableState extends State<ButtonDisable> {
  bool isButtonClickable = true;

  void ButtonClicked() async {
    Duration time = Duration(seconds: 5);
    setState(() {
      isButtonClickable = false;
      print("Clicked Once");

      Future.delayed(time,(){
        setState(() {
          isButtonClickable = true;
        });

      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Visibility(
              visible: isButtonClickable,
              child: ElevatedButton(
                onPressed: () {
                  if (isButtonClickable) {
                    ButtonClicked();
                  }
                },
                child: Text(
                  isButtonClickable?"Clickable":"Not Clickable",
                  style: TextStyle(
                    color: Colors.white,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Understanding Future, async & await in the flutter dart

0
why and when to use async await in flutter dart
why and when to use async await in flutter dart

Hi Guys, Welcome to Proto Coders Point, In this Flutter tutorial we will learn what is async & await in flutter.

In order to understand flutter async & await in dart, first we need to learn synchronous vs asynchronous programming in dart & how it works.

synchronous vs asynchronous programming

  • synchronous: In simple words, When you execute code synchronously then you need to wait for it to finish task 1 before you move to task 2.
  • asynchronous: When you execute code asynchronously, then you can continue to execute the next task, no need to wait for the previous task to complete, but in case if task 1 & task 2 are related like, talk 2 get data from task 1 then you need to make use of async & await in a flutter.

Understanding async & await in flutter

We write code or a lines of code that takes very short amount of time to execute & give result

print(''Hello World');

for example we want to print text on console, as you see that it is a single line statement that takes about fraction of second to complete the task, but there are some code or task that need more time to get executed completly for example: loading a image or File from internet.

Here are some common asynchronous task:-

  1. Fetching data(image or file) over a network.
  2. Writing data to a database.
  3. Reading a huge list of file from internet.

Therefore, to perform the asynchronous operations in a dart programming language, we make use of the Future class & the async & await keyword in a flutter.

synchronous and asynchronous programming code example

synchronous programming

for better understanding lets look into how synochronous code works,

//snippet method

void Function(){

   //step 1
   print('Hello World');

   //step 2
   loadImage('url of image to load');

   //step 3
   print('Hello World');


}

When the above method is been called the step 1 gets executed immediately but step 3 executes only when the step 2 process is completely over/executed.

Suppose you have an image to be loaded in step 2 & due to an internet or network issue step 2 never get executed then you code will get stuck at step 2 and step 3 never gets executed until step 2 task is over.

Therefore, in synchronous method every thing works in a sync order/step by step process( The next task will not work until the current task is completed)

asynchronous programming

//snippet method

void Function() async{

   //step 1
   print('Hello World');

   //step 2
   async_loadImage('URL of image to load');  //if loading image take time then step 3 will execute and simultaneously step 2 will load at same time there is not wait.

//step 3
   print('Welcome to proto coders point');

}

So, if you have a method that load image & is a async method then, while the image been getting loaded, the step 3 will get executed, it simply means that the step 3 will not wait until step 2 complete the task.

flutter synchronous example

synchronous.dart code example

void main(){
  callMethods();
}

void callMethods(){
  method1();
  method2();
  method3();
}

void method1(){
  print('method 1 completed');
}

void method2(){
  print('method 2 completed');
}

void method3(){
  print('method 3 completed');
}

Here, its a synchronous code, which execute methods step by step process and the output will be in sequence order.

output

method 1 completed
method 2 completed
method 3 completed

Ok , then suppose if I add a sleep(duration) in method 2 then until sleep duration is not completed the execution of method 3 is still iin pending.

//snippet
void method2(){
  
  Duration wait3sec = Duration(seconds: 3);
  sleep(wait3sec); // sleep here for 3 second, then go forword
  print('method 2 completed');
}

Check out the screenshot of output

dart synchronous example

We have created artifically a sleep timer so that method 2 get paused for some time, but in real time application, the case might be different may be method 2 need time to load data or there might be network issue due to which data is loading slowly like downloading Imahe or files through Internet,

Therefore, if we use the synchronous method then until the image or file gets downloaded, method 3 will not execute, so this is the disadvantage of sync methods.

Flutter delayed method in flutter

Suppose you want to execute a piece of code after some duration then you can make use of async method i.e. Future.delayed(duration,(){});

void method2(){

  Duration wait3sec = Duration(seconds: 5);
  Future.delayed(wait3sec,(){
    print('Future delayed executes after 5 seconds ');
  });
  print('method 2 completed');
}

Now, if i add future delayed to above method 2() then the output will be something like this:

In above example, method 1,2,3 get executed immediatly there is not wait time, but in method 2 i have a future delayed that executed after some duration.

Why & When to use async & await in flutter

Below Example shows you what happens if async & await is not used.

import 'dart:io';

void main(){
  callMethods();
}

//note: that method 3 get data from the result of method 2, but method 3 get executed before method 2 return the result, due to which null get printed 
void callMethods(){
  method1();
  String result =  method2();
  method3(result);
}

void method1(){
  print('method 1 completed');
}

String method2(){

  Duration wait3sec = Duration(seconds: 2);
  String result;
  Future.delayed(wait3sec,(){
    result = 'data from method 2 ';

  });
  
  return result;
}

void method3(String data_from_method2){
  print('method 3 completed, received ${data_from_method2}');
}

output

method 1 completed
method 3 completed, received null

//note: method 3 get data from the result of method 2, but method 3 get executed before method 2 return the result, due to which null get printed.

So, as in above dart code, The method 3 display result as null because method 3 is called immediatly before method 2 return the data therefore string result is null & is passed to method 3 as null.

When to use async & await in flutter dart

Then as you see in the above example method 3 depended of the data that method 2 return, so to prevent null passed to method 3, we make use of async & await in dart.

Snippet Example how async await works in dart

import 'dart:io';

void main(){
  callMethods();
}

void callMethods() async{
  method1();
 String result =   await method2();
  method3(result);
}

void method1(){
  print('method 1 completed');
}

Future method2() async{

  Duration wait3sec = Duration(seconds: 2);
  String result;
  await Future.delayed(wait3sec,(){
    result = 'data from method 2 ';

  });

  return result;
}

void method3(String data_from_method2){
  print('method 3 completed, received ${data_from_method2}');
}

Explanation of above code.

dart async & await example flutter

So as you see the method3() needs data that method2 returns, so we are making use of async & await so that method 2 waits until it returns a result, and then once the result is available it is been passed to method 3. therefore method 3 runs successfully with null safety.

Output of above code

method 1 completed
method 3 completed, received data from method 2 

[Complete Source Code] Audio Player In Flutter – Assets Audio Player

0
audio player in flutter
audio player in flutter

Hi Guys, Welcome to Proto Coders Point, In this flutter tutorial we will learn how to play audio file by using assets_audio_player package that help you to play music from your project assets folder.

Video Tutorial

About Assets audio player package

This audio player flutter package is a very easy-to-use package that helps developers implement sound effects or play the audio files (mp3) from the assets folder, Can be used to develop apps that need some sound effects at a particular time (Eg: Game App).

Now with the latest update with the package, A new feature is been added i.e. we can play audio files from the network url or your own audio API & also listen to radio/Livestream audio music.

And if audio/music is playing & you exit the app, still the audio will be in background & show you Notification in notification bar you can also control the music that is playing from notification itself.

Feature of assets_audio_player package

You can play audio in various ways like

Assets File: Store audio in assets folder & play the audio by its path.

Network url: use exact url of audio file to play it.

Network livestream/radio url: use livestream url to play audio.

Various command/method to play with audio/sounds

  1. play()
  2. pause()
  3. stop()
  4. seek(Duration to)
  5. seekBy(Duration by)
  6. forword(speed)
  7. rewind(speed)
  8. next()
  9. previous().

There are more awesome feature that you can try ” to learn more about the assets audio player visit official site here

How to add & use assets audio player package in flutter

1. Add Dependencies

Open your flutter project & navigate to pubspec.yaml file & open it, then under dependencies add the audio player package.

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.0
  assets_audio_player: ^3.0.3+3 #add this

then don’t forget to hit pub get button, it will download the package in your flutter project.

2. Add audio/music file in a folder

Create new directory in your flutter project Eg: assets/sound/ and copy/paste a music audio file in it. Check out below screenshot.

3. Declare the path of audio assets directory in pubspec.yaml

We need to specily the path of the audio directory, so that the app can read the files from the directory.

flutter:

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/sound/

Snippet Code of Assets Audio Player Package

Importing the package

You need to import the audio player package in dart file, where you want to use it.

import 'package:assets_audio_player/assets_audio_player.dart';

Creating an instance of AssetAudioPlayer

AssetsAudioPlayer audioPlayer = AssetsAudioPlayer();  // this will create a instance object of a class

Now you can use audioPlayer object to set path of your audio file as shown below.

Open/initialize the audio file path

The below method create and initialize the audio file and play it automatically by default if you do not set autoStart: false.

audioplayer.open(
               Audio('assets/sound/bobbyrichards.mp3')
);

if you don’t want autoplay of audio then you can set property autoStart: false,
& There is one more useful property called showNotification:true.

audioplayer.open(
            Audio('assets/sound/bobbyrichards.mp3'),
            autoStart: false,
            showNotification: true
);

This above snippet code will play sound only when play() method get triggered when button is been pressed. and display a notification.

Play audio from network or from your Audio API

void playAudioNetwork() async{
    try{
      await player.open(
        Audio.network("URL PATH")
      );
    }catch(t){
      
    }
  }

Method used to control the audio player

play(): play the audio file.

pause(): pause the audio file.

stop(): completly stop the audio, then if played again then song start from beginning.

playOrPause(): if audio playing, then pause else play.

next(): play next song from the list of songs.

previous(): play prev song from the list of songs.

Jump to specific audio time length

if you want to play the music a particular time file or if you want to forword or rewind the audio at particular time in audio file.

audioPlayer.seek(Duration(seconds: 10));  // just to audio time 10

Forword or rewind the audio by specific time duration

audioPlayer.seekBy(Duration(seconds: 10));  // go 10 sec forword

audioPlayer.seekBy(Duration(seconds: -10));  /go -10 sec backwork

Learn more from offical site here.

Complete Source code Example on Assets Audio Player package

Output

Check the output on my youtube channel, Video tutorial is above

Audio player in flutter

main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:assets_audio_player/assets_audio_player.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  late AnimationController
      iconController; // make sure u have flutter sdk > 2.12.0 (null safety)

  bool isAnimated = false;
  bool showPlay = true;
  bool shopPause = false;
  
  AssetsAudioPlayer audioPlayer = AssetsAudioPlayer();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    iconController = AnimationController(
        vsync: this, duration: Duration(milliseconds: 1000));

    audioPlayer.open(Audio('assets/sound/bobbyrichards.mp3'),autoStart: false,showNotification: true);
    
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text("Playing Audio File Flutter"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image.network("https://i.pinimg.com/originals/f7/3a/5b/f73a5b4b7262440684a2b5c39e684304.jpg",width: 300,),
              SizedBox(height: 30,),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                 InkWell(child: Icon(CupertinoIcons.backward_fill),onTap: (){
                   audioPlayer.seekBy(Duration(seconds: -10));
                 },),
                  GestureDetector(
                    onTap: () {
                      AnimateIcon();
                    },
                    child: AnimatedIcon(
                      icon: AnimatedIcons.play_pause,
                      progress: iconController,
                      size: 50,
                      color: Colors.black,
                    ),
                  ),
                  InkWell(child: Icon(CupertinoIcons.forward_fill),onTap: (){
                    audioPlayer.seekBy(Duration(seconds: 10));
                    audioPlayer.seek(Duration(seconds: 10));
                    audioPlayer.next();
                  },),
                ],
              ),

            ],
          ),
        ));
  }

  void AnimateIcon() {
    setState(() {
      isAnimated = !isAnimated;

     if(isAnimated)
       {
         iconController.forward();
         audioPlayer.play();
       }else{
       iconController.reverse();
       audioPlayer.pause();
     }


    });
  }
  
  @override
  void dispose() {
    // TODO: implement dispose
    iconController.dispose();
    audioPlayer.dispose();
    super.dispose();
  }
}

[100% Solved] Plugin ‘Dart’ is inCompatible, Plugin ‘Flutter’ is inCompatible

0
Plugin ‘Flutter’ is inCompatible

Hi Guys, Welcome to Proto Coders Point.

Ok, so recently I updated my Android Studio IDE version from 202.76.. to A.I-201.87.. and during updating process due to some network issue or any other reason.

The plugin which needs to be updated too such as dart, flutter, markdown, JetBrain marketPlace did not get updated due to which i faced an incompatible plugin version error as soon below.

  • Plugin Dart is incompatible (since build 202.766 > A.I-201.87433)
  • Plugin Flutter is incompatible (since build 202.766 > A.I-201.87433)
  • Plugin Gaugeis incompatible (since build 202.766 > A.I-201.87433)
  • Plugin JetBrains Marketplace is incompatible (since build 202.766 > A.I-201.87433)
  • PluginMarkdown is incompatible (since build 202.766 > A.I-201.87433)

Solution for incompatible plugin version

After some debugging, i found out 100% working solution & easy to do it.

You just need to update the incompatible plugin to latest version currently available.

Time needed: 1 minute

How to update plugins in android studio

  1. Go to File -> Setting

    A Setting window will get opened.

  2. Go to Plugins

    In the Setting window, go to the Plugins section on the left side of the window.

  3. Updated the Plugin

    Now, in the search box search for the plugin, you need to update or simply scroll down to find it.
    how to update plugin in android studio

  4. Restart the IDE

    Once you update all the plugin, it will ask you need to Restart IDE. Do it.
    Then the problem is solved successfully.

Error while merging dex archives – Solution 100% Working

0
error while merging dex archieve
enable multidex android

Hi Guys, Welcome to Proto Coders Point, In this tutorial, we will checkout & solve the common error that “error while merging dex archives”.

Video Tutorial to solve the same

The error says: DexArchiveMergerException

Cannot fit requested classes in a single file: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

so before looking into how to solve multi dex error, let’s learn basic about DEX(Dalvik Executable).

What is the dex file? Understanding Multidex in android

In Java, your code is converted from .java to .class file during compile time, so that our machine can understand the .class file but in android, the java code is compiled into DEX(Dalvik Executable) file so that our Android machine can understand it.

This article is for android/flutter developers who face DEX error “cannot fit requested classes in a single file: error while merging dex archieve“.

 error while merging dex archieve
error while merging dex archieve

The error itself says you, why you are facing “multi Dex error”, The number of methods references in a .dex file cannot exceed 64K (# 68563 > 65536).

A Single DEX file limits the number of methods referenced, A single DEX file is limited to 64K i.e. 65536, which simply means that you cannot create more than 65536 methods in a single DEX file(“cannot fit requested classes in a single file“).

usually, this DEX error occurs when a developer adds external android/flutter libraries,

So, sometimes by adding external libraries to your android/flutter projects, if your project merged app exceeds 65536 methods, than you will encounter a build error as mentioned above “error while merging dex archieve“.

Ways to enable multidex support in android studio project

Solution 1: Clean project and invalidate caches & restart

Once you add any external libraries in your android studio project always keep habit to clean project and invalidate cache restart.

Step 1: Menubar -> Build -> Clean Project then Rebuild project.

Step 2: Menubar -> Invalidate Caches/Restart.

Solution 2: Enable multidex for app over 64K methods

To enable multidex, if you are not using AndroidX, you need to add deprecated library in dependency

dependencies {
    implementation "com.android.support.multidex: 1.0.3 " //add this
    
}

By adding above multidex it will become a primary DEX file of your app.

if your minSdkVersion is set to 21 or higher, The Multidex is been enabled by default while creating new project, if not,

then do the followng steps:-

Step 1: modify Module level app/build.gradle

android {
    defaultConfig {
        applicationId "com.example.flutter_app_simple"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true //add this line
    }
}

dependencies {
    implementation "com.android.support.multidex: 1.0.3"  // add this line

}

Step 2: Add multidex in manifest <application> tag

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="androidx.multidex.MultiDexApplication" >  <!-- add this line -->
        ...
    </application>
</manifest>