当前位置: 首页 > 知识库问答 >
问题:

匕首组件:错误:找不到符号kotlin类

冉弘化
2023-03-14

dagger的生成组件无法找到kotlin类的符号,即使该组件上没有读取行。

任务:app:compilestatingdebugjavawithjavac失败

\app\build\generated\source\kapt\stagingDebug\...\DaggerAppComponent.java:49: error: cannot find symbol
import com...features.Main.splash_screen.SplashScreenActivity;
                                                                     ^
symbol:   class SplashScreenActivity
location: package com...features.Main.splash_screen

当我用java输入代码时,它运行成功,这个问题只在windows中发生。它不出现在mac或linux中。

interface ISplashScreen  : IView {
    fun gotoMainScreen()
}

@Module
abstract class SplashModule {
    @Binds
    abstract fun provideISplash(splashScreenActivity: SplashScreenActivity): ISplashScreen
}


class SplashScreenActivity : BaseActivity<SplashScreenPresenter>(), ISplashScreen {

    @Inject
    lateinit var splashScreenPresenter: SplashScreenPresenter

    override fun gotoMainScreen() {
        Navigator.goToMainScreen(context)
    }

    override fun onCreateInit(savedInstanceState: Bundle?) {

    }

    override fun getLayout(): Int = R.layout.activity_splash

    override fun initPresenter(): SplashScreenPresenter = splashScreenPresenter
}

class SplashScreenPresenter @Inject constructor(view: ISplashScreen,
                                                environment: PresenterEnvironment)
    : BasePresenter<ISplashScreen>(view, environment) {

    // TODO : load project data by API
    @SuppressLint("CheckResult")
    override fun startLogic(savedInstance: Bundle?) {
        super.startLogic(savedInstance)
        Completable.timer(3, TimeUnit.SECONDS)
                .compose(getDestroyIoTransformer<Unit>())
                .subscribe {
                    view.gotoMainScreen()
                }
    }
}

@Module
public abstract class ActivityModule {

    @ContributesAndroidInjector(modules = SplashModule.class)
    abstract SplashScreenActivity bindSplashScreenActivity();

    @ContributesAndroidInjector(modules = { CartFragmentProvider.class, CategoryFragmentProvider.class})
    abstract MainActivity bindMainActivity();
}

//Gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-platform-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'

implementation "com.google.dagger:dagger:2.23.1"
implementation "com.google.dagger:dagger-android-support:2.23.1"
kapt "com.google.dagger:dagger-compiler:2.23.1"
kapt "com.google.dagger:dagger-android-processor:2.23.1"

