A recent mistake was made with arouter and Kotlin

1. The problem scenario is as follows:

I pass A parameter “class_id” via the autowired annotation in the Arouter routing framework, starting with A –> B

The classId variable can be assigned an initial value, and here I gave it a default value of “21”,

So, if interface A jumps to interface B, the “class_id” property is not passed, then what is the value of the classId we use in interface B?

—————————————————————————————–

2. Conclusions:

If you do not pass this property, then this value will be null when used in the B interface

I accidentally called this parameter and it was a null-pointer exception.

————————————————————————————————

3. Why?

Analysis of the source code:

ARouter injection source code analysis

That’s a key line of code**ARouter.getInstance().inject(this)**;ARouter’s proxy class _ARouter first looks for the implementation class of the AutowiredService and then gets the instance

After into the

The TestActivity3 ARouterARouterARouterAutowired. Java, is generated by the compiler

This “class_id” is the field I need to pass in the code, getStringExtar defaults to null, and initial assignment is useless.

This is the truth, how painful understanding or honestly sentenced empty bar.

By the way, summarize the ARouter Inject injection process again: