Hyperion-Android:ServiceLoader 无法加载自定义插件

Yar*_*nko 7 android kotlin

我在Hyperion github 中遇到了一个问题。我想将我的自定义项目添加到Hyperion菜单中。当我发现如果我从核心库中删除某些东西时,它们会被成功删除,反之亦然。但是如果我添加自定义Plugin- 没有任何反应。

我尝试过不同版本的Hyperion,它也不会影响结果。
另外,这里我还检查了:

  1. 混淆器
  2. 进口
  3. 依赖关系
  4. 布局检查器
  5. 带调试的源
  6. 套餐
  7. 口味
  8. 提取到单独的模块中
  9. @AutoService 注解
  10. minifyEnabled false

插入:

import com.google.auto.service.AutoService
import com.willowtreeapps.hyperion.plugin.v1.Plugin
import com.willowtreeapps.hyperion.plugin.v1.PluginModule

@AutoService(Plugin::class)
class TestPlugin : Plugin() {
    override fun createPluginModule(): PluginModule? {
        return TestPluginModule()
    }
}
Run Code Online (Sandbox Code Playgroud)

模块:

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.willowtreeapps.hyperion.plugin.v1.PluginModule


class TestPluginModule : PluginModule() {
    override fun createPluginView(layoutInflater: LayoutInflater, parent: ViewGroup): View? {
        return layoutInflater.inflate(R.layout.htest_plugin_item, parent, false)
    }
}
Run Code Online (Sandbox Code Playgroud)

依赖项:

def hyperionVersion = '0.9.27'
    debugImplementation "com.willowtreeapps.hyperion:hyperion-core:$hyperionVersion"
    debugImplementation "com.willowtreeapps.hyperion:hyperion-attr:$hyperionVersion"
    debugImplementation "com.willowtreeapps.hyperion:hyperion-crash:$hyperionVersion"
    debugImplementation "com.willowtreeapps.hyperion:hyperion-measurement:$hyperionVersion"
    debugImplementation "com.willowtreeapps.hyperion:hyperion-recorder:$hyperionVersion"
    debugImplementation "com.willowtreeapps.hyperion:hyperion-shared-preferences:$hyperionVersion"
    debugImplementation "com.willowtreeapps.hyperion:hyperion-timber:$hyperionVersion"
Run Code Online (Sandbox Code Playgroud)

注意:在屏幕截图 v0.9.26 上。但我也测试过 v0.9.27、v0.9.25、v0.9.24。

小智 4

看起来问题与@AutoService注释的处理有关。确保您已将注释处理器添加到项目中。

您应该将以下注释处理器添加到文件中build.gradle

对于Kotlin项目:

kapt 'com.google.auto.service:auto-service:1.0-rc6'

Run Code Online (Sandbox Code Playgroud)

对于Java项目:

annotationProcessor 'com.google.auto.service:auto-service:1.0-rc6'
Run Code Online (Sandbox Code Playgroud)