Java – Android .aar library interface parameter names are missing

Android .aar library interface parameter names are missing… here is a solution to the problem.

Android .aar library interface parameter names are missing

I use Android Studio (1.2.2). I built an Android module library that declares an interface:

public interface myInterface {
    void onSuccess(String returnedId);

void onFailure(Exception e);
}

I compile the project and get the .aar file from the build/outputs/aar/ directory. Then, I use the import . JAR or . AAR package Import the .aar into the project. I set it as a module dependency and imported the interface into the class I want to use it with.

The problem is that when I want to use the imported interface, the autocomplete doesn’t use the descriptive name I set when building the library to complete the interface variable. Going to the declaration on the interface in the imported .aar file, I found:

public interface myInterface {
       void onSuccess(String var1);

void onFailure(Exception var1);
 }

What I want:

void onSuccess(String returnedId);

What I got :

public void onSuccess(String s) {

Solution

The .aar file contains only the compiled code (.class file in the .jar file).

If you want to see the real parameter names in Android Studio, you have to tell Android Studio where it can find the source code (*.java files).

Related Problems and Solutions