I am trying to integrate android studio with CouchBAse Lite. this tutorial.
Below is my code which I implemented for creating a document
package mmt.com.couchbasehelloworld;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import com.couchbase.lite.CouchbaseLiteException;
import com.couchbase.lite.Database;
import com.couchbase.lite.Document;
import com.couchbase.lite.Manager;
import com.couchbase.lite.android.AndroidContext;
import com.couchbase.lite.util.Log;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
public static final String DB_NAME = "couchbaseevents";
public static final String TAG = "couchbaseevents";
private String createDocument(Database database) {
// Create a new document and add data
Document document = database.createDocument();
String documentId = document.getId();
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "Big Party");
map.put("location", "My House");
try {
// Save the properties to the document
document.putProperties(map);
} catch (CouchbaseLiteException e) {
Log.e(TAG, "Error putting", e);
}
return documentId;
}
private void helloCBL() {
Manager manager = null;
Database database = null;
try {
manager = new Manager(new AndroidContext(this), Manager.DEFAULT_OPTIONS);
database = manager.getDatabase(DB_NAME);
} catch (Exception e) {
Log.e(TAG, "Error getting database", e);
return;
}
// Create the document
String documentId = createDocument(database);
/* Get and output the contents */
// outputContents(database, documentId);
/* Update the document and add an attachment */
//updateDoc(database, documentId);
// Add an attachment
//addAttachment(database, documentId);
/* Get and output the contents with the attachment */
//outputContentsWithAttachment(database, documentId);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
helloCBL();
Log.d(TAG, "Begin Couchbase Events App");
Log.d(TAG, "End Couchbase Events App");
}
}
Below is my Consol output
05-02 17:55:43.317 32217-32217/mmt.com.couchbasehelloworld I/art: Not late-enabling -Xcheck:jni (already on)
05-02 17:55:45.723 32217-32217/mmt.com.couchbasehelloworld W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-02 17:55:45.964 32217-32217/mmt.com.couchbasehelloworld E/UCI4C: u_getDataDirectory()=/data/user/0/mmt.com.couchbasehelloworld/files/icu
05-02 17:55:46.161 32217-32273/mmt.com.couchbasehelloworld D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 05-02 17:55:46.166 32217:32217 D/ ]
HostConnection::get() New Host Connection established 0xaa97fd10, tid 32217
[ 05-02 17:55:46.221 32217:32273 D/ ]
HostConnection::get() New Host Connection established 0xaa97fe90, tid 32273
05-02 17:55:46.228 32217-32273/mmt.com.couchbasehelloworld I/OpenGLRenderer: Initialized EGL, version 1.4
05-02 17:55:46.346 32217-32273/mmt.com.couchbasehelloworld W/EGL_emulation: eglSurfaceAttrib not implemented
05-02 17:55:46.346 32217-32273/mmt.com.couchbasehelloworld W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb2a9e100, error=EGL_SUCCESS
05-02 17:57:36.917 1188-1188/mmt.com.couchbasehelloworld W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-02 17:57:37.130 1188-1188/mmt.com.couchbasehelloworld E/UCI4C: u_getDataDirectory()=/data/user/0/mmt.com.couchbasehelloworld/files/icu
05-02 17:57:37.351 1188-1284/mmt.com.couchbasehelloworld D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 05-02 17:57:37.388 1188: 1188 D/ ]
HostConnection::get() New Host Connection established 0xaa97fd30, tid 1188
[ 05-02 17:57:37.451 1188: 1284 D/ ]
HostConnection::get() New Host Connection established 0xaa97fed0, tid 1284
05-02 17:57:37.458 1188-1284/mmt.com.couchbasehelloworld I/OpenGLRenderer: Initialized EGL, version 1.4
05-02 17:57:37.553 1188-1284/mmt.com.couchbasehelloworld W/EGL_emulation: eglSurfaceAttrib not implemented
05-02 17:57:37.553 1188-1284/mmt.com.couchbasehelloworld W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb2a9e320, error=EGL_SUCCESS
05-02 17:57:37.623 1188-1194/mmt.com.couchbasehelloworld W/art: Suspending all threads took: 66.978ms
But the tutorial says output should be like
05-16 19:46:57.933 31719-31719/com.couchbase.helloworld D/HelloWorld docContent={message=Hello Couchbase Lite, creationDate=2014-05-16T19:46:57.938Z} 05-16 19:46:57.949 31719-31719/com.couchbase.helloworld D/HelloWorld﹕ Document written to database named hello with ID = b4e23b69-0aad-4a66-9fd6-3b8fc64694d1
which does not match with my output. Please help. Thanx