Having Problem with ViewResult

I’m using java-client-2.2.6 and I want to query a view as with the following code:

ViewResult result = bucket.query(ViewQuery.from("dev_byType", "byType").stale(Stale.FALSE));
		// Iterate through the returned ViewRows

//		List<ViewRow> rows = result.allRows();

		for (ViewRow row : result) {

However, when I want to iterate in viewResult, I’m getting the following execption:

java.lang.IllegalStateException: This Observable can only have one subscription. Use Observable.publish() if you want to multicast.
I’m a newbie, so I couldn’t figure out what’s going on?

Below is map function of my view:

function (doc, meta) {
  emit(doc.id, meta.id);

I also tried with
function (doc, meta) {
emit(doc.id, null);

Yet, did not work.

Try this:

function (doc, meta) {
emit(meta.id, null);

for index ID

Thanks, but it did not work neither.

may be you can debug on the couchbase admin Console first.

In the console it returns ids as keys as expected.

As another point: when I switch to 2.0.3 version, the error changes to:
com.couchbase.client.java.error.TranscodingException: Could not decode View JSON.

wow, I should have guessed that.
In my map method I should have had square brackets around meta.id

function (doc, meta) {
  emit([meta.id], null);