-1

Never really used a piece of software that threw so many errors. I installed and got all the errors below so tried a fresh install, following a reinstall process to remove it completely, even including the SDKs but installing it again threw the exact same errors. From what I read it should just work after the basic install?

First error on opening it for the first time:

unable to access android sdk add on list

Even though right after installing I added it and approved it in my firewall.

Then during install it says HAXM failed to install, and it gives a link to install it which is a page not found. Then I found in the SDK Manager under tools it shows Intel x86 Emulator Accelerator (HAXM installer) 7.3.2 - Installed. From what I read that means it IS installed?

I'm using MacOS High Sierra and supposedly going to System Preferences > Security & Privacy and opting to allow this particular app should fix it, but since I already have it set to allow any apps that clearly doesn't fix it for me.

Then I added the Flutter plugin, created the default app and launched it and I got the error:

* Error running Gradle:
ProcessException: Process "/Users/hasen/AndroidStudioProjects/testing_app/android/gradlew" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in /usr/local/Cellar/android-sdk/24.4.1_1/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in /usr/local/Cellar/android-sdk/24.4.1_1/licenses
Warning: License for package Android SDK Platform 28 not accepted.

Picked up _JAVA_OPTIONS: -Xverify:none

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/hasen/AndroidStudioProjects/testing_app/android/build.gradle' line: 24

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Failed to install the following Android SDK packages as some licences have not been accepted.
        build-tools;28.0.3 Android SDK Build-Tools 28.0.3
        platforms;android-28 Android SDK Platform 28
     To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
     Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

     Using Android SDK: /usr/local/Cellar/android-sdk/24.4.1_1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
  Command: /Users/hasen/AndroidStudioProjects/testing_app/android/gradlew app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

It says in this error output that I need to accept the SDK licence agreements but not sure how or why that needs to be done. The tutorials I followed didn't need to do any of this...not sure why it's so weird.

EDIT: Marked in error as a duplicate. It's not a duplicate because the solution from 3 years back does not work for me and I have two other errors which are not mentioned at all in the duplicate question.

In addition the solution to my problem was to remove the second installation of the Android SDK that was installed by Homebrew. None of this is mentioned in the supposed question this is a 'duplicate' of.

Hasen
  • 11,710
  • 23
  • 77
  • 135
  • @Lakhwinder Singh That question you linked to itself is a duplicate and with no accepted answer either. It's also 3 years old. Not to mention that in my case it is a FRESH install and shouldn't need such methods to fix it. My question is why doesn't it work right after a fresh install. That also only refers to only **one** of the errors I encountered... – Hasen Jul 01 '19 at 11:37
  • https://stackoverflow.com/a/45782695/2219208 – Lakhwinder Singh Jul 01 '19 at 11:39
  • @Lakhwinder Singh Tried `yes | sudo ~/Library/Android/sdk/tools/bin/sdkmanager --licenses` and it doesn't work, it still throws the same error as above. Possibly due to the other errors I listed. – Hasen Jul 01 '19 at 11:43
  • It says `To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager` but I can't find how to do that... – Hasen Jul 01 '19 at 11:47
  • @Lakhwinder Singh Can you please remove your duplicate mark because 1. the solution in the question you linked to from 3 years ago does not work. It returns `Warning: File /var/root/.android/repositories.cfg could not be loaded. All SDK package licenses accepted.======] 100% Computing updates...` I even tried running it again, rebooting but it does not fix the error at all. 2. It has nothing about the HAXM problem I have and also nothing about `unable to access android sdk add on list` error. – Hasen Jul 01 '19 at 12:04
  • `Never really used a piece of software that threw so many errors. ` it seems like you've never used Xcode then... anyway... since you're so mad at Android Studio, I'm going to ask you a simple question (no I didn't read all your rant because you're not asking a question, you're mad that what you want to do doesn't work and your words reflect it), so... did you ever install Android Studio on a Mac before? What is your experience with Bash (default macOS shell)? Is your SDK in the path? Are the platform-tools in the path? What Java version do you have? Your error is "uncommon". – Martin Marconcini Jul 01 '19 at 12:37
  • `I shouldn't need to do all kinds of things to fix a fresh install...the problem is with the installation itself.` Funny you say this, you're installing a Development tool, which has (like all others) a _toolchain_ and some requirements, and yet _you don't want to do all kinds of things_. There's not *much to do* to be honest. Have JAVA, Have the SDK. Run Android Studio. Most can be done before or after you install AS. – Martin Marconcini Jul 01 '19 at 12:40
  • @Martin Marconcini Yes I was gonna say I couldn't believe it was even more buggy than XCode. Yes I installed it a year or so back and it threw some errors back then so I uninstalled it. That's why I did a full uninstall just today using appcleaner and manually removed the SDKs too. I think people are actually more annoyed that I said something bad about their beloved Android Studio, hence your comment and the downvotes. – Hasen Jul 01 '19 at 12:45
  • @Martin Marconcini But anyway, this is my exact experience and the string of errors surprised me is all. I just installed it following the instructions in the video on the Android Studio website. I didn't do anything more or less than that. The Java version I have is 8.131 – Hasen Jul 01 '19 at 12:45
  • @Martin Marconcini I was just going by their install video and instructions. If there's so much more to it then why not mention it? I'm happy to do whatever is necessary to run it. It seems a lot of people have this licence issue and many replies to the three year old question this is supposed to be a duplicate of say it doesn't work in 2018, or comments this year also say it doesn't work etc. – Hasen Jul 01 '19 at 12:47
  • @Martin Marconcini "Your error is "uncommon" Which error are you referring to? The licence error which has two similar questions with 39 and 15 answers respectively, hundreds of upvotes and countless comments? If it's all so easy and simple why can't you say how to solve it? – Hasen Jul 01 '19 at 13:16

