This is a sample app for displaying a particlar issue with Android Studio to the Android tools team:
https://code.google.com/p/android/issues/detail?id=199892
When using Maven dependencies within Android Studio, you may use libraries deployed either as .aar
files or .jar
files. It's very useful during development to be able to step right into library code to view the source and javadocs. Currently, this is only supported for .jar
-based libraries, and not .aar.
libraries.
This is a sample Android application project created using Android Studio 2.0 Preview 8 which has only been modified to:
- Use a custom Maven endpoint where I've deployed the sample library in both jar and aar form
- Add the aar/jar library as dependencies in
build.gradle
MainActivity
has been altered to reference the library, to display when source/docs are and aren't attached.
This issue has been brought to the attention of the tools team in the past, but has unfortunately been marked as fixed and released. This repository is an effort to show that this issue is still present.
This is the past issue report: https://code.google.com/p/android/issues/detail?id=74203
- Import the enclosed Android Application into Android Studio 2.0 Preview 8, on OS X 10.11.3 (Studio version and OS X version don't actually matter, the issue will be present regardless)
- Open app/build.gradle, and note that the current MParticle dependency is
compile 'com.mparticle:android-core-test:4.2.1@aar'
- Open MainActivity.java and Command-Click into the
MParticle
class withinonCreate
.
Expected Result: Android Studio will display the sources of MParticle.java
Actual Result: Android Studio will show the decompilation of the bytecode of the underlying classes.jar within the aar
- Re-open app/build.gradle, change
compile 'com.mparticle:android-core-test:4.2.1@aar'
tocompile 'com.mparticle:android-core-test:4.2.1@jar'
- Clean your project and re-sync Gradle
- Open MainActivity.java and Command-Click into the
MParticle
class withinonCreate
. - Android Studio will correctly display the sources of MParticle.java
This issue is not present for the support library. The Android Studio codebase is tightly-coupled to the com.android.support
group id - it looks specifically for it and attached sources to aar's of that group.
Here is the commit that enabled source-attachment for the Support Library: https://android.googlesource.com/platform/tools/adt/idea/+/28ccb2410ddda1a4271e177c1d6ed632f95583bd
Here is the method that could potentially be made generic for all AARs: https://android.googlesource.com/platform/tools/adt/idea/+/master/android/src/com/android/tools/idea/gradle/project/PostProjectSetupTasksExecutor.java#379