5

I tried importing via import project wizard, didn't work. This project is using Gradle Kotlin DSL. I am using Android Studio 3.1.4.

I tried running gradle idea and got this message

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user/Projects/firebaseauthui/FirebaseUI-Android/build.gradle.kts' line: 400

* What went wrong:
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* 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.

What is the recommended way to import this project as they have migrated to Kotlin DSL?

This has been reported on GitHub Repository. Still I have issue importing.

A note on importing the project using Android Studio: Using 'Project from Version Control' will not automatically link the project with Gradle (issue #1349). When doing so and opening any build.gradle.kts file, an error shows up: Project 'FirebaseUI-Android' isn't linked with Gradle. To resolve this issue, please git checkout the project manually and import with Import from external model.

screenshot of the issue

Poornan
  • 741
  • 2
  • 11
  • 25
  • https://stackoverflow.com/questions/51091932/open-firebaseui-android-with-android-studio/51107928; this answer did not help me – Poornan Aug 30 '18 at 05:41

6 Answers6

3

According to your issue

* What went wrong:
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

Looks like Android SDK is not configured in your project which is why it is failing to compile project in Gradle.

Try this solution:

  1. Go to your project ('/Users/user/Projects/firebaseauthui/FirebaseUI-Android/')
  2. Find local.properties file.
  3. Open that file and add this variable if it's not there

    sdk.dir=`path of your Android SDK`(it is where you've put android sdk in local storage)
    

"For more generic way, check this solution" SO answer by @Ziggy192

Jeel Vankhede
  • 11,592
  • 2
  • 28
  • 58
  • I look for a recommended practice, not a patch. "What is the recommended way to import this project(Gradle Kotlin DSL) as they have migrated to Kotlin DSL?" – Poornan Sep 05 '18 at 06:29
  • 2
    @Poornan there might be a vast misconception on your side. ever tried the suggested approach? the error message tells you exactly what to do, while you seem to ignore that and the bounty won't change that. – Martin Zeitler Sep 11 '18 at 09:09
  • misconception? I did the basic debugging before posting. The question is specifically looking for a defined answer "What is the recommended way to import this project". I don't expect a random answer. Bounty set for "Authoritative reference needed; Looking for an answer drawing from credible and/or official sources." – Poornan Sep 12 '18 at 12:33
0

I did update the Android Studio, current version

Android Studio 3.1.4 Build #AI-173.4907809, built on July 24, 2018 JRE: 1.8.0_152-release-1024-b01 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.13.6

I did update Kotlin plugin, current version

Version: 1.2.70-release-Studio3.1-1

Still I could not import from Version Control- GitHub.

Manual git checkout then open build.gradle.kts with Android Studio did solve the issue.

success screenshot

Poornan
  • 741
  • 2
  • 11
  • 25
-1

Getting started:

1. Get an Android Studio version 3.0 and above (You got it)

2. Make sure you have install Kotlin plugin.

Go to File | Settings | Plugins | Install JetBrains plugin… and then search for and install Kotlin. If you are looking at the "Welcome to Android Studio" screen, choose Configure | Plugins | Install JetBrains plugin… You'll need to restart the IDE after this completes.

3. Make sure you have Firebase Authentication

Go to Tools | Firebase | Authentication | Connect to Firebase | Add Firebase Authentication to your app.

With this step, you don't have to manually download the Firebase AUth.

4. Done

Source : Kotlin for Android Firebase Auth

Angus
  • 3,680
  • 1
  • 12
  • 27
  • I am not using 'FirebaseUI-Android'. I am trying to build https://github.com/firebase/FirebaseUI-Android project locally – Poornan Sep 05 '18 at 06:22
  • Making your own local library where you can change the code ? – Angus Sep 05 '18 at 06:23
  • Yes. I am trying to clone the project(github.com/firebase/FirebaseUI-Android) and locally build as I mentioned. – Poornan Sep 05 '18 at 06:27
-1

The error is suggesting that the android studio cannot find your android SDK you should go to:

File -> Project Structure -> in right panel choose SDK location -> set your Android SDK location.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
Pouya Danesh
  • 1,557
  • 2
  • 19
  • 36
-1

Try to sync project with Gradle files from Android Studio:

Step 1 - File -> Sync Project with Gradle file

Step 2 - Once sync is done :- File - Invalidate caches/Restart.

I hope this will help you.

Khantahr
  • 8,156
  • 4
  • 37
  • 60
Sachin Singh
  • 149
  • 1
  • 7
-1

I cloned the FirebaseUI-Android project and tried to reproduce your issue. I found two solutions for it.

  1. If you just want to build the project locally as you mentioned in one of your comment. You can use command line to do it.

    • First you need to create an environment variable named ANDROID_HOME in your operating system and set it to SDK location. It's required so that gradle can find all the tools required to build the project.
    • Open a command prompt(Windows OS) on the project root directory.
    • Type gradlew assembleDebug to build the project. You can also try to run other task available in gradle as per your requirement.
  2. I tried to import project via wizard but it did not work for me as well. I then first opened a random android project in Android studio and then tried

    • File > Open... > Selected the FirebaseUI-Android Project > New Window

These two procedure worked for me but I'm not sure if it's the recommended way.

Note: Please make sure you set the ANDROID_HOME if you get SDK location missing issue in any of the two solutions. You will also get error in project as google-services.json is missing and I hope you know how to fix it. My Android Studio is v3.1.4 and Kotlin Plugin is v1.2.50

mthakuri
  • 1,085
  • 8
  • 13