1 Answers1

4

Let me clarify your comments first: I didn't downvote, but your wording leaves a lot to be desired. Android Studio is not my beloved anything, it's just a tool that I use for the lack of a more convenient one. What you're experiencing is not an Android Studio installation issue, this is an Android toolchain problem.

What's going on?

Your Android toolchain is broken.

What to do?

I'd take a few steps here to verify where is your problem originating, for it's hard to tell without being able to reproduce it. Instead, I'm going to tell you what steps I would follow if I encountered a fresh install of macOS (or any other OS, since I don't run macOS anymore).

  1. Download Android Studio from Google.
  2. Android Studio comes with some bundled basic stuff, but for the most part, it's recommended that you complete the missing keys, using the integrated SDK Manager. It's available in the very first Android Studio welcome popup that says "Welcome to Android Studio". Pick the "Configure" at the bottom and then "SDK Manager":

My SDK Manager

  1. Notice at the top, my location where I saved all this; this must be set as ANDROID_HOME environment variable, and some of these folders must be in your Path (for easier access to any tool, notably the adb command). So if you use BASH (default for macOS High Sierra), ensure you add this to your .bashrc or .bash_profile or anywhere where you have configured your path.
export ANDROID_HOME="$HOME/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

You get the idea.

  1. Unfortunately, you also need Java, something macOS doesn't deliver these days anymore. So you have a bunch of choices here. You can head over to Oracle's downloads for Java 8 and chose the right one for your environment, or you can install the OpenJDK. In any case, if you need to see where you Java install(s) are, macOS has a handy tool called java_home. You can read more about it in this StackOverflow post.

java_home doesn't exist on my Linux, but I know where my java is, and I can see it because I added this environment variable, which is needed:

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64

Now that I have that in my path, I can run the Java binaries:

 $ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.19.04.2-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

What about the licenses

The SDK manager is capable of approving the licenses from the command line in a semi-automated form because that's what Continuous Integration environments use. If your CI environment is freshly created for every pipeline (To ensure things work from fresh every time), then they, too, need to download the SDK and accept the licenses. That's where the SDK manager license enters the picture.

It's hard to tell what's going on with yours in particular, but rest assured, it's not a normal occurrence in my experience. It's mostly easy to realize that all it needs is a file in the right place to stop asking for approval, and what not. But all that is not needed if you use the SDK Manager UI because it will prompt you to accept the licenses right there in the UI.

