Flutter - Tutorial 001. Hello world

Android, Flutter, Hello World

Flutter is a fresh framework from Google for application development for Android and iOS. The programming language used is Dart (also developed by Google).

Let's understand the launch of our first application on Flutter.

To create our first application that will run under Android, you need to install all the necessary components. The installation of these components will be done in the Ubuntu Linux OS.

Download Flutter

In the official documentation, it is first proposed to download Flutter itself, and then unpack it.

cd ~/development
tar xf ~/Downloads/flutter_linux_v1.0.0-stable.tar.xz

Check for required components.

Further they propose to add the flutter utility on the way so that you can run a diagnostics of the presence of all necessary components in the system.

export PATH=$PATH:`pwd`/flutter/bin

Then the utility flutter doctor is launched, which will show whether all the components are in the system

[-] Android toolchain - develop for Android devices
    • Android SDK at /Users/obiwan/Library/Android/sdk
    ✗ Android SDK is missing command line tools; download from https://goo.gl/XxQghQ
    • Try re-installing or updating your Android SDK,
      visit https://flutter.io/setup/#android-setup for detailed instructions.

Specify paths to the Flutter SDK

First of all, they suggest indicating the paths to the Flutter SDK. For this you need:

  1. Find the directory where flutter was placed. If you followed the instructions, the path should look like this.
    /home/user/development/flutter/bin
  2. Open or create file
    $HOME/.bash_profile
  3. Add the path to the flutter sdk to this file
    export PATH=$PATH:/home/user/development/flutter/bin
  4. Update bash environment
    source $HOME/.bash_profile
  5. You can check that the path is added.
    echo $PATH

Install Android Studio

Since this is a configuration guide for Linux, you can use the installation of Android Studio through the snap system packages. It really is easier.

sudo snap install android-studio --classic

I’ll skip the default Android Studio setting, for example, setting a color scheme. Since the most important point is to install plugins for working with Dart and Flutter.

Android Studio Settings

Find these parameters in the settings File -> Settings

Android Studio Settings

Dart Plugin

Dart plugin

Flutter Plugin

Flutter plugin

Acceptance of licenses

You will need to run flutter foctor --android-licenses again to comply with all licenses.

Start a new Flutter project

After that you will be able to create Flutter project Start a new Flutter project

Start a new Flutter project

Select Flutter application

Flutter application

Specify Flutter SDK

Specify the domain of the company

After which a Flutter project will be created.

Pay attention to the project structure. External Libraries must have all the necessary components:

  1. Dart Packages
  2. Dart SDK
  3. Flutter for Android

If some of the items are not available, then you may need to either reinstall Flutter or correctly configure the paths in the IDE settings.

Dart Settings

Настройка Dart

Flutter Settings

Настройка Flutter

Connecting Android Smartphone

Next, connect a smartphone to your Android computer to perform the last item on the required components. You can certainly use an emulator, but personally I prefer a live device. In the end, Android smartphone in this case should be at hand.

And check that everything is in order through the flutter doctor.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Linux, locale C.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] Android Studio (version 3.2)
[✓] Connected device (1 available)

• No issues found!

Conclusion

After assembling and installing apk on a smartphone, you will see such an application.

Virtual hosting with 10 percent discount
Virtual hosting with 10 percent discount
EVILEG offers reliable hosting with a 10% discount for virtual hosting and 5% for VPS
Support the author Donate

Доброго времени суток. В Андроид разработке новичек, посему будут вовросы.
Делал все по статье. Но получил следующую картину

rust@Leap15:~/Android/Sdk/tools/bin> flutter doctor -v
[✓] Flutter (Channel stable, v1.0.0, on Linux, locale ru_RU.UTF-8)
    • Flutter version 1.0.0 at /home/rust/develop/flutter
    • Framework revision 5391447fae (6 недель назад), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

⣾Error retrieving device properties for ro.product.cpu.abi:
error: insufficient permissions for device
See [http://developer.android.com/tools/device.html] for more information


[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /home/rust/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    ✗ Android license status unknown.

[✓] Android Studio (version 3.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (1 available)
    • 612HKBR8272WZ • 612HKBR8272WZ • android-arm • Android null (API null)

! Doctor found issues in 1 category.

При попытке обновить лицензии выдает следующе

rust@Leap15:~/Android/Sdk/tools/bin> /home/rust/Android/Sdk/tools/bin/sdkmanager --update
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
        ... 5 more

Подскажите в какую сторону копать.....

Добрый день!

Саму Android Studio запускали? она должна скачать нужные SDK самостоятельно при первом старте. Либо запустите Android-Studio и посмотрите, что может выдать SDK Manager. То есть сделайте без консольных утилит это.

Я поэтому из snap устанавливал, там уже всё нормально настроено.

Comments

Only authorized users can post comments.
Please, Log in or Sign up
G
July 24, 2019, 4:20 a.m.
G0tzef

C++ - Test 005. Structures and Classes

  • Result:66points,
  • Rating points-1
VK
July 24, 2019, 3:49 a.m.
Viktoriia Komarova

C++ - Test 001. The first program and data types

  • Result:40points,
  • Rating points-8
G
July 24, 2019, 3:25 a.m.
G0tzef

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
Last comments
July 23, 2019, 12:14 p.m.
IscanderChe

Вот ссылка: https://github.com/iscander-che/TestReportViewer .
July 23, 2019, 5:42 a.m.
Evgenij Legotskoj

Хорошо, хотя конечно это С, а не С++ )))) Но если вдруг будут проблемы, то решение через класс со статическими переменными вы видели ))
July 23, 2019, 5:33 a.m.
IscanderChe

"Не потребует каждый раз объявлять extern в других файлах". И так не требует. У меня в тестовом классе эти переменные используются без дополнительного объявления. Так же объявил их в cpp-файле о…
July 23, 2019, 5:28 a.m.
IscanderChe

В репозиторий могу сегодня вечером выложить. "Или ее надо компилить самому под дистриб?" Тут я не совсем понимаю, что вы имеете ввиду. Я выложу в репозиторий исходный код утилиты, и всё.
July 23, 2019, 4:32 a.m.
Evgenij Legotskoj

Есть комментарий по вашему коду. Лучше бы вместо глобальных переменных в стиле Си, то есть с использоавнием extern, написали бы статические переменные в рамках класса. IMHO - это будет выглядеть…
Now discuss on the forum
July 24, 2019, 4:57 a.m.
Mihailll

Это не помогает. Ниже мой код Rectangle{ //Flickable { //contentX: 100 id: rectangleForListView y: parent.height * 0.15 height: parent.height * 0.…
July 24, 2019, 3:17 a.m.
Evgenij Legotskoj

Ну вот теперь я несколько в ступоре. Запустите из консоли проект и посмотрите тогда, на что ругается. Также, следовало бы посмотреть в настройках самой виртуальной машины, что по поддержке OpenG…
July 23, 2019, 8:20 a.m.
Mihailll

Так работает QFile f1(dbAdress); f1.setPermissions(QFileDevice::WriteOther);
July 23, 2019, 7:11 a.m.
Pavel K.

Советую использовать нечто такое или такое
July 22, 2019, 10:50 a.m.
Pavel K.

Благодарю.Буду пробовать.
Looking for a Job?
5,000.00 руб. - 15,000.00 руб.
Дизайнер
Moskovskiy, Moscow, Russia
25,000.00 руб. - 30,000.00 руб.
Разработчик Qt/C++
Barnaul, Altai Krai, Russia

For registered users on the site there is a minimum amount of advertising

EVILEG
About
Services
Join us
© EVILEG 2015-2019
Recommend hosting TIMEWEB