gpt4 book ai didi

android - Dagger 组件 : error: cannot find symbol kotlin classes

转载 作者:行者123 更新时间:2023-12-03 21:01:42 30 4
gpt4 key购买 nike

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

Task :app:compileStagingDebugJavaWithJavac FAILED

\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:compileStagingDebugJavaWithJavac' 执行失败。

  • Compilation failed; see the compiler error output for details.


  • 尝试:
    使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
  • 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
    23 秒内构建失败
    50 个可操作的任务:9 个已执行,41 个最新

    最佳答案

    你的项目使用 kapt 吗?
    如果是这样,您可以禁用 kapt 的缓存。
    打开您的build.gradle应用程序模块中的文件,并设置useBuildCache为 false,并同步 Gradle。
    尝试重建您的代码。

    kapt {
    useBuildCache = false
    }
    如果一切顺利,您可以启用 useBuildCache再次。

    关于android - Dagger 组件 : error: cannot find symbol kotlin classes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56955853/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com