gpt4 book ai didi

gson - Robospice 不可能在没有服务的情况下启动 SpiceManager

转载 作者:行者123 更新时间:2023-12-01 00:58:17 29 4
gpt4 key购买 nike

我正在尝试使用以下库来开发我的应用程序。

  • Robospice
  • Gson
  • 和 Spring for android

  • 为此,在我的 gradle 文件中,我添加了以下依赖项
    compile 'com.octo.android.robospice:robospice-spring-android:1.4.13'
    compile 'com.google.code.gson:gson:2.2.4'

    在 list 文件中,我在应用程序标签中插入了以下几行。
    <service
    android:name="com.octo.android.robospice.GsonSpringAndroidSpiceService"
    android:exported="false" />

    现在,我创建了一个用作基本事件的基类。而且,我通过以下方式做到了这一点:
    public class BaseSpiceActivity extends Activity {
    private SpiceManager spiceManager = new SpiceManager(GsonSpringAndroidSpiceService.class);

    @Override
    protected void onStart() {
    spiceManager.start(this);
    super.onStart();
    }

    @Override
    protected void onStop() {
    spiceManager.shouldStop();
    super.onStop();
    }

    protected SpiceManager getSpiceManager() {
    return spiceManager;
    }
    }

    然后我使用该基类来扩展我自己的类,在那里我必须使用 spice 服务请求。
    SimpleTextRequest text = new SimpleTextRequest(placeUrl);   
    getSpiceManager().execute(text, "place", DurationInMillis.ONE_MINUTE, new RequestListener<String>() {

    //Other functions and codes

    }
    )

    但是当上面的代码被执行时,我收到以下错误
     E/AndroidRuntime﹕ FATAL EXCEPTION: SpiceManagerThread 0
    java.lang.RuntimeException: Impossible to start SpiceManager as no service of class : com.octo.android.robospice.SpiceService is registered in AndroidManifest.xml file !
    at com.octo.android.robospice.SpiceManager.checkServiceIsProperlyDeclaredInAndroidManifest(SpiceManager.java:1287)
    at com.octo.android.robospice.SpiceManager.tryToStartService(SpiceManager.java:1168)
    at com.octo.android.robospice.SpiceManager.run(SpiceManager.java:247)
    at java.lang.Thread.run(Thread.java:856)

    我一直在尝试解决这个问题很多小时。但遗憾的是不能。请帮帮我。

    最佳答案

    我 100% 确定你在某个地方搞砸了。搜索 new SpiceManager(SpiceService.class);在您的代码中,您会发现您确实使用此服务而不是所需的 GsonSpringAndroidSpiceService .

    关于gson - Robospice 不可能在没有服务的情况下启动 SpiceManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25812082/

    29 4 0
    文章推荐: javascript - 如何在js中创建文件对象?
    文章推荐: Javascript - for 循环中的 Axios。使用当前获取的响应进行下一次获取数据的迭代
    文章推荐: jQuery slider 未捕获类型错误 : Object # has no method 'data'