Dipendra
Dipendra

Reputation: 1557

Robospice Impossible to start SpiceManager as no service of class

I am trying to use following libraries to develop my app.

To do so, In my gradle file I have 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 manifest file, I have following lines inserted inside application tag.

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

Now, I created a base class that is used as Base Activity. And, I have did this in the following way:

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 that base class to extend my own class where I had to use 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 gets executed, I am getting 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 issue from many hours. But unfortunately couldn't. Please help me out.

Upvotes: 4

Views: 1267

Answers (3)

Kate Lee
Kate Lee

Reputation: 56

Try to find out where using SpiceManager. In my case, I named a activity SpiceActivity, and others extend it. But robospice library also offer a activity named SpiceActivity. And it uses new SpiceManager(SpiceService.class)

So activity extends the wrong SpiceActivity which use SpiceService, then cause the error.

Upvotes: 0

Dinesh Chitta
Dinesh Chitta

Reputation: 680

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

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

Upvotes: 2

Snicolas
Snicolas

Reputation: 38168

I am 100% sure you got messed somewhere. Search for new SpiceManager(SpiceService.class); in your code, and you will find out that you do use this service instead of the desired GsonSpringAndroidSpiceService.

Upvotes: 2

Related Questions