繁体   English   中英

将 Android 源代码导入 Intellij-IDEA 时出现导航问题

[英]Navigation Issue when importing the Android source code into Intellij-IDEA

我遵循将android源代码导入IDEA的标准流程。

像这样:

https://wiki.lineageos.org/import-android-studio-howto.html

为什么不导航到 Message.java 而不是 jar 中的 Message.class?

消息.class 位置:

/home/sdb/android_source/source/aosp/external/robolectric/v3/runtime/android-all-4.2.2_r1.2-robolectric-0.jar./android/os/Message.class

为什么不导航到 Message.java 而是 jar 中的 Message.class

任何人都知道如何解决它?

我已经成功构建了源代码。

想法版本:

IntelliJ IDEA 2020.2.3 (Ultimate Edition)
Build #IU-202.7660.26, built on October 6, 2020
Licensed to *****
Subscription is active until January 22, 2021
For educational use only.
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 4.15.0-123-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 4062M
Cores: 4
Non-Bundled Plugins: org.jetbrains.kotlin
Current Desktop: Unity

通常,这会发生在除了代码之外,您将 JAR 作为源包含在 IntelliJ 中的情况。

要解决此问题,您应该:

  • Project Structure中,从您包含的 SDK 的类路径中删除所有 JARs。 请参阅博客文章以获取指南
  • 对于您不想打开的特定模块/JAR(例如,因为您希望 IntelliJ 打开源代码),您可以将其标记为Excluded
    例如,在上面链接的博客中,您有以下内容:

在此处输入图像描述

Go 在该屏幕中,找到您要忽略的文件夹/模块/JAR,并将其标记为Excluded

当它被排除时,IntelliJ 不会将它用于“Ctrl + 单击”导航。

看起来这是 class 不是来自项目本身,而是来自依赖项。

To be able to navigate to the dependency source file instead of the.class file - this library jar dependency ( android-all-4.2.2_r1.2-robolectric-0.jar ) must have the sources jar in addition to.class jar and此 jar 必须作为源类型添加到 IDE 中的 库配置中。 这是对机器人项目的依赖——它不是 Andorid Studio 的源代码。 因此,必须从中央 maven 存储库中下载除 .class 文件之外的源文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM