4

次のライブラリを使用してアプリを開発しようとしています。

  • ロボスパイス

  • Gソン

  • Android用のSpring

そうするために、私のgradleファイルには、次の依存関係が追加されています

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

マニフェスト ファイルでは、アプリケーション タグ内に次の行が挿入されています。

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

ここで、Base Activity として使用される基本クラスを作成しました。そして、私は次の方法でこれを行いました:

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)

私は何時間もの間、問題を解決しようとしてきました。しかし、残念ながらできませんでした。私を助けてください。

4

3 に答える 3

2

manifest.xml でサービスを宣言する必要があります このように

<service android:name=".SampleRetrofitService"
        android:exported="false"/>
于 2015-06-27T06:08:20.300 に答える
2

私はあなたがどこかで台無しになったと100%確信しています。コード内で を検索new SpiceManager(SpiceService.class);すると、目的の の代わりにこのサービスを使用していることがわかりますGsonSpringAndroidSpiceService

于 2014-11-01T12:45:25.060 に答える