Kotlin: Cannot find character class Fragment or other Android classes

I have a java fragment with viewPager in it.

public class FragmentWithViewPager extends Fragment {

    private class ViewPagerAdapter extends FragmentStatePagerAdapter {

        ViewPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
            Fragment fragment = new DeshFalView(); //<-- Problem here
            Bundle args = new Bundle();
            args.putInt("index", i);
            fragment.setArguments(args);
            return fragment;
        }

    }
}

Now I have another fragment that will be filled inside this fragment and written in kotlin as follows:

class DeshFalView : Fragment(), DeshfalContract.View {
    //More code...
}

I do not get a warning or lint error, but when I try to start the application:

But I get an error message:

Error: (79, 37) error: Cannot find DeshFalView character class

in the highlighted line above .. these two classes are inside the same package as shown below enter image description here

Thanks in advance...

+4
source share
1 answer

: , kotlin-android

: gradle:

apply plugin: 'kotlin-android'
+19

Source: https://habr.com/ru/post/1678127/


All Articles