...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:49: error: cannot find symbol
import com....features.Main.splash_screen.SplashScreenActivity;
                                                                     ^
  symbol:   class SplashScreenActivity
  location: package com....features.Main.splash_screen
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:51: error: cannot find symbol
import com....features.Main.splash_screen.SplashScreenPresenter;
                                                                     ^
  symbol:   class SplashScreenPresenter
  location: package com....features.Main.splash_screen
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\modules\ActivityModule_BindSplashScreenActivity.java:3: error: cannot find symbol
import com....features.Main.splash_screen.SplashModule;
                                                                     ^
  symbol:   class SplashModule
  location: package com....features.Main.splash_screen
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\modules\ActivityModule_BindSplashScreenActivity.java:4: error: cannot find symbol
import com....features.Main.splash_screen.SplashScreenActivity;
                                                                     ^
  symbol:   class SplashScreenActivity
  location: package com....features.Main.splash_screen
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\modules\ActivityModule_BindSplashScreenActivity.java:25: error: cannot find symbol
  public interface SplashScreenActivitySubcomponent extends AndroidInjector<SplashScreenActivity> {
                                                                            ^
  symbol:   class SplashScreenActivity
  location: class ActivityModule_BindSplashScreenActivity
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\modules\ActivityModule_BindSplashScreenActivity.java:27: error: cannot find symbol
    interface Factory extends AndroidInjector.Factory<SplashScreenActivity> {}
                                                      ^
  symbol:   class SplashScreenActivity
  location: interface SplashScreenActivitySubcomponent
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:217: error: cannot find symbol
        SplashScreenActivity arg0) {
        ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentFactory
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:224: error: cannot find symbol
    private final SplashScreenActivity arg0;
                  ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:226: error: cannot find symbol
    private SplashScreenActivitySubcomponentImpl(SplashScreenActivity arg0Param) {
                                                 ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:233: error: cannot find symbol
    private SplashScreenPresenter getSplashScreenPresenter() {
            ^
  symbol:   class SplashScreenPresenter
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:237: error: cannot find symbol
    public void inject(SplashScreenActivity arg0) {
                       ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:240: error: cannot find symbol
    private SplashScreenActivity injectSplashScreenActivity(SplashScreenActivity instance) {
                                                            ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:240: error: cannot find symbol
    private SplashScreenActivity injectSplashScreenActivity(SplashScreenActivity instance) {
            ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:14: error: cannot find symbol
public final class SplashScreenActivity_MembersInjector implements MembersInjector<SplashScreenActivity> {
                                                                                   ^
  symbol: class SplashScreenActivity
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:25: error: cannot find symbol
  private final Provider<SplashScreenPresenter> splashScreenPresenterProvider;
                         ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:33: error: cannot find symbol
      Provider<SplashScreenPresenter> splashScreenPresenterProvider) {
               ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:48: error: cannot find symbol
      Provider<SplashScreenPresenter> splashScreenPresenterProvider) {
               ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:42: error: cannot find symbol
  public static MembersInjector<SplashScreenActivity> create(
                                ^
  symbol:   class SplashScreenActivity
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:52: error: cannot find symbol
  public void injectMembers(SplashScreenActivity instance) {
                            ^
  symbol:   class SplashScreenActivity
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:61: error: cannot find symbol
  public static void injectSplashScreenPresenter(SplashScreenActivity instance,
                                                 ^
  symbol:   class SplashScreenActivity
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenActivity_MembersInjector.java:62: error: cannot find symbol
      SplashScreenPresenter splashScreenPresenter) {
      ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenActivity_MembersInjector
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:8: error: cannot find symbol
public final class SplashScreenPresenter_Factory implements Factory<SplashScreenPresenter> {
                                                                    ^
  symbol: class SplashScreenPresenter
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:9: error: cannot find symbol
  private final Provider<ISplashScreen> viewProvider;
                         ^
  symbol:   class ISplashScreen
  location: class SplashScreenPresenter_Factory
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:13: error: cannot find symbol
  public SplashScreenPresenter_Factory(Provider<ISplashScreen> viewProvider,
                                                ^
  symbol:   class ISplashScreen
  location: class SplashScreenPresenter_Factory
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:20: error: cannot find symbol
  public SplashScreenPresenter get() {
         ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenPresenter_Factory
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:24: error: cannot find symbol
  public static SplashScreenPresenter_Factory create(Provider<ISplashScreen> viewProvider,
                                                              ^
  symbol:   class ISplashScreen
  location: class SplashScreenPresenter_Factory
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:29: error: cannot find symbol
  public static SplashScreenPresenter newInstance(ISplashScreen view,
                                                  ^
  symbol:   class ISplashScreen
  location: class SplashScreenPresenter_Factory
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:29: error: cannot find symbol
  public static SplashScreenPresenter newInstance(ISplashScreen view,
                ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenPresenter_Factory
...\app\src\main\java\com\...\common\di\modules\ActivityModule.java:3: error: cannot find symbol
import com....features.Main.splash_screen.SplashModule;
                                                                     ^
  symbol:   class SplashModule
  location: package com....features.Main.splash_screen
...\app\src\main\java\com\...\common\di\modules\ActivityModule.java:4: error: cannot find symbol
import com....features.Main.splash_screen.SplashScreenActivity;
                                                                     ^
  symbol:   class SplashScreenActivity
  location: package com....features.Main.splash_screen
...\app\src\main\java\com\...\common\di\modules\ActivityModule.java:16: error: cannot find symbol
    abstract SplashScreenActivity bindSplashScreenActivity();
             ^
  symbol:   class SplashScreenActivity
  location: class ActivityModule
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\modules\ActivityModule_BindSplashScreenActivity.java:24: error: cannot find symbol
  @Subcomponent(modules = SplashModule.class)
                          ^
  symbol:   class SplashModule
  location: class ActivityModule_BindSplashScreenActivity
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\modules\ActivityModule_BindSplashScreenActivity.java:20: error: cannot find symbol
  @ClassKey(SplashScreenActivity.class)
            ^
  symbol:   class SplashScreenActivity
  location: class ActivityModule_BindSplashScreenActivity
...\app\src\main\java\com\...\common\di\modules\ActivityModule.java:15: error: cannot find symbol
    @ContributesAndroidInjector(modules = SplashModule.class)
                                          ^
  symbol:   class SplashModule
  location: class ActivityModule
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:143: error: cannot find symbol
    return MapBuilder.<Class<?>, Provider<AndroidInjector.Factory<?>>>newMapBuilder(2).put(SplashScreenActivity.class, (Provider) splashScreenActivitySubcomponentFactoryProvider).put(MainActivity.class, (Provider) mainActivitySubcomponentFactoryProvider).build();}
                                                                                           ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:234: error: cannot find symbol
      return new SplashScreenPresenter(arg0, DaggerAppComponent.this.providePresenterEnvironmentProvider.get());}
                 ^
  symbol:   class SplashScreenPresenter
  location: class DaggerAppComponent.SplashScreenActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\common\di\components\DaggerAppComponent.java:271: error: cannot find symbol
      return MapBuilder.<Class<?>, Provider<AndroidInjector.Factory<?>>>newMapBuilder(4).put(SplashScreenActivity.class, (Provider) DaggerAppComponent.this.splashScreenActivitySubcomponentFactoryProvider).put(MainActivity.class, (Provider) DaggerAppComponent.this.mainActivitySubcomponentFactoryProvider).put(CartFragment.class, (Provider) cartFragmentSubcomponentFactoryProvider).put(CategoriesFragment.class, (Provider) categoriesFragmentSubcomponentFactoryProvider).build();}
                                                                                             ^
  symbol:   class SplashScreenActivity
  location: class DaggerAppComponent.MainActivitySubcomponentImpl
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:21: error: cannot find symbol
    return new SplashScreenPresenter(viewProvider.get(), environmentProvider.get());
               ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenPresenter_Factory
...\app\build\generated\source\kapt\stagingDebug\com\...\features\Main\splash_screen\SplashScreenPresenter_Factory.java:31: error: cannot find symbol
    return new SplashScreenPresenter(view, environment);
               ^
  symbol:   class SplashScreenPresenter
  location: class SplashScreenPresenter_Factory
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
39 errors

FAILURE: Build failed with an exception.
  • 错误:任务执行失败:app:compilestatingdebugjavawithjavac

编译失败;有关详细信息,请参阅编译器错误输出。

>

获取更多帮助https://help.gradle.org

此版本中使用了不推荐的Gradle功能,使其与Gradle 6.0不兼容。使用“-warning mode all”显示单个弃用警告。看见https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

构建在2350个可操作任务中失败:9个已执行,41个最新

共有1个答案

巫马玉堂
2023-03-14

你的项目使用kapt吗?

如果是这样,您可以禁用kapt的缓存。

在app模块中打开build.gradle文件,将useBuildCache设置为false,并同步Gradle。

尝试重建您的代码

kapt {
    useBuildCache = false  
}

如果一切顺利,您可以再次启用useBuildCache

 类似资料:
  • 这里有一个类似的答案:如何在Java中将函数作为参数传递? 但提供的正确答案不起作用。我有一门课: 在函数内部我试图将传递到,但我得到的错误是: 找不到符号 符号:类Callable 我不知道为什么。 另外,我尝试使用返回类型字符串作为xMethod,您能传递一个返回类型不同的函数吗?

  • 问题内容: 我使用时代码工作正常 吗?在我看来这很奇怪。 (错误显示在终端上) 问题答案: 这是 Arrays 类的静态方法。 您应该像这样调用它: 请注意,您仍然必须像这样导入Arrays类: 或者像其他人提到的那样,如果您进行静态导入,则可以省略类名。 我认为这样做对可读性更好。

  • (菜鸟失误,我确定。) 我是计算机科学专业的一年级学生,正在尝试用代码编写作业程序; 但是在编译时,我得到了错误; Lab10Ex1.java:10: 错误: 找不到符号 System.out.print(n 1);^ 符号:变量n 位置: 班级 Lab10Ex1 如果有人能向我解释我做错了什么,或者如何纠正它,我会非常感激。

  • 我有一个问题,我试图实现一个JMenuBar,但不断得到一个不能找到符号错误。我将JFrame与main方法一起放在一个单独的类中,JFrame将安装MainPanel类的一个对象。我在这里漏掉了什么?如有任何帮助将不胜感激,谢谢! 符号:方法setJMenuBar(JMenuBar) 位置:类主面板

  • 我下载了一个Android项目,但我得到了这个错误: 样品导入: 样品用法: 代码时没有错误,但在编译时我得到了我提到的错误。 当我尝试在Android Studio上进行定义时,我不能。 应用程序级生成。格拉德尔: 我试着清理和重建这个项目,但还没有成功。 谢谢你的帮助。

  • 我是Android应用程序开发的新手,所以请耐心等待我。我正在编写一个应用程序,该应用程序从Google Play服务获取GPS位置,然后通过蓝牙广播数据。我有一个获取位置的位置活动,以及一个广播数据的 AdvertisingActivity。 我的问题是我很难理解Android应用程序中的文件结构,所以我怀疑我缺乏理解是我遇到错误的原因。 下面是位置活动的一个代码段,其中错误是: 为什么编译器找