Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 594 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Prefer to run the dagger processor over that class instead" in Kotlin

#1
I'm getting this note in the build whenever I do an inject into a kotlin class (btw, I have a mixed android project with both kotlin and java).

For example, after this gradle task: `compileStagingDebugJavaWithJavac` (StagingDebug is my build variant), I get this message:

> "Note: Generating a MembersInjector or Factory for com.packageNameXXX.CourseDiscoveryMapFragment. Prefer to run the dagger processor over that class instead."

My **CourseDiscoveryMapFragment** code can be seen here:

class CourseDiscoveryMapFragment : Fragment(){

@Inject
lateinit var presenter: CourseDiscoveryMapPresenter

lateinit var mapView: MapView

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

val view = inflater.inflate(R.layout.fragment_discovery_map, container, false)

MapsInitializer.initialize(activity)

mapView = view.mapView
mapView.onCreate(savedInstanceState?.getBundle(BUNDLE_KEY_MAP_STATE))

(activity as BaseActivity)
.activityComponent.inject(this)
}

And my **ActivityComponent** is :

@ActivityScope
@Subcomponent(modules = ActivityModule.class)
public interface ActivityComponent {

void inject(BaseActivity baseActivity);

void inject(CourseDiscoveryMapFragment fragment);

//Exposed to sub-graphs.
Activity activity();
}

So, I'm having dagger component and modules written in Java, while having dagger injections in Kotlin.

Is this anything that I should be worried about?

Thank you.
Reply

#2
I am afraid you can't. Why not write dependency modules in Kotlin?

To write dependency modules in java, you need to configure your Gradle script in this way:

> compile 'com.google.dagger:dagger:2.8'
> apt 'com.google.dagger:dagger-compiler:2.8'

But, to write dependency modules in Kotlin, you should configure your Gradle script in this way:

> compile 'com.google.dagger:dagger:2.8'
> kapt 'com.google.dagger:dagger-compiler:2.8'

dagger need the annotation processing tool to generate the dependency code during the compiling process. So I guess you just need to use the right APT(annotation processing tool) according to right language.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through