Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class in AAR file not available in Android Studio

I created a library project which I built as an AAR file and later included in another project. It's in the libs folder, and the main gradle.build file includes it: implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')

When I try to use classes of this aar file, all of them are available except one class. I initially imagined it could be Proguard, but I even removed Proguard and it is still not available. It's a public class, and it's even there when I decompile the AAR file.

This is the content:

package com.onboarding;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.Keep;


/**
 *
 */
@Keep
public class Builder {


    /**
     *
     */
    public static String mainColor = null;
    public static String baseUrl = null;
    public static Class firstActivity = null;
    public static Class onboardingSettingsActivity = null;


    /**
     *
     */
    public static String tosUrl = null;
    public static String privacyUrl = null;
    public static String cookieUrl = null;
    public static String contactsLearnMoreUrl = null;


    /**
     *
     */
    private static Builder builder = null;


    /**
     *
     */
    private Builder() {}


    /**
     *
     */
    public static Builder init() {
        if (builder == null) {
            builder = new Builder();
        }
        return builder;
    }


    /**
     *
     */
    public void start(final Context context) {
        final Intent intent = new Intent(context, Onboarding1.class);
        context.startActivity(intent);
    }


    /**
     *
     */
    public Builder setMainColor(final String color) {
        mainColor = color;
        return this;
    }


    /**
     *
     */
    public Builder setBaseUrl(final String url) {
        baseUrl = url;
        return this;
    }


    /**
     *
     */
    public Builder setFirstActivity(final Class c) {
        firstActivity = c;
        return this;
    }


    /**
     *
     */
    public Builder setOnboardingSettingsActivity(final Class c) {
        onboardingSettingsActivity = c;
        return this;
    }


    /**
     *
     */
    public Builder setTosUrl(final String u) {
        tosUrl = u;
        return this;
    }


    /**
     *
     */
    public Builder setPrivacyUrl(final String u) {
        privacyUrl = u;
        return this;
    }


    /**
     *
     */
    public Builder setCookieUrl(final String u) {
        cookieUrl = u;
        return this;
    }


    /**
     *
     */
    public Builder setContactsLearnMoreUrl(final String u) {
        contactsLearnMoreUrl = u;
        return this;
    }

}

Any idea why I can't access this class from the main project?

Thanks!

like image 500
zundi Avatar asked Oct 12 '18 01:10

zundi


1 Answers

After randomly working then not working, it appears that a File -> Invalidate caches / restart in Android Studio did the trick.

So apparently Android Studio caches some part of the aar, which even a Clean nor Rebuild would fix.

like image 165
zundi Avatar answered Oct 22 '22 00:10

zundi