Didn't find class “androidx.core.app.CoreComponentFactory”

前端 未结 10 1168
一向
一向 2020-12-03 06:40

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         


        
相关标签:
10条回答
  • 2020-12-03 06:58

    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 :)

    0 讨论(0)
  • 2020-12-03 07:01

    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.

    0 讨论(0)
  • 2020-12-03 07:03

    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.

    0 讨论(0)
  • 2020-12-03 07:08

    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.

    0 讨论(0)
  • 2020-12-03 07:09

    In my case, add android.enableR8=false in the gradle.properties.

    0 讨论(0)
  • 2020-12-03 07:10

    add below code to gradle.properties

    android.enableJetifier=true
    android.useAndroidX=true
    

    or you can choose migrate to androidX in refactor -> Migrate to androidX.

    0 讨论(0)
提交回复
热议问题