Flutter, set android SDK path in ubuntu - android-studio

I was developing flutter apps from around 2 months everything worked perfectly fine, recently I don't remember what I changed in my .bashrc folder in ubuntu since then I am unable to run flutter projects. below is the flutter doctor -v info.
[✓] Flutter (Channel stable, v1.17.5, on Linux, locale en_IN)
• Flutter version 1.17.5 at /home/sai/flutter
• Framework revision 8af6b2f038 (7 weeks ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[!] Android toolchain - develop for Android devices
• Android SDK at /usr/lib/android-sdk
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
• ANDROID_HOME = /home/sai/Android/sdk
• ANDROID_SDK_ROOT = /home/sai/Android/sdk
✗ No valid Android SDK platforms found in /usr/lib/android-sdk/platforms. Directory was empty.
• Try re-installing or updating your Android SDK,
visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.
[✓] Android Studio (version 4.0)
• Android Studio at /home/sai/Softwares/android-studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.46.1)
• VS Code at /usr/share/code
• Flutter extension version 3.12.2
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
! Doctor found issues in 1 category.
Below is my .bashrc code
export PATH="$PATH:/home/sai/flutter/bin"
export PATH="$PATH:/home/sai/flutter/bin/cache/dart-sdk/bin"
export PATH="$PATH:/usr/lib/dart/bin"
export PATH=~/.flutterSetup/bin:$PATH
export ANDROID_HOME=/home/sai/Android/sdk
export ANDROID_SDK_ROOT=/home/sai/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools
after replacing the above code with
export PATH="$PATH:/home/sai/flutter/bin"
export PATH="$PATH:/home/sai/flutter/bin/cache/dart-sdk/bin"
export PATH="$PATH:/usr/lib/dart/bin"
export PATH=~/.flutterSetup/bin:$PATH
export ANDROID_HOME = "$PATH:/usr/lib/android-sdk"
export ANDROID_SDK_ROOT = "$PATH:/usr/lib/android-sdk"
export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools
This error is showed in the android studio terminal, while flutter doctor -v remained the same.
bash: export: `=': not a valid identifier
bash: export: `/home/sai/.flutterSetup/bin:/home/sai/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/dart/bin:/home/sai/flutter/bin:/home/sai/flutter/bin/cache/dart-sdk/bin:/usr/lib/dart/bin:/usr/lib/android-sdk': not a valid identifier
bash: export: `=': not a valid identifier
bash: export: `/home/sai/.flutterSetup/bin:/home/sai/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/dart/bin:/home/sai/flutter/bin:/home/sai/flutter/bin/cache/dart-sdk/bin:/usr/lib/dart/bin:/usr/lib/android-sdk': not a valid identifier

shell variable assignment must not have any space around = character. From your new .bashrc it have space around = character. Your old .bashrc doesn't, that's why it works fine.

Related

Android Studio does not find cocoapods in console

