Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio 0.4.2 + gradle + Android Source code

I'm trying to attach the android source code to my gradle project using Android Studio. The problem is that the SDK tab does not appear if you are using a gradle project and I can not attach the source code. I tried with version 0.4.3 and does not work.

Any idea or work arround?

EDIT: I've attach a capture with my project structure without sdk option.

enter image description here

Thank you,

like image 654
flipper83 Avatar asked Jan 24 '14 13:01

flipper83


People also ask

Where can I find Android source code?

The Android source tree is located in a Git repository hosted by Google. The Git repository includes metadata for the Android source, including changes to the source and when the changes were made. This page describes how to download the source tree for a specific Android code line.

What is source code in Android Studio?

Your source code download is a reflection of your app at the time of your last build inside Dropsource, made available for a one-way transfer to the IDE. However, if you plan to release multiple versions of your app you can do so from your source code – for each new version: Make your changes in the editor.

Where is the build Gradle File in Android Studio?

The top-level build.gradle file, located in the root project directory, defines dependencies that apply to all modules in your project. By default, the top-level build file uses the plugins block to define the Gradle dependencies that are common to all modules in the project.


2 Answers

The short explanation is that Android Studio has added some functionality to try to automatically manage IntelliJ SDKs; if you give it a JDK path and Android SDK path in Project Structure > Android SDK, it will automatically create a Java SDK and Android SDKs for each API level you have installed in your Android SDK. The problem is, if it creates an Android SDK for an API level that doesn't have the sources downloaded, if you go into SDK Manager later and download the source, it doesn't pick that up and update its SDK. I've filed https://code.google.com/p/android/issues/detail?id=65230 for this. In that bug I list two workarounds, which I'll explain here:

You can actually get at the SDKs panel you're looking for. We hide it if you have a Gradle-based project open since we want Gradle-based project users to not have to worry about it, but since we also support IntelliJ-style projects that use its internal builder, it's still possible to access it so those users will be able to make their projects work. You can get at this panel if you access Project Structure without a project open. To do so:

  • Close all open projects
  • From the Welcome to Android Studio screen, go to Configure > Project Defaults > Project Structure > SDKs
  • Choose the appropriate Android API SDK that you installed source for, and go to Sourcepath panel
  • Press the + button, and choose the source directory.

If you're having trouble following that, let me know and I can post screenshots.

Another approach would be to blow away all of Android Studio's auto-created SDKs and let it rebuild them. To do that

  • Exit Android Studio
  • Delete the jdk.table.xml file, which on MacOS will be in your home directory under Library/Preferences/AndroidStudioPreview
  • Relaunch Android Studio
  • Go into Project Structure (either from the Welcome screen or from a project), and choose the Android SDK tab
  • Make sure the Android SDK location and JDK location are correct.
like image 68
Scott Barta Avatar answered Nov 15 '22 18:11

Scott Barta


Check the compileSdkVersion in your build.gradle file and download the "Source for Android SDK" for respective API from Android SDK Manager.

SDK manager icon will be available on Android Studio tool bar.

Nothing else needs to be done.

Note : Source Code for Android SDK is only available for and after API 13 .

like image 24
Piyush Agarwal Avatar answered Nov 15 '22 17:11

Piyush Agarwal