Tencent / Shadow

零反射全动态Android插件框架
BSD 3-Clause "New" or "Revised" License
7.46k stars 1.3k forks source link

插件使用ARoute,接入宿主后,Aroute无法找到path #38

Closed SpenceAcc closed 5 years ago

SpenceAcc commented 5 years ago

有遇到过这个问题吗?

shifujun commented 5 years ago

你把代码库贴出来我们才能讨论问题呀。

SpenceAcc commented 5 years ago

07-10 22:05:16.371 11454-11454/? W/Zygote: mz_is_rooted true 07-10 22:05:16.376 11454-11454/? I/art: Late-enabling -Xcheck:jni 07-10 22:05:16.396 11454-11468/? E/art: Failed sending reply to debugger: Broken pipe 07-10 22:05:16.401 11454-11468/? I/art: Debugger is no longer active 07-10 22:05:16.411 11454-11454/? D/Proxy: setHttpRequestCheckHandler 07-10 22:05:16.416 11454-11454/? E/System: stat file error, path is /data/app/com.tencent.shadow.sample.host-1/lib/arm, exception is android.system.ErrnoException: stat failed: ENOENT (No such file or directory) 07-10 22:05:16.436 11454-11454/? I/com.tencent.shadow.dynamic.host.PluginProcessService: onCreate:com.tencent.shadow.sample.host.PluginProcessPPS@11e70387 07-10 22:05:16.436 11454-11454/? I/com.tencent.shadow.dynamic.host.PluginProcessService: onBind:com.tencent.shadow.sample.host.PluginProcessPPS@11e70387 07-10 22:05:16.441 11454-11474/? I/com.tencent.shadow.dynamic.host.PluginProcessService: setUuidManager uuidManager==com.tencent.shadow.dynamic.host.BinderUuidManager@2edbca52 07-10 22:05:16.446 11454-11475/? I/com.tencent.shadow.dynamic.host.PluginProcessService: loadRuntime uuid:DC5977C9-9A73-4DFA-82CC-3C78FAF82BAF 07-10 22:05:16.466 11454-11475/? I/com.tencent.shadow.dynamic.host.PluginProcessService: loadPluginLoader uuid:DC5977C9-9A73-4DFA-82CC-3C78FAF82BAF mPluginLoader:null 07-10 22:05:16.471 11454-11475/? I/com.tencent.shadow.dynamic.host.PluginProcessService: 取出uuid==DC5977C9-9A73-4DFA-82CC-3C78FAF82BAF的Loader apk:/data/data/com.tencent.shadow.sample.host/files/ShadowPluginManager/UnpackedPlugin/test-dynamic-manager/cd208bfed1363e7034a7c4b92452803c/plugin-debug.zip/sample-loader-debug.apk 07-10 22:05:16.551 11454-11474/? I/com.tencent.shadow.core.loader.ShadowPluginLoader: start loadPlugin 07-10 22:05:16.771 11454-11454/? I/ARouter::: ARouter openLog[ ] 07-10 22:05:16.771 11454-11454/? I/ARouter::: ARouter openDebug[ ] 07-10 22:05:16.771 11454-11454/? I/ARouter::: ARouter init start.[ ] 07-10 22:05:16.771 11454-11454/? I/ARouter::: Run with debug mode or new install, rebuild router map.[ ] 07-10 22:05:16.776 11454-11454/? I/ARouter::: VM with name 'Android' has multidex support 07-10 22:05:16.776 11454-11454/? E/ARouter::: InstantRun support error, com.android.tools.fd.runtime.Paths 07-10 22:05:16.776 11454-11454/? I/ARouter::: Thread production, name is [ARouter task pool No.1, thread No.1][ ] 07-10 22:05:16.786 11454-11454/? D/ARouter::: Filter 0 classes by packageName 07-10 22:05:16.786 11454-11454/? I/ARouter::: Find router map finished, map size = 0, cost 13 ms.[ ] 07-10 22:05:16.786 11454-11454/? I/ARouter::: Load root element finished, cost 0 ms.[ ] 07-10 22:05:16.786 11454-11454/? E/ARouter::: No mapping files were found, check your configuration please![ ] 07-10 22:05:16.791 11454-11454/? D/ARouter::: LogisticsCenter has already been loaded, GroupIndex[0], InterceptorIndex[0], ProviderIndex[0][ ] 07-10 22:05:16.791 11454-11454/? I/ARouter::: ARouter init success![ ] 07-10 22:05:16.801 11454-11454/? W/ARouter::: ARouter::There is no route match the path [/arouter/service/interceptor], in group [arouter][ ] 07-10 22:05:16.836 11454-11475/? V/Toast: SHOW: android.widget.Toast$TN@226e5975 07-10 22:05:16.836 11454-11454/? V/Toast: enqueueToast: android.widget.Toast$TN@226e5975 packageName: com.tencent.shadow.sample.host 07-10 22:05:16.836 11454-11454/? I/ARouter::: ARouter init over.[ ] 07-10 22:05:16.836 11454-11454/? V/Toast: HANDLE SHOW: android.widget.Toast$TN@226e5975 mView=null mNextView=android.widget.LinearLayout{2dbbed0a V.E..... ......I. 0,0-0,0} 07-10 22:05:16.836 11454-11454/? V/Toast: HANDLE HIDE: android.widget.Toast$TN@226e5975 mView=null 07-10 22:05:16.836 11454-11454/? V/Toast: ADD! android.widget.LinearLayout{2dbbed0a V.E..... ......I. 0,0-0,0} in android.widget.Toast$TN@226e5975 07-10 22:05:16.846 11454-11486/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 07-10 22:05:16.901 11454-11486/? I/HAL: (hw_get_module_by_class[194]):MODULE load start ==> class_id = gralloc // path = /system/lib/hw/gralloc.exynos5.so 07-10 22:05:16.906 11454-11486/? I/OpenGLRenderer: Initialized EGL, version 1.4 07-10 22:05:16.916 11454-11486/? D/OpenGLRenderer: Enabling debug mode 0 07-10 22:05:16.916 11454-11486/? D/mali_winsys: new_window_surface returns 0x3000 07-10 22:05:16.951 11454-11454/? D/com.tencent.shadow.core.loader.delegates.ShadowActivityDelegate: com.tencent.shadow.sample.plugin.app.lib.gallery.splash.SplashActivity mPluginHandleConfigurationChange==536874144 07-10 22:05:16.961 11454-11454/? V/Toast: enqueueToast: android.widget.Toast$TN@2be0d429 packageName: com.tencent.shadow.sample.host 07-10 22:05:16.986 11454-11486/? D/mali_winsys: new_window_surface returns 0x3000 07-10 22:05:16.986 11454-11486/? E/OpenGLRenderer: mFlymePerf == NULL 07-10 22:05:16.996 11454-11486/? I/HAL: (hw_get_module_by_class[194]):MODULE load start ==> class_id = gralloc // path = /system/lib/hw/gralloc.exynos5.so 07-10 22:05:17.021 11454-11486/? D/mali_winsys: new_window_surface returns 0x3000 07-10 22:05:17.036 11454-11454/? D/STATUS_BAR_TINT: onWindowAttributesChanged 07-10 22:05:18.966 11454-11454/com.tencent.shadow.sample.host:plugin W/ARouter::: ARouter::There is no route match the path [/main/MainActivity], in group [main][ ] 07-10 22:05:18.971 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: enqueueToast: android.widget.Toast$TN@3e57d2c8 packageName: com.tencent.shadow.sample.host 07-10 22:05:20.336 11454-11474/com.tencent.shadow.sample.host:plugin V/Toast: HIDE: android.widget.Toast$TN@226e5975 07-10 22:05:20.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE HIDE: android.widget.Toast$TN@226e5975 mView=android.widget.LinearLayout{2dbbed0a V.E..... ......I. 0,0-1260,272} 07-10 22:05:20.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: REMOVE! android.widget.LinearLayout{2dbbed0a V.E..... ......I. 0,0-1260,272} in android.widget.Toast$TN@226e5975 07-10 22:05:20.336 11454-11475/com.tencent.shadow.sample.host:plugin V/Toast: SHOW: android.widget.Toast$TN@2be0d429 07-10 22:05:20.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE SHOW: android.widget.Toast$TN@2be0d429 mView=null mNextView=android.widget.LinearLayout{258f0f47 V.E..... ......I. 0,0-0,0} 07-10 22:05:20.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE HIDE: android.widget.Toast$TN@2be0d429 mView=null 07-10 22:05:20.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: ADD! android.widget.LinearLayout{258f0f47 V.E..... ......I. 0,0-0,0} in android.widget.Toast$TN@2be0d429 07-10 22:05:20.381 11454-11486/com.tencent.shadow.sample.host:plugin D/mali_winsys: new_window_surface returns 0x3000 07-10 22:05:20.396 11454-11486/com.tencent.shadow.sample.host:plugin E/OpenGLRenderer: mFlymePerf == NULL 07-10 22:05:22.336 11454-11485/com.tencent.shadow.sample.host:plugin V/Toast: HIDE: android.widget.Toast$TN@2be0d429 07-10 22:05:22.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE HIDE: android.widget.Toast$TN@2be0d429 mView=android.widget.LinearLayout{258f0f47 V.E..... ........ 0,0-714,140} 07-10 22:05:22.336 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: REMOVE! android.widget.LinearLayout{258f0f47 V.E..... ........ 0,0-714,140} in android.widget.Toast$TN@2be0d429 07-10 22:05:22.336 11454-11475/com.tencent.shadow.sample.host:plugin V/Toast: SHOW: android.widget.Toast$TN@3e57d2c8 07-10 22:05:22.341 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE SHOW: android.widget.Toast$TN@3e57d2c8 mView=null mNextView=android.widget.LinearLayout{3a8109d V.E..... ......I. 0,0-0,0} 07-10 22:05:22.341 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE HIDE: android.widget.Toast$TN@3e57d2c8 mView=null 07-10 22:05:22.341 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: ADD! android.widget.LinearLayout{3a8109d V.E..... ......I. 0,0-0,0} in android.widget.Toast$TN@3e57d2c8 07-10 22:05:22.376 11454-11486/com.tencent.shadow.sample.host:plugin D/mali_winsys: new_window_surface returns 0x3000 07-10 22:05:22.411 11454-11486/com.tencent.shadow.sample.host:plugin D/mali_winsys: new_window_surface returns 0x3000 07-10 22:05:25.841 11454-11485/com.tencent.shadow.sample.host:plugin V/Toast: HIDE: android.widget.Toast$TN@3e57d2c8 07-10 22:05:25.846 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: HANDLE HIDE: android.widget.Toast$TN@3e57d2c8 mView=android.widget.LinearLayout{3a8109d V.E..... ......I. 0,0-1044,272} 07-10 22:05:25.846 11454-11454/com.tencent.shadow.sample.host:plugin V/Toast: REMOVE! android.widget.LinearLayout{3a8109d V.E..... ......I. 0,0-1044,272} in android.widget.Toast$TN@3e57d2c8

