Android studio dart sdk

IntelliJ & Android Studio

The Dart plugin adds Dart support to JetBrains IDEs such as IntelliJ IDEA and Android Studio. IntelliJ IDEA is an intelligent Java IDE with support for many other languages and frameworks. Android Studio is an IDE based on IntelliJ IDEA that’s used for Android and Flutter development.

Whichever JetBrains IDE you choose for Dart development, this page has resources to help you get started quickly and find more information when you need it.

Note: WebStorm, a JetBrains IDE for client-side development, comes with the Dart plugin pre-installed.

Getting started

If you don’t already have the IDE and the Dart SDK, get them. Then install the Dart plugin and tell it where to find the Dart SDK.

Downloading the IDE

Install a JetBrains IDE if you don’t already have one. Choose one:

Note: The Community Edition of IntelliJ IDEA has limited functionality. For example, it doesn’t directly support debugging web apps. It also has very little support for JavaScript, HTML, CSS, and YAML.

Downloading the Dart SDK

If you don’t already have the Dart SDK, install it. You can get it either by itself or by downloading the Flutter SDK, which (as of Flutter 1.21) includes the full Dart SDK.

Configuring Dart support

Here’s one way to configure Dart support:

Start the IDE, and install the Dart plugin.

  1. From the Welcome screen, choose Plugins.
  2. Search for Dart.
  3. Once you’ve installed the Dart plugin, restart the IDE.

Create a new Dart project:

  1. From the Welcome screen, click New Project.
  2. In the next dialog, click Dart.

If you don’t see a value for the Dart SDK path, enter it.

For example, the SDK path might be /dart/dart-sdk .

Note: The Dart SDK specifies the directory that contains the SDK’s bin and lib directories; the bin directory contains tools such as dart and dartdoc . The IDE ensures that the path is valid.

Choose a starting template.

  1. To enable starting templates, click Generate sample content.
  2. Pick your desired template.

The provided templates are supplied and created by dart create .

Click Next and continue project setup.

An alternative to Step 2 is to open an existing Dart project, and then open its pubspec.yaml file or any of its Dart files.

Reporting issues

Please report issues and feedback via the official JetBrains issue tracker for Dart.

Include details of the expected behavior, the actual behavior, and screenshots if appropriate.

More information

See the JetBrains website for more information.

Источник

Get the Dart SDK

This page describes how to download the Dart SDK. The Dart SDK has the libraries and command-line tools that you need to develop Dart command-line, server, and non-Flutter web apps. For details, see the Dart SDK overview.

As of Flutter 1.21, the Flutter SDK includes the full Dart SDK. So if you have Flutter installed, you might not need to explicitly download the Dart SDK. Consider downloading the Dart SDK if any of the following are true:

  • You don’t use Flutter.
  • You use a pre-1.21 version of Flutter.
  • You want to reduce disk space requirements or download time, and your use case doesn’t require Flutter. For example, you might have a continuous integration (CI) setup that requires Dart but not Flutter.

Installing the Dart SDK

As the following instructions show, you can use a package manager to easily install and update a stable channel Dart SDK. Alternatively, you can build the SDK from source, grab a Dart Docker image, or install from any release channel by downloading the SDK as a zip file.

Читайте также:  Android phone backup softwares

Dart tools may send usage metrics and crash reports to Google. By downloading the Dart SDK, you agree to the Google Terms of Service. Note: The Google Privacy Policy describes how data is handled in this service.

To control the submission of metrics, use the following options on the dart tool:

  • —enable-analytics : Enables anonymous analytics.
  • —disable-analytics : Disables anonymous analytics.
  • Windows
  • Linux
  • macOS

You can install the Dart SDK using Chocolatey.

Important: These commands require administrator rights. Here’s one way to open a Command Prompt window that has admin rights:

  1. Press Windows+R to open the Run window.
  2. Type cmd into the box.
  3. Press Ctrl+Shift+Enter .

To install the Dart SDK:

To upgrade the Dart SDK:

By default, the SDK is installed at C:\tools\dart-sdk . You can change that location by setting the ChocolateyToolsLocation environment variable to your chosen installation directory.

