/Flutter_Connect_Mobile_lesson2

How to connect your mobile with your laptop for debugging a Flutter application

How to connect your mobile phone to your laptop for debugging a Flutter application

https://developer.android.com/tools/adb#wireless-adb-android-11

To install and set up Android Debug Bridge (adb) for debugging a Flutter application on your mobile phone, follow these steps:

1. Step 1: Install Android Studio

Download and Install Android Studio: Download Android Studio from the official Android developer website

https://developer.android.com/studio

image

Install Android SDK: During the installation, ensure that the Android SDK is installed

We press in the three dots button and we select the option SDK Manager

image

We have to select the SDK Tools tab and then install Android SDK Command-Line Tools

image

2. Step 2: Set Up adb

Open Android Studio:

Launch Android Studio and go to the SDK Manager

Navigate to Configure > SDK Manager

Install SDK Platform Tools:

In the SDK Manager, go to the SDK Tools tab

Check the box for Android SDK Platform-Tools

image

Click OK to install the package

3. Step 3: Add adb to System PATH

Find adb Location:

The adb executable is located in the platform-tools directory inside the Android SDK directory

Common default paths:

Windows: C:\Users<Your-Username>\AppData\Local\Android\Sdk\platform-tools

macOS: ~/Library/Android/sdk/platform-tools

Linux: ~/Android/Sdk/platform-tools

Add to PATH:

Windows:

Open Control Panel > System and Security > System > Advanced system settings

Click on Environment Variables

Under System variables, find the Path variable, and click Edit

Click New and add the path to the platform-tools directory

Click OK to save the changes

C:\Users\luisc\AppData\Local\Android\Sdk\platform-tools

image

4. Step 4: Enable USB Debugging on Your Mobile Phone

We first press the Settings button

image

We select the menu option Settings/About the Phone

image

Then we select the option Software Information

image

For enabling the Develper options we have to tap on the Build Number sevent times:

image

We enter the Mobile device password if required

image

We receive a message Developer mode has been turned on

image

Now we can verify the Developer options are available in our mobile phone:

image

We can Enable USB Debugging:

Go to Settings > System > Developer options

Enable USB debugging

image

We also have to connect the Mobile to the Laptop with an USB wire

image

We can also revoke the USB debugging authorization for detecting the mobile phone

image

And then accept the message in your mobile phone to authorize to connect the mobile to the laptop

5. Step 5: Verify adb Installation

Connect Your Phone:

Connect your Android phone to your computer using a USB cable

Verify adb Connection:

Open a terminal (Command Prompt on Windows, Terminal on macOS/Linux)

Run the following command:

adb devices

You should see your device listed. If prompted on your phone, authorize the connection

image

6. Step 6: Debug Flutter Application

Open your Flutter project

Run the Flutter application:

In the terminal, navigate to your Flutter project directory

Run the following command to start debugging on your connected device:

flutter run

We click on the new flutter application icon in our mobile device to run it

image

image

Your Flutter application should now be running on your mobile phone, and you can use adb for debugging purposes