KotlinAndroid icon indicating copy to clipboard operation
KotlinAndroid copied to clipboard

在项目根目录下新建一个文件夹,将Module移入该文件夹时,APK安装不了

Open leach-chen opened this issue 6 years ago • 9 comments

在项目根目录下新建一个文件夹,将Module移入该文件夹时,APK安装不了,安装时android studio 弹窗提示如下:

Installation failed with message INSTALL_FAILED_INVALID_APK. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.

WARNING: Uninstalling will remove the application data!

Do you want to uninstall the existing application?

请问如何解决?是不是要修改插件PluginSwitch代码,还一个问题是插件里面输出的日志在哪查看,我好像没找到

leach-chen avatar Jan 25 '19 09:01 leach-chen

解决了,之前不知道怎么调试这个plugin,一调试就发现问题在哪了。加了一层目录后,拿到的module名称前会加上这个目录的名称。String module = project.path.replace(":", "")

leach-chen avatar Jan 25 '19 09:01 leach-chen

isRegisterAuto applicationName 的作用不是很明白,能说下具体作用么?

leach-chen avatar Jan 25 '19 10:01 leach-chen

这个插件提供两种加载组件的方式: 第1种是通过字节码插桩的方式,就是在dex之前扫描所有的IApplicationLoad的子类,然后在主项目的Application中调用; 第2种是反射的方式,手动在Application中通过反射的方式调用IApplicationLoad的子类对应的方法。该Application就是isRegisterAuto属性配置的。

guofudong avatar Jan 25 '19 12:01 guofudong

isRegisterAuto为false的时候使用的是字节码的方式,如果为true,就会走applicationName配置的类,在onCreate()中要手动注册组件。

guofudong avatar Jan 25 '19 12:01 guofudong

哦哦,再问下,CompileCodeTransform里面的 void transform 函数什么时候执行,我debug的时候执行不到该函数。

leach-chen avatar Jan 29 '19 05:01 leach-chen

哦哦,再问下,CompileCodeTransform里面的 void transform 函数什么时候执行,我debug的时候执行不到该函数。

编译的时候:class文件 -> dex,插件和依赖库中的断点是走不到的。

guofudong avatar Jan 29 '19 06:01 guofudong

哦,那这段代码怎么调试呢?这块打印的log在哪可以看到吗,我现在运行有问题,不知道是不是改了目录的原因

leach-chen avatar Jan 29 '19 06:01 leach-chen

找到输出的地方了

leach-chen avatar Jan 29 '19 06:01 leach-chen

找到输出的地方了

ok

guofudong avatar Jan 29 '19 08:01 guofudong