I don\'t know what to do about the following errors, I\'ve searched the web but not found anything:
java.lang.ClassNotFoundException: Didn\'t find class \"an
Adding Java 1.8 compatibility to my build.gradle
fixed this for me (non-release build with multidex enabled).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
Unfortunately I'm not sure why :)
did u create fragments? ok if you create fragments with classes and after that you have to create a class to call those fragments. and if you use switch this cane be like this
`public Fragment getItem(int i) {
// you have create a switch to get positions using i.
switch (i) {
case 0:
ChatsFragment chatsFragment = new ChatsFragment();
return chatsFragment;
case 1:
GroupsFragment groupsFragment = new GroupsFragment();
return groupsFragment;
case 2:
ContactsFragment contactsFragment = new ContactsFragment();
return contactsFragment;
default:
return null;
}
}
@Override
public int getCount() {
return 3;//error can be happen if u use default 0, use fragment counts in here.
}`
in this case you can see 3 cases in switch and the public int getCount() the return value should be 3 not default value 0.
See your error must be close to this one. i got same kind of error and i solved it.
In my case ,that was because of a little mistake in one of my layouts.
I removed one >
at the end of a view tag accidentlly.
Check your
xml
files.
It may sound totally unrelated, but I have seen this problem also when by mistake I have overridden wrong on Activity#onCreate() method i.e.
public void onCreate(@Nullable Bundle savedInstanceState,
@Nullable PersistableBundle persistentState)
Instead of
protected void onCreate(@Nullable Bundle savedInstanceState)
So, please check that also. The second one is the one that you probably need.
Please refer to the documentations for the details of these two methods.
In my case, add android.enableR8=false
in the gradle.properties.
add below code to gradle.properties
android.enableJetifier=true
android.useAndroidX=true
or you can choose migrate to androidX in refactor -> Migrate to androidX.