java.lang.NoClassDefFoundError
in Android 5.1.1
but I got running well on 6.0.1
Here is the class which have the error:
public class DuelsTextView extends AppCompatTextView {
int fontType;
public DuelsTextView(Context context) {
super(context);
init(null);
}
public DuelsTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public DuelsTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs);
}
public void init(AttributeSet attrs) {
if (attrs != null) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DuelsTextView);
fontType = a.getInteger(R.styleable.DuelsTextView_font_type, 0);
}
try {
Typeface myTypeface = null;
if (fontType == 0) {
myTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/BreeSerif-Regular.ttf");
} else if (fontType == 1) {
myTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/MarkoOne-Regular.ttf");
}
this.setTypeface(myTypeface);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Here is the gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.adamvarhegyi.duelsofcodrer"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.android.support:appcompat-v7:25.0.1') {
exclude module: 'support-v4'
}
compile('com.android.support:recyclerview-v7:25.0.1')
compile('com.makeramen:roundedimageview:2.2.1')
compile('org.apache.commons:commons-lang3:3.4')
compile('de.hdodenhof:circleimageview:2.1.0')
}
If I change the extending to simple TextView
it's working fine, however android studio suggests me that I would have to use AppCompatTextView
for custom views.
Why is this happening? What should I modify?