android studio 0.4.2 + gradle + Android 源码 [英] android studio 0.4.2 + gradle + Android Source code

查看:31
本文介绍了android studio 0.4.2 + gradle + Android 源码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android Studio 将 android 源代码附加到我的 gradle 项目中.问题是如果您使用的是 gradle 项目并且我无法附加源代码,则不会出现 SDK 选项卡.我尝试了 0.4.3 版,但不起作用.

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.

有什么想法或工作吗?

我在没有 sdk 选项的情况下附加了我的项目结构的捕获.

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

谢谢,

推荐答案

简短的解释是,Android Studio 添加了一些功能来尝试自动管理 IntelliJ SDK;如果你在 Project Structure > Android SDK 中给它一个 JDK 路径和 Android SDK 路径,它会自动为你安装的每个 API 级别创建一个 Java SDK 和 Android SDK你的安卓 SDK.问题是,如果它为没有下载源代码的 API 级别创建了一个 Android SDK,如果您稍后进入 SDK 管理器 并下载源代码,它不会选择它并且更新其 SDK.我已经提交了 https://code.google.com/p/android/issues/detail?id=65230.在那个错误中,我列出了两个解决方法,我将在这里解释:

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:

您实际上可以找到您正在寻找的 SDK 面板.如果您打开了基于 Gradle 的项目,我们会将其隐藏,因为我们希望基于 Gradle 的项目用户不必担心它,但由于我们也支持使用其内部构建器的 IntelliJ 风格的项目,因此仍然可以访问它这些用户将能够使他们的项目工作.如果您在没有打开项目的情况下访问项目结构,则可以访问此面板.这样做:

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:

  • 关闭所有打开的项目
  • 欢迎使用 Android Studio 屏幕,转到配置 > 项目默认值 > 项目结构 > SDK
  • 选择您为其安装了源代码的相应 Android API SDK,然后转到 Sourcepath 面板
  • + 按钮,然后选择源目录.
  • 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.

另一种方法是删除所有 Android Studio 自动创建的 SDK,并让它重建它们.这样做

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

  • 退出 Android Studio
  • 删除 jdk.table.xml 文件,该文件在 MacOS 上将位于您的主目录下 Library/Preferences/AndroidStudioPreview
  • 重新启动 Android Studio
  • 进入项目结构(从欢迎屏幕或从项目),然后选择 Android SDK 标签
  • 确保 Android SDK 位置JDK 位置 正确.
  • 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.

这篇关于android studio 0.4.2 + gradle + Android 源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