Somehow Android Studio does not find cocoapods, even though it is correctly installed in the system via brew install coocapods. The Android Studio console looks like it doesn't get the correct PATH.
Note: Starting Android Studio through a terminal / iTerm with
open /Applications/Android\ Studio.app
does mitigate the issue, Android Studio then somehow gets the right path. But im wondering how i can archieve the same result for a start directly from the application directory / spotlight-search? Why does Android Studio not resolve the right PATH?
Android Studio Version 2021.1.1, macOS
Console output after click on "Flutter doctor":
/Users/[...]/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale de-DE)
• Flutter version 2.8.1 at /Users/[...]/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/[...]/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
...
Starting a terminal in Android Studio or starting iTerm, output:
flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale de-DE)
• Flutter version 2.8.1 at /Users/[...]/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/[...]/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
...
Fixed in Android Studio Bumblebee 2021.1.1.1.21 Patch 1 for Mac.
I just installed the latest ANDROID STUDIO Bumblebee 2021.1.1.1.21 Patch 1 for Mac Intel. I loaded an older FLUTTER app into it and ran, (from the run arrow in the IDE), it against an iPhone 8 Simulator device. The CocoaPods error did NOT appear and the app launched in the Simulator device. It seems to me that this update has fixed that error.
#scrimau wrote the best description of this issue.
Here's some further info:
echo $PATH (using Android Studio's Terminal) produces different results depending on which of the two methods is used to start Android Studio.
The same directories appear in both echo $PATH results, but the directories are shuffled around.
It almost seems like the sequence of directories (as shown by echo $PATH) might have something to do with the different behaviors.
(Sorry: This should have been a comment. I can't find a way to change an answer to a comment. I'll be more careful next time.)
Android Studio Bumblebee 2021.1.1.1.21 Patch 1 seems to have fixed this issue. In the release notes there is a similar issue mentioned:
Issue #216364005: Env variables not sourced when launched from Mac OS X to Monterey Dock

How make a portable Intellij IDEA Ultimate be recognised by Flutter Doctor?

I used to have a portable development environment. Where I have a IntelliJ IDEA Ultimate installed in a External SSD Drive (https://portapps.io/app/intellij-idea-ultimate-portable/). I'm starting to code in Flutter and I having this issue.
When I run "flutter doctor -v", the flutter doesn't recognise the portable version (and I understand, because is not in the default directory).
The question is, how to make flutter doctor recognise this external installation (from zip file)?
I have everything configured correctly, here is my current "flutter doctor -v" output:
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-GB)
• Flutter version 1.17.5 at Z:\SDK\Flutter
• Framework revision 8af6b2f038 (10 days ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at Z:\SDK\Android
• Platform android-30, build-tools 30.0.1
• ANDROID_HOME = Z:\SDK\Android
• Java binary at: Z:\SDK\OpenJDK\bin\java
• Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
• All Android licenses accepted.
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
You're free to use IntelliJ (or any other IDE) for flutter development, but it won't satisfy the checks made by flutter doctor. It's looking specifically for Android Studio. If you want to use IntelliJ then you have to live with flutter doctor's warnings about Android Studio not being installed.
If you want to use a portable version of Android Studio then use the command
flutter config --android-studio-dir "Z:\MyPortableApps\AndroidStudio"
with the path to your portable application.
If you want to see what has been configured then just use flutter config without any parameters. The output starts with a load of usage text but at the end you'll find a section with the heading Settings: listing anything that has been set. A new install won't have anything set and will just use defaults.
To later unset a value use a quoted empty string "" in the same command.

Android Studio do not sees a Chrome device

I am using a Flutter SDK for building a web application.
In these latter days i am trying to working on Linux, and i ran into a problem: Android Studio do not sees a Chrome in device list.
You can say what Flutter SDK is not properly configured, but no - Flutter seed a chrome device, and also Flutter can run a application in chrome via flutter run -d chrome command.
Has anyone encountered a same problem?
Flutter doctor output:
[urusai#mikhail-pc ka4alka-voting]$ flutter doctor -v
[✓] Flutter (Channel beta, v1.14.6, on Linux, locale ru_RU.UTF-8)
• Flutter version 1.14.6 at /usr/lib/flutter
• Framework revision fabeb2a16f (4 недели назад), 2020-01-28 07:56:51 -0800
• Engine revision c4229bfbba
• Dart version 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /home/urusai/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.3
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = /opt/google/chrome/google-chrome
[✓] Android Studio (version 3.6)
• Android Studio at /opt/android-studio
• Flutter plugin version 43.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (2 available)
• Chrome • chrome • web-javascript • Google Chrome 80.0.3987.122
• Web Server • web-server • web-javascript • Flutter Tools
• No issues found!
Try launch Android studio via terminal.
if it the case, that Chrome(web) device is shown only when u run it via terminal. This means if u can copy your bash ~/.bashrc environment variable to user wide variable ~/.profile it can be fixed.
Try set up your environment variable in ~/.profile so it the same in ~/.bashrc

Flutter Finished with error: ProcessException: Permission denied

I want to run my frist app with flutter but I got the following error :
Launching lib/main.dart on Android SDK built for x86 64 in debug mode.
Initializing gradle.
Resolving dependencies.
Finished with error shown below:
ProcessException: Permission denied Command:
/home/abdoul-razak/Android/Sdk/build-tools/28.0.3/aapt dump xmltree
/home/abdoul-razak/Projects/akoybiz/build/app/outputs/apk/app.apk
AndroidManifest.xml
here is the result of flutter doctor:
abdoul-razak#Komche:~/Projects/akoybiz$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Linux, locale fr_FR.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
✗ Android license status unknown.
[✓] Android Studio (version 3.0)
[✓] VS Code (version 1.30.2)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
after updating the sdk android here is the result of flutter doctor -v
abdoul-razak#Komche:~/Projects/akoybiz$ flutter doctor -v
[✓] Flutter (Channel stable, v1.0.0, on Linux, locale fr_FR.UTF-8)
• Flutter version 1.0.0 at /home/abdoul-razak/flutter
• Framework revision 5391447fae (il y a 9 semaines), 2018-11-29 19:41:26
-0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /home/abdoul-razak/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /home/abdoul-razak/Android/Sdk
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.0)
• Android Studio at /opt/android-studio
• Flutter plugin version 23.2.1
• Dart plugin version 171.4424
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[✓] VS Code (version 1.30.2)
• VS Code at /usr/share/code
• Flutter extension version 2.22.2
[✓] Connected device (1 available)
• itel P31 • 45YP8LSO4T7HWCLZ • android-arm • Android 7.0 (API 24)
• No issues found!
The issue is related to your Android SDK licenses. Run the command
flutter doctor --android-licenses
Then press y until it acquires all permissions.
xattr -d com.apple.quarantine ./gradlew
By using this command it solves the issue. I don't know the exact reason but it worked for me.
I stumbled across the same exception. And something fixed it, but I do not know what exactly.
The exception says something different but I think it has something to do where flutter is installed. I reinstalled it again like suggested on their website and it worked...
cd ~/development
tar xf ~/Downloads/flutter_linux_v1.7.8+hotfix.4-stable.tar.xz
Edit: Make sure you use a local folder for your flutter project too.

Flutter SDK is not found in the specified location - in Android Studio

I am installing Flutter and everything is good except one thing, specified above.
Flutter doctor says this:
$ flutter doctor -v
[√] Flutter (Channel beta, v0.7.3, on Microsoft Windows [Version 10.0.17134.228], locale nl-NL)
• Flutter version 0.7.3 at C:\Flutter\flutter_windows_new\flutter
• Framework revision 3b309bda07 (13 days ago), 2018-08-28 12:39:24 -0700
• Engine revision af42b6dc95
• Dart version 2.1.0-dev.1.0.flutter-ccb16f7282
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\iwijsman\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 27.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 28.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[√] IntelliJ IDEA Community Edition (version 2018.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.2
• Flutter plugin version 28.0.4
• Dart plugin version 182.4323.44
[√] Connected devices (1 available)
• Pixel 2 • FA83P1A01724 • android-arm64 • Android 9 (API 28)
• No issues found!
I've added the requested path to variables and in Android studio, the plugins are installed and applied but I still get this error.
please help me, where am I going wrong?
The same problem faced me, but trying the above solution was not helpful. So I tried another thing:
Open File
Select settings from the File menu
Select Languages & frameworks from the left panel
Select Flutter
Then from the right panel choose the location of your flutter SDK
The location of flutter SDK is where you copied or cloned the code. In my case it was like the following:
If the specified location contains the flutter SDK, the version section will contain your flutter version. If not, the version section will not contain any versions and there will be a message in the bottom of the setting dialog saying:
Flutter SDK Is Not Found In The Specified Location
Hope this helps.
The path to the SDK should be to the main Flutter folder (e.g. C:\src\flutter and not to the bin folder as set in the Environment Variable Path.
As mentioned in the message it is optional and only used for specific tasks.
You can install it from Android Studio
Menu > Tools > SDK Manager > Android SDK (left side of the dialog) > SDK Tools (tab)
Ensure that this line is enabled
With [OK] it should be installed.
create an android project and see everything works fine.
if Gradle sync problem with kotline : File -> Settings -> Kotlin Compiler -> Target JVM Version Changing to 1.8 fixed the issue.
If everything run fine as android project then proced:
File -> Settings ->Languages & frameworks->Flutter.
select flutter sdk path as src\flutter and ok
if step 4 not works then select path src\flutter\bin;
Note:if android 10.0 not work then try it with 9.0;
Flutter folder put on dekstop and try to again to set flutter sdk path
check this also..
https://flutter.dev/docs/get-started/install/windows
You need to correctly specify the path of the Flutter installation. To find the path, run in your command line:
flutter doctor -v
The second line of the output should be the path:
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19041.488], locale en-US)
--- THIS LINE CONTAINS THE PATH---
• Flutter version 2.0.6 at C:\src\flutter\flutter_windows_2.0.6-stable\flutter
• Framework revision 1d9032c7e1 (6 days ago), 2021-04-29 17:37:58 -0700
• Engine revision 05e680e202
...
Enter the path into Android Studio.

Resources