SpenceAcc commented 5 years ago

上面是plugin进程打印的日志,ARouter找不到对应的路由表。但是单独运行的时候是可以的。团队项目具体的代码不方便贴,我用sample接入ARouter的结果也和上面打印的日志一样。

shifujun commented 5 years ago

sample接入ARouter的代码总是可以给大家看的嘛。你直接给我看看,免得我还得去研究ARouter怎么接、是干什么的。在Shadow的sample里接入,我就很方便的可以看到独立安装时的效果,和在插件环境下失败的情况。应该会比较容易发现问题的。

SpenceAcc commented 5 years ago

在Shadow的sample里接入的代码如下: 1、Shadow\projects\sample\sample-plugin\sample-app-lib\build.gradle

defaultConfig { minSdkVersion project.MIN_SDK_VERSION targetSdkVersion project.TARGET_SDK_VERSION versionCode project.VERSION_CODE versionName project.VERSION_NAME javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } }

dependencies { implementation project(":slidingmenu") implementation project(":pinnedheaderexpandablelistview") implementation 'com.android.support:support-annotations:28.0.0' implementation 'com.android.support:support-v4:27.1.1' implementation 'com.alibaba:arouter-api:1.4.1' annotationProcessor 'com.alibaba:arouter-compiler:1.2.2' }

