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

Viewed 98

I followed the standard process of importing android source code into IDEA.

Like this:

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

Why not navigate to Message.java but Message.class in jar?

Message.class location:

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

Why not navigate to Message.java but Message.class in jar

Anyone knows how to fix it?

I have successfully built the source code.

IDEA version:

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
2 Answers

Generally, this will happen in cases where in addition to code, you have the JAR's included in IntelliJ as sources.

To fix this you should:

  • In Project Structure, remove all JARs from classpath for SDKs you have included. See this blog post for guide
  • For the specific module/JAR that you don't want opened ( because you'd rather have IntelliJ open the source for example ), you can mark it as Excluded.
    For example in the blog linked above you have this:

enter image description here

Go in that screen, and find the folder/module/JAR that you want to ignore, and mark it as Excluded.

When it's exluded, then IntelliJ won't use it for "Ctrl + click" navigation.

It looks like this is the class not from the project itself but from the dependency.

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 this jar must be added as source type to the library configuration in IDE. This is the dependency from robotletic project - it is not the Andorid Studio sources. So the sources for this must be downloaded in addition to .class file from the central maven repository.

Related