If you can’t use the Dart SDK executables, add the SDK location to your PATH:

  1. In the Windows search box, type env .
  2. Click Edit the system environment variables.
  3. Click Environment Variables….
  4. In the user variable section, select Path and click Edit….
  5. Click New, and enter the path to the dart-sdk directory.
  6. In each window that you just opened, click Apply or OK to dismiss it and apply the path change.

If you’re using Debian/Ubuntu on AMD64 (64-bit Intel), you can choose one of the following options, both of which can update the SDK automatically when new versions are released.

Install using apt-get

Perform the following one-time setup:

Then install the Dart SDK:

Install a Debian package

Alternatively, download Dart SDK as a Debian package in the .deb package format.

Modify PATH for access to all Dart binaries

After installing the SDK, add its bin directory to your PATH . For example, use the following command to change PATH in your active terminal session:

To change the PATH for future terminal sessions, use a command like this:

Install Homebrew, and then run the following commands:

Important: Make sure the Homebrew bin directory is in your PATH . Setting up the path correctly makes it easier to use Dart SDK commands such as dart and dart format . For help setting up your path, consult the Homebrew FAQ.

To upgrade when a new release of Dart is available:

To switch between locally installed Dart releases, use brew switch dart . Example:

Version note: The brew switch command was removed after the 2.6 release of Homebrew. To continue using brew switch , downgrade Homebrew to a 2.6 version:

To see which versions of Dart you’ve installed:

System requirements

The Dart SDK is supported on Windows, Linux, and macOS.

Windows

  • Supported versions: Windows 10.
  • Supported architectures: x64, ia32.

Linux

  • Supported versions:Debian stable and Ubuntu LTS under standard support.
  • Supported architectures: x64, ia32, arm, arm64.

Note: The arm support requires glibc 2.23 or newer due to a dynamic linker bug.

macOS

  • Supported versions: Latest three major versions. As of November 2021, the following versions are supported:
    • macOS 10.15 (Catalina)
    • macOS 11 (Big Sur)
    • macOS 12 (Monterey)
  • Supported architectures: x64, arm64.

About release channels and version strings

The Dart SDK has three release channels:

Stable channel: stable releases, updated roughly every three months; currently [calculating] .

Stable releases are suitable for production use.

Beta channel: preview releases, usually updated every month; currently [calculating] .

Beta channel builds are preview builds for the stable channel. We recommend testing, but not releasing, your apps against beta to preview new features or test compatibility with future releases.

Dev channel: prereleases, usually updated twice a week; currently [calculating] .

Dev channel releases are the most current with latest changes, may be broken, are unsupported, and may contain unvetted breaking changes.

Читайте также:  Mojo аналог для андроид

Stable channel releases of the Dart SDK have x.y.z version strings like 1.24.3 and 2.1.0 . They consist of dot-separated integers, with no hyphens or letters, where x is the major version, y is the minor version, and z is the patch version.

Beta and dev channel releases of the Dart SDK (non-stable releases) have x.y.z-a.b. versions like 2.8.0-20.11.beta . The part before the hyphen follows the stable version scheme, a and b after the hyphen are the prerelease and prerelease patch versions, and beta or dev is the channel.

You can get stable channel releases using the instructions above, or you can get stable, beta, or dev channel releases using a package manager or Dart Docker image, or by downloading the SDK as a zip file.

Источник

Android studio dart sdk

Copy raw contents

It is possible to build and run the standalone Dart VM for Android devices. This setup is not yet thoroughly tested, but is available for experimentation.

  • The host (build) machine must be an x86 Linux machine.
  • The target (Android) device must be a device or emulator that supports the Android NDK.
  • The resulting Android Dart VM can only be run from the Android command line.
  • The resulting Android Dart VM only has access to dart:core APIs. It does not have access to the Android C or Java APIs.
  • The Android-related tools and emulator image files will take about 2GB of disk space on the host machine.

Download and install the Dart source tree using the standard instructions for building Dart.

Use a text editor to add the following line to the very bottom of your Dart .gclient file (which is located in the directory that contains the main ‘dart’ directory):

Run gclient sync to install the Android NDK and SDK. This may take 10 minutes or more depending upon the speed of your Internet connection

Building for Android

Once you’ve set up your build tree, you can build the Dart VM for Android by using the standard Dart build script with the addition of the —os android build flag:

$ tools/build.py —arch=arm,arm64,ia32,x64 —os=android runtime

Testing the result

Adding “adb” to your path

For convenience, add the path to the adb tool to your shell PATH:

Starting an Android emulator

You can start an emulator running, by using the android_finder.py script:

$ runtime/tools/android_finder.py -a -b

The -a flag says to find an Android device for the specified architecture. The -b flag says to start (or bootstrap) a new emulator if no existing emulator or device with a given ABI can be found. This script could take up to 20 seconds to run if a new emulator needs to be started.

Running the Dart VM on an Android emulator

Once you have finished building the Android Dart VM and have a running Android emulator, you can run Dart scripts on the emulator as follows:

Create a directory on the Android emulator.

$ adb shell mkdir /data/local/tmp/dart

Copy the Dart VM executable to the Android emulator:

$ adb push out/android/ReleaseAndroid/dart /data/local/tmp/dart/dart

Create a simple Dart test script:

Copy the Dart test script to the Android emulator:

$ adb push hello.dart /data/local/tmp/dart

Run the Dart VM with the test script:

$ adb shell /data/local/tmp/dart/dart /data/local/tmp/dart/hello.dart

Stopping an Android Emulator

You can list all currently attached Android devices, including emulators, using the adb command:

You can stop a running emulator using the adb emu kill command:

$ adb emu kill ← if there is just one emulator running

$ adb -s emulator-name emu kill ← if there is more than one emulator running

Running the Dart VM on an Android device

First, make sure that the «USB Debugging» mode is enabled by navigating to Settings > Developer options > USB debugging. The box should be checked. You may need to have root on the device.

Читайте также:  Android terminal root access

Now, plug in your device. Then, run:

There should be an entry for your device, such as:

Now, you can copy dart and hello.dart to the device as above. If an emulator is also running, be sure to give adb the -d switch to tell it to use the attached device instead of the emulator. Use the -s switch to give the device ID explicitly.

The only effect of the “target_os” line in the Dart .gclient configuration file is to install the Android tools. Despite what the name “target_os” implies, the target_os line does not affect which OS is targeted. Therefore, once you’ve installed the Android tools you can (and should) leave the target_os = [“android”] line in place even when switching back and forth between building for Android and building for Linux.

Источник

Flutter SDK and/or Dart SDK settings keep changing while Android Studio is running #3307

Comments

Stargator commented Mar 20, 2019

Thanks for the feedback! If your issue is related to the Flutter framework itself,
please open an issue at
github.com/flutter/flutter.

Steps to Reproduce

  1. Running Android Studio on Mac
  2. Change Dart SDK from flutter installed version to Homebrew installed 2.2.0. Click Apply and then OK.
  3. After some time, maybe restart the IDE, notice that the skip parameter for a test method is not recognized as defined.
  4. I will go to the settings and see that either the Dart SDK reverts back to the version used by flutter and/or the Flutter SDK is set as empty or undefined.

Manually changing the Dart SDK back to the version used by flutter may not correct the issue seen in the IDE. Going back to the setting, the Flutter SDK may have been changed by the IDE/plugin or the Dart SDK is re-set to the non-flutter installed version.

It’s very hard to understand the logic. For the Dart SDK, I may even set it to look for updates on the Stable channel only and even that would get undone when the Dart SDK gets auto changed.

Look at the following screenshots (look at the time stamps to see how quickly the settings change on their own.

  • at 6:12:18 PM I changed the Flutter SDK

  • at 6:12:43 PM, noticed it had no impact and the IDE still reported the same issue ( skip not defined)

  • at 6:12:51 PM — Flutter remains unchanged

  • at 6:12:59 PM — The Dart SDK setting changed with no user input

  • at 6:13:27 PM — Flutter is set as empty/undefined with no user input

Version info

flutter doctor —verbose
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.3 18D109, locale en-US)
• Flutter version 1.2.1 at /Users/User/flutter
• Framework revision 8661d8aecd (5 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[✓] Android toolchain — develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/User/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.

[✓] iOS toolchain — develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.6.1

[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 33.4.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 30.0.2
• Dart plugin version 183.5912.23

[!] Connected device
! No devices available

! Doctor found issues in 1 category.
Process finished with exit code 0

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью