Robospice Unable to start SpiceManager as a class service

I am trying to use the following libraries to develop my application.

  • Robospice

  • Gson

  • and Spring for android

To do this, in my gradle file I have the following dependencies added

compile 'com.octo.android.robospice:robospice-spring-android:1.4.13'
compile 'com.google.code.gson:gson:2.2.4'

      

And in the manifest file, I have the following lines inserted inside the application tag.

<service
    android:name="com.octo.android.robospice.GsonSpringAndroidSpiceService"
    android:exported="false" />

      

Now I have created a base class that is used as a base activity. And I did it like this:

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;
    }  
}

      

And then I used this base class to extend my own class where I had to use a spice service request.

SimpleTextRequest text = new SimpleTextRequest(placeUrl);   
getSpiceManager().execute(text, "place", DurationInMillis.ONE_MINUTE, new RequestListener<String>() { 

    //Other functions and codes

    }
)

      

But when the above code runs I get the following error

 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)

      

I have been trying to solve the problem from many hours. Unfortunately, this did not happen. Please help me.

+3


source to share


3 answers


I am 100% sure that you are confused somewhere. Search new SpiceManager(SpiceService.class);

in your code and you will know that you are using this service instead of what you want GsonSpringAndroidSpiceService

.



+2


source


You need to declare your service in your manifest. xml Like this



<service android:name=".SampleRetrofitService"
        android:exported="false"/>

      

+1


source


Try to figure out where to use SpiceManager. In my case, I named the activity SpiceActivity and others have extended it. But the robospice library also offers an activity called SpiceActivity. And it uses the new SpiceManager (SpiceService.class)

So the Activity extends the wrong SpiceActivity that uses the SpiceService and then throws an error.

0


source







All Articles