After you have JAVA_HOME, ANDROID_HOME, etc. all set up. If you type adb --version, it should work, no matter where you are:

$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.1-5644136
Installed as /home/martin/Android/Sdk/platform-tools/adb

After all this, and assuming your Android Studio SDK pointer is pointing to the right place, then you should be good to go.

Keep in mind, projects can elect to use the embedded JDK (and in fact it says recommended) so if Java works for you, ignore the way I install Java :) (I prefer to use my own copy of the JDK, I got used to it). Remember this is a per-project setting.

my Java configuration in AS

How about HAXM?

HAXM is an Intel proprietary tool, and all Android Studio / SDKManager does is download but not install (as far as I remember). In any case, the official Google steps to install it on macOS, clearly say, on step 4 (and I quote the above link):

After the download finishes, run the installer. Typically, you can find the installer in the following location: sdk/extras/intel/Hardware_Accelerated_ExecutionManager/IntelHAXMversion.dmg

UPDATE

  1. HAXM: this is an Intel Tool and it has security implications and requires elevated permissions (in the case of macOS, to install a kernel extension) among other things, so you must complete the installation on your own. The only thing the SDK Manager used to do was just download the file, I don't think it launches the install on its own. Installing HAMX is relatively straightforward now; you can even download it from Intel and install it on your own.

  2. Regarding your Homebrew thing, I'm not sure what's going on but I haven't used Flutter to do Android Development, so my help here will be limited in that regard. I'd try to brew uninstall whatever is conflicting here or at least try to figure out why Flutter is pointing to the wrong SDK. Take my flutter advice as coming from someone who hasn't installed Flutter ever and is just guessing with no proof :)

