Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请注意每个插件apk构建时都需要apply plugin: 'com.tencent.shadow.plugin' #871

Closed
1 task
lks6123 opened this issue Mar 28, 2022 · 4 comments
Closed
1 task

Comments

@lks6123
Copy link
Contributor

lks6123 commented Mar 28, 2022

我在自己写的Demo时,启动插件时爆出了这个问题。

2022-03-28 19:44:03.556 30795-30832/com.leelu.shadow E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
    Process: com.leelu.shadow, PID: 30795
    java.lang.RuntimeException: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.Error: 请注意每个插件apk构建时都需要apply plugin: 'com.tencent.shadow.plugin'
        at com.leelu.plugin_manager.SamplePluginManager$1.run(SamplePluginManager.java:164)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)
     Caused by: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.Error: 请注意每个插件apk构建时都需要apply plugin: 'com.tencent.shadow.plugin'
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2433)
        at android.os.Parcel.createException(Parcel.java:2409)
        at android.os.Parcel.readException(Parcel.java:2392)
        at android.os.Parcel.readException(Parcel.java:2334)
        at com.tencent.shadow.dynamic.manager.BinderPluginLoader.loadPlugin(BinderPluginLoader.java:47)
        at com.leelu.plugin_manager.FastPluginManager.loadPlugin(FastPluginManager.java:127)
        at com.leelu.plugin_manager.SamplePluginManager$1.run(SamplePluginManager.java:142)

代码 pr 上来了。 大佬帮我看看。 搞了两天了。 还是没搞定。
代码在 sample 目录下面。 是一个单独的 Project 。 是通过maven依赖的方式, shadow是最新的shadow sdk 源码编译到本地maven 仓库的。

@SpaceQ-Z
Copy link
Contributor

你这在自己仓库下搞呀,发到公有仓库干什么。。。

@shifujun
Copy link
Collaborator

问题的原因是你添加flavorDimensions时把Shadow自动添加的给覆盖掉了。

所以这样修改就可以了:
shifujun@7d9f8a7

刚刚也新增了这种情况的提示检查:
#875

@lks6123
Copy link
Contributor Author

lks6123 commented Mar 29, 2022

原来是这样,感谢大佬!!

@lks6123 lks6123 closed this as completed Mar 29, 2022
@lks6123
Copy link
Contributor Author

lks6123 commented Mar 29, 2022

问题的原因是你添加flavorDimensions时把Shadow自动添加的给覆盖掉了。

所以这样修改就可以了: shifujun@7d9f8a7

刚刚也新增了这种情况的提示检查: #875

按大佬你这个改了下,发现还是会报这个错误。研究了下,按你给出的那个思路,猜测应该还是把shadow自动添加的给覆盖了。这样写 productFlavors 就没问题了

    flavorDimensions(*flavorDimensionList, 'type')
    // 将插件applicationId设置为和宿主相同
    productFlavors {
        plg {
            applicationId "com.leelu.shadow"
            dimension "type"
        }
        app {
            dimension "type"
        }
    }

引入 flavorDimensions 之后,关键在于 productFlavors 中不能用 plugin 来作为一个渠道。否则会覆盖 shadow 的渠道,package 出来之后,还是会提示 ”请注意每个插件apk构建时都需要apply plugin: 'com.tencent.shadow.plugin' “

或者这样写也可以:

//    flavorDimensions(*flavorDimensionList, 'type')
    // 将插件applicationId设置为和宿主相同
    productFlavors {
        plugin {
            applicationId "com.leelu.shadow"
        }
    }

去掉 flavorDimensions 的情况下,可以在 productFlavors 中写 plugin 渠道。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants