Kotlin:找不到符号类Fragment或其他android类

erl*_*man 9 java android android-fragments kotlin kotlin-android-extensions

我有一个带有viewPager的java片段.

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;
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

现在我有另一个片段将填充在上面的片段中,并用kotlin写成:

class DeshFalView : Fragment(), DeshfalContract.View {
    //More code...
}
Run Code Online (Sandbox Code Playgroud)

我没有得到任何lint警告或错误但是当我尝试运行应用程序时:

但我收到一个错误:

错误:(79,37)错误:找不到符号类DeshFalView

在上面突出显示的行中..这两个类在同一个包中,如下所示 在此输入图像描述

提前致谢 ...

erl*_*man 37

问题:我犯了一个愚蠢的错误,我apply kotlin-android 插件

解决方案:app gradle文件粘贴的顶部:

apply plugin: 'kotlin-android'
Run Code Online (Sandbox Code Playgroud)