Martin Marconcini
  • 26,875
  • 19
  • 106
  • 144
  • About the "Android Studio is not my beloved anything, it's just a tool that I use for the lack of a more convenient one." Why not just use Eclipse or IntelliJ? – SnakeException Jul 01 '19 at 15:55
  • As _bad_ (as some people) think Android Studio is, let's not forget AS is just IntelliJ with a bunch of plug-ins on top and not much more (the Open Source version of IntelliJ that is). I believe IntelliJ (and Android Studio) are vastly superior to Eclipse in almost any aspect I can think of. Not to mention that Eclipse is _no longer officially supported_ for Android Development (the plug-in to make it work and easier hasn't been maintained in years). I'm not saying I love or hate AS, I'm saying i'm not "offended" if you don't, hence why "is not my beloved" as the OP implied. – Martin Marconcini Jul 01 '19 at 16:17
  • 1
    Just to clarify, I didn't say that you personally downvoted my answer, I just said 'the downvotes'. Even though there's nothing wrong with my question, that's exactly what happened and nobody would be happy with so many errors popping up with a simple software install. – Hasen Jul 01 '19 at 17:20
  • Anyway I think the problem lies with the fact that Macs seem to have things installed in various places. I tried running Flutter through VScode and it also says "Flutter requires Android SDK 28" even though Android Studio clearly displays that. I seem to have another version here `/usr/local/Cellar/android-sdk/24.4.1_1/tools/bin/sdkmanager` probably installed by homebrew, which for some reason VScode clings to while Android Studio uses another version. It's all a bit of a mess. – Hasen Jul 01 '19 at 17:21
  • I followed your instructions to clean all this up and I have $JAVA_HOME and $ANDROID_HOME showing the correct paths. But upon creating a new flutter app in local.properties it's showing `sdk.dir=/usr/local/Cellar/android-sdk/24.4.1_1` still clinging to the old homebrew install. Regarding HAXM, not sure why it tries to install it if it's supposed to install it at the end? In any case I can't find this file. It's supposed to be in sdk/extras/ on my hard drive? I couldn't find that folder, not sure where it's supposed to be since I have so many files with SDK in the name dotted about the place. – Hasen Jul 01 '19 at 17:55
  • Check my updated answer. For what is worth, `local.properties` is usually generated by Android Studio to the _path_ of the SDK it can find in the SDK Manager's SDK location field (see my screenshot). Nothing stops you from modifying the local.properties file to point to another SDK (try it to see if it works) – Martin Marconcini Jul 01 '19 at 18:11
  • @Martin Marconcini Doesn't look like it does unfortunately, the Android SDK Location field in AS says : `/Users/hasen/Library/Android/sdk` so it's not doing that. It's automatically selecting a completely different location for god know's what reason. Updating local.properties manually and then restarting AS still yields the same licence error. In fact in the error message still says `Using Android SDK: /usr/local/Cellar/android-sdk/24.4.1_1` so it ignores local.properties anyway? Who knows what it does. – Hasen Jul 02 '19 at 05:00
  • @Martin Marconcini Why is it the SDK manager within AS picks up all the correct SDK files but when you go to run an app it has no idea and picks something completely different? Both within the same piece of software. You'd think they'd be more connected.. – Hasen Jul 02 '19 at 05:03
  • @Martin Marconcini Uninstalling homebrew's install of SDK solves the problem for AS and VSCode with flutter. Any idea why in the world Homebrew installs stuff in weird locations? I had the same problem with Python previously...two python engines, Macos doesn't know which one is right. Anyway the test app succeeds in running now. So that's good but still haven't managed to fix my other errors, like the HAXM thing. It even seems to show as being installed in the SDK manager...is it installed? – Hasen Jul 02 '19 at 05:20
  • Homebrew: I haven't got a clue, I don't use macOS very often now but the way I remember, Hb keeps its own copies so maybe if you have 2 or more (like Python) you need to be explicit about which one to use. Maybe it changed your path (what's the output of `whereis adb` for example?). This could also be a flutter issue (don't have xp w/it, sorry). Regarding your HAXM, did you read the link that tells you to _ run the installer_? You can verify if HAXM is installed and running, see [this SO post](https://stackoverflow.com/questions/45896535/intel-haxm-on-macos-high-sierra-10-13). – Martin Marconcini Jul 02 '19 at 11:32
  • When you start an Emulator, it will tell you whether it's running in fast mode or not (check the logs), it says something like: `HAX is working and emulator runs in fast virt mode`. – Martin Marconcini Jul 02 '19 at 11:35
  • @Martin Marconcini Yes HB installs stuff in it's own locations and I looked it up and that's exactly where it installs the Android SDK...in a completely different place to where AS puts it. Since I had problems with both AS and Python thanks to HB I can only imagine HB is like a virus that messes your whole system up. Obviously there's no need to have two copies of all these things...anyway, regarding HAXM I don't know where the `sdk/extras/ it's referring to is. Normally Mac locations start from a more obvious place like `~/users/library/` whatever. – Hasen Jul 03 '19 at 11:12
  • @Martin Marconcini When opening an emulator the terminal and Dart Analysis don't display anything at all. Anyway thanks for your help in fixing the main error which was deleting the additional installation of Homebrew that stopped everything working. – Hasen Jul 03 '19 at 11:15
  • Good to hear that it worked now. I suggest you post a different HAXM question if you're still having issues with it. For what is worth, on macOS you can verify if it's working by calling `kextstat | grep intel`. Regarding `/sdk/extras` it refers to the place where you put your Android SDK (by default, on macOS, I think it's in `/Users//Android/Sdk/...` (not sure if it's all lowercase on macOS). – Martin Marconcini Jul 03 '19 at 11:53
  • If HAXM isn't working, the emulator will take VERY Long to load and will be relatively slow compared to any other macOS app. It's not super fast on macOS (compared to, say my linux box), but it works very fast and with the snapshot feature of the latest versions, it should be up and running in less than 5-10 seconds, depending on your machine. (It takes 2-3 on my box) from the moment I start till the moment the emulator is running and responsive. – Martin Marconcini Jul 03 '19 at 11:55
  • 1
    @Martin Marconcini Aha! Yes it certainly wasn't installed before. I found it in the SDK folder in my system library (weird place to put an installer) and now the emulator snaps open instantly! Used to take forever as you say. – Hasen Jul 04 '19 at 16:30