2、Shadow\projects\sample\sample-plugin\sample-app-lib\src\main\java\com\tencent\shadow\sample\plugin\app\lib\gallery\TestApplication.java

@Override public void onCreate() { sInstence = this; isOnCreate = true; super.onCreate(); if (BuildConfig.DEBUG) {
ARouter.openLog();
ARouter.openDebug(); } ARouter.init(this);
UseCaseManager.initCase(); }

3、Shadow\projects\sample\sample-plugin\sample-app-lib\src\main\java\com\tencent\shadow\sample\plugin\app\lib\gallery\splash\SplashActivity.java

mSplashAnimation.setAnimationListener(new ISplashAnimation.AnimationListener() { @Override public void onAnimationEnd() { finish(); ARouter.getInstance().build("/main/MainActivity").navigation(); //startActivity(new Intent(SplashActivity.this, MainActivity.class)); } });

4、Shadow\projects\sample\sample-plugin\sample-app-lib\src\main\java\com\tencent\shadow\sample\plugin\app\lib\gallery\MainActivity.java

@Route(path = "/main/MainActivity") public class MainActivity extends Activity implements ExpandableListView.OnChildClickListener, ExpandableListView.OnGroupClickListener, OnHeaderUpdateListener, OnGiveUpTouchEventListener {

SpenceAcc commented 5 years ago

以上黑体部分为接入ARouter的代码。

shifujun commented 5 years ago

我调试了一下,不支持ARoute主要有两个原因。 1.插件的context没有支持双参数的startActivity(Intent intent, Bundle options)方法。这个简单支持一下就好了。 2.插件中获取ApplicationInfo的实现没太设计好,从packageManager上getApplicationInfo获得的ApplicationInfo没有写入sourceDir导致ARoute根据这个路径去Dex中找自己的类找不到。这个问题需要仔细Review一下多个getApplicationInfo的实现,将它们统一起来。已经提了#40 记录。

git checkout -b sample_aroute dev
git pull https://github.com/shifujun/Shadow.git sample_aroute

做了一个临时修复。可以先看一下。

tigerjiang commented 5 years ago

@SpenceAcc 这个问题解决了吗?解决了麻烦给个回复,方便其他开发者,谢谢

shifujun commented 5 years ago

@SpenceAcc 这个问题解决了吗?解决了麻烦给个回复,方便其他开发者,谢谢

问题解决代码已经写好了。如果有空可以帮忙测一下,我自己已经测过了。在前面贴的我的sample_aroute分支上。我再找人交叉Review一下再合入。

SpenceAcc commented 5 years ago

抱歉,前两天身体不舒服,没能及时回复。 今天我尝试了修复问题的代码,发现并未生效。 验证步骤如下: 使用以下命令拉取代码 git checkout -b sample_aroute dev git pull https://github.com/shifujun/Shadow.git sample_aroute 当前代码已经是最新了,如下截图: image 然后运行sample-host。效果与之前一直,ARouter提示找不到对应页面的path。 image

shifujun commented 5 years ago

我也重新checkout了一个新分支,pull了一样的操作。

git checkout -b tmp1 dev                                     
git pull https://github.com/shifujun/Shadow.git sample_aroute

确实没问题的。

你再检查一下是否执行的是新的代码。因为你截图的命令行不是Android Studio内置的,有没有可能CMD打开的目录和Android Studio打开的不是一个目录?你看看有没有我今天提交的代码。

image

SpenceAcc commented 5 years ago

我换了一台电脑重新拉了项目,验证ARouter在宿主模式下能支持了,非常感谢@shifujun。公司的项目我周一试试看。

zhizhongbiao commented 2 years ago

抱歉,前两天身体不舒服,没能及时回复。 今天我尝试了修复问题的代码,发现并未生效。 验证步骤如下: 使用以下命令拉取代码 git checkout -b sample_aroute dev git pull https://github.com/shifujun/Shadow.git sample_aroute 当前代码已经是最新了,如下截图: image 然后运行sample-host。效果与之前一直,ARouter提示找不到对应页面的path。 image

现在最新版本是可以在host进程使用Arouter了吗

zhengjirui commented 1 year ago

https://github.com/shifujun/Shadow.git sample_aroute 我这边测试是可行的,并且在我的项目上使用androidx,ARouter.getInstance().build("/main/MainActivity").navigation() 也是可行的,但是在我的项目上使用androidx在.navigation()中添加回调,在启动插件时直接闪退,不知道有遇到的没