setting up android studio to run flutter app

system: Ubuntu 20.04 LTS

So I’m trying to create an app using flutter and encountered a few issues trying to get a simple “Hello world” application running on my phone. Below are some of the issues I encountered and the solutions I found to eventually get my app working: 

Issue 1: build failure and accepting SDK license agreements

When I first ran my app via android studio I encountered the following build error:

“Failed to install the following Android SDK packages as some licences have not been accepted.”

Gradle, the build system, was complaining that it couldn’t install the required  SDK packages because the license agreements weren’t accepted. I couldn’t find a way to do this through the android studio UI so had to do so using the cmd line. But before this I ran the cmd:

flutter doctor 

To check if flutter was installed correctly and got the following results:

turns out it was using the wrong android sdk path. It should have use /usr/lib/Android/Sdk/ instead of /usr/lib/android-sdk so I set flutter to use the correct Sdk by running the cmd:

flutter config --android-sdk /usr/lib/Android/Sdk/

then ran the flutter doctor again and it worked.

At this point this may be enough to get your flutter app working and running on your phone. Keep reading if you want to follow my debug journey. 

Now that that was taken care of, I went to update the license for the Sdk manager by cd into /usr/lib/Android/Sdk/tools/bin and running 

./sdkmanager --licenses 

but I was then greeted with the following error message

turns out I didn’t have Java jdk installed. 


Trying to update the sdkmanager licenses using another version of Java results in the error:

“Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema ...”

if, like me, you already installed a version of java other than version 8 then install java 8 and in the file “/etc/environment” add the following lines:


Then log out and log back in to your system for the effects to take place 

if you then attempt again to update the license file using the above method it should work. 

issue 2: mismatched adb server version

After attempting to run the app again I was met with the adb server mismatch problem: 

to fix this I simply uninstalled and then reinstalled platform-tools located in the “SDK Tools” tab using the SDK manager on android studio (File -> Settings -> Appearance & Behavior ->System Settings-> Android SDK) followed by closing then reopening android studio. 

I was then able to successfully run my app on my phone

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s