Comments (4)
服务要由ARouter来实例化和初始化,Application这种不适合用作服务
子模块要拿到Application有太多办法,用ARouter的话,服务的init方法中的参数Context就是Application
from arouter.
我发现我common模块没有依赖app模块的时候,通过Arouter是获取不到app模块中的服务的.
我是想不通过模块间直接依赖的方式,而是通过Arouter获取服务来解决common和app之间依赖关系混乱的问题.
如果common不依赖app,能否通过Arouter获取到app中的服务?
from arouter.
我找到了为什么一直注解的是null.
我在BaseActivity中需要注入一个服务,
但是编译后apt只生成了一个叫做BaseActivity$$ARouter$$Autowired的类.
其他的Activity继承了BaseActivity后,调用了BaseActivity中的ARouter.getInstance().inject(this);
最后执行到AutowiredServiceImpl的autowire方法的时候,这个方法中className是子Activity的类名.找不到对应的Activity$$ARouter$$Autowired,所以没有注入.
为何自动生成的类没有子Activity的Autowired,还是说autowire方法查找的类名不对?
from arouter.
- 跨模块调用的话,需要抽象出一个接口包,来约束api
- 基类中不能使用自动注入,基类中的服务直接采用依赖查找即可
from arouter.
Related Issues (20)
- A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message)
- 新版本发布计划咨询 HOT 5
- 页面跳转问题 HOT 2
- 请问Arouter现在支持Dynamic Feature Module吗
- [arouter-compiler:1.5.2] RouteProcessor init JavaNullPointerException! HOT 2
- 真特么垃圾,史上最垃圾的库 HOT 1
- Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.wm.Task.inPinnedWindowingMode()' on a null object reference
- 通过三方插件对ARouter提供KSP注解处理器支持, 帮助大家移除KAPT、提升kotlin项目编译速度
- It's outrageous, why is it strongly related to the calling order of the code:
- Fork了一个版本,适配了AGP8.0,可直接远程引用,链接见内
- 希望能适配 APG 7.3+ HOT 5
- 初始化耗时-BlockCanaryContext检测
- AS 火烈鸟 构建性能提示 HOT 2
- The following annotation processors are not incremental: jetified-arouter-compiler-1.1.4.jar (com.alibaba:arouter-compiler:1.1.4). Make sure all annotation processors are incremental to improve your build speed. :module_device:compileYF_PRODebugJavaWithJavac spend 78ms
- 安卓Android 7.1.1报错:
- Android7.1.1报错:Attempt to read from field 'java.lang.String com.android.server.am.ActivityRecord.packageName' on a null object reference,具体信息如下:
- 同时使用arouter 和 hilt报错 HOT 7
- 基于 KSP 和 AGP 8 的重构版本 HOT 3
- 自定义类型值不传崩溃
- It will caused NullPointException if we implement the interface of 'PretreatmentService' with Kotlin language
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arouter.