我创建了一个图书馆项目,并将其构建为AAR文件,之后又包含在另一个项目中.它在libs文件夹中,主gradle.build文件包括它:实现fileTree(include:[‘* .jar’,’*.aar’],dir:’libs’)
当我尝试使用此aar文件的类时,除一个类外,所有其他类均可用.我最初以为它可能是Proguard,但我什至删除了Proguard,但它仍然不可用.这是一个公共类,甚至在我反编译AAR文件时也存在.
这是内容:
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;
}
}
知道为什么我不能从主项目访问此类吗?
谢谢!
解决方法:
嗨,您检查过您的依存关系了吗?如果添加到那里?我的意思是这个另请参阅此documentation,以了解实现和api之间的区别.