0

Whenever I import project in android studio I get a very bad structure. It goes like this.

enter image description here

What I want it to be like

enter image description here

I am trying this for hours but can't import it properly. I tried it importing it as android studio, gradle project. I also tried importing app module and even tried creating app module separately but did not come up with a solution. The original project is here - https://github.com/udacity/Sunshine-Version-2/tree/4.02_start_code_for_lesson_4 .

1 Answer 1

3

After checking out the project from github I got could see the same problem; In build.gradle there's a line that needs fixing:

Line 21: it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherMapApiKey

Since there is no variable MyOpenWeatherMapApiKey gradle sync will fail and you will get the project view instead of the Android project view.

If you try for example:

it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', "\"MY_API_KEY\""

To get an open weather api key you can check for more information here on openweathermap.

3
  • I tried setting the key, and it is not working still. Did it work for you?
    – Varun Garg
    Nov 1, 2015 at 23:04
  • Did you get a compilation error ? View still invalid? Project view works for me after updating the buildConfigField. However I updated my post, you need to wrap the api key like this "\"MY_API_KEY\"" for it to compile, my bad :) Nov 1, 2015 at 23:13
  • Thanks, I did some more changes (sdk version) to get it to work. I did not know gradle errors can make android studio this mad :p
    – Varun Garg
    Nov 1, 2015 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.