5
maven central에 일부 위젯이있는 라이브러리가 있습니다. 내가 Gradle을을 사용하여 프로젝트에 (받는다는 중앙에서) 종속성으로 해당 라이브러리를 추가 할 때 내가 얻을 :Android 라이브러리 선언 스타일 가능 런타임 오류
java.lang.NoClassDefFoundError: com.my.pacakge.R$styleable
내가 수동으로 .aar를 다운로드하고 프로젝트에 모든 것이 잘 작동 것을 포함합니다. Android Studio의 코드 완성을 사용하여 라이브러리의 R
이 포함되었는지 확인하려고했습니다. maven 종속성을 사용할 때 com.my.pacakge.R
을 입력해도 결과가 반환되지 않지만 로컬 .aar를 사용하면 라이브러리에 대해 R
을 반환합니다.
// widget constructor
public ForegroundImageView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundImageView);
Drawable foreground = a.getDrawable(R.styleable.ForegroundImageView_android_foreground);
if (foreground != null) {
setForeground(foreground);
}
a.recycle();
}
// attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ForegroundImageView">
<attr name="android:foreground"/>
</declare-styleable>
</resources>
종속성을 포함하고있는 빌드 파일을 보여주십시오. –
나는 내 아아와 같은 문제가있다. 스타일 가능 속성을 사용할 수 없기 때문에 내 라이브러리를 maven에 놓을 수 없습니다. "publishNonDefault false"가 작동하지 않습니다. – NeoKree