4

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

  • Robospice

  • Gson

  • and Spring for android

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.

Leistungsabfall
  • 6,368
  • 7
  • 33
  • 41
Dipendra
  • 1,547
  • 19
  • 33
  • @ChrisNevill Sorry, while playing around, I also tried that. But the problem was with Gson, Thanks for replying. I have corrected the question – Dipendra Sep 12 '14 at 15:57

3 Answers3

2

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.

Snicolas
  • 37,840
  • 15
  • 114
  • 173
2

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

<service android:name=".SampleRetrofitService"
        android:exported="false"/>
Dinesh Chitta
  • 670
  • 8
  • 23
0

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.

Kate Lee
  • 11
  • 1