CBLiteConsole is a debugging tool for apps based on Couchbase Lite.
Drop CBLiteConsole into a Couchbase Lite app and:
- Show stats about the db
- Show the raw contents of the db
- Add sample docs
- Delete all docs
- View logcat logs
- View status of replications
This will assume the same project layout as Grocery-Sync Android
|-- GrocerySync-Android
| |-- GrocerySync-Android-GrocerySync-Android.iml
| |-- build
| |-- build.gradle
| |-- libs
| `-- src
|-- GrocerySync-Android.iml
|-- README.md
|-- build.gradle
|-- gradle
| `-- wrapper
|-- gradlew
|-- gradlew.bat
|-- local.properties
|-- local.properties.example
`-- settings.gradle
$ git submodule add https://github.com/couchbaselabs/CBLiteConsole.git CBLiteConsole
your directory structure should now look like:
|-- CBLiteConsole
| |-- README.md
| |-- build.gradle
| |-- libs
| `-- src
|-- GrocerySync-Android
| |-- GrocerySync-Android-GrocerySync-Android.iml
| |-- build
| |-- build.gradle
| |-- libs
| `-- src
|-- GrocerySync-Android.iml
|-- README.md
|-- etc..
Update settings.gradle to tell it about the new module.
Before:
include ':GrocerySync-Android'
After:
include ':GrocerySync-Android', ':CBLiteConsole'
In the case of Grocery-Sync, this is the file GrocerySync-Android/GrocerySync-Android/build.gradle:
Before:
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.couchbase.cblite:CBLite:0.7.2'
...
}
After:
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.couchbase.cblite:CBLite:0.7.2'
...
compile project(':CBLiteConsole')
}
Under the application
element, add the following activities:
<activity
android:name="com.couchbase.cblite.cbliteconsole.CBLiteConsoleActivity"
android:label="@string/console_activity_display_message"
android:parentActivityName="com.couchbase.couchbaseliteproject.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.couchbase.couchbaseliteproject.MainActivity" />
</activity>
<activity
android:name="com.couchbase.cblite.cbliteconsole.AllDocsActivity"
android:label="@string/title_activity_all_docs" >
</activity>
If your project uses Couchbase Lite maven artifacts, you will need to do a small hack to CBLiteConsole/build.gradle.
Before:
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile project(':CBLite')
compile project(':CBLiteEktorp')
}
After:
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.couchbase.cblite:CBLite:0.7.2'
compile 'com.couchbase.cblite:CBLiteEktorp:0.7.4'
}
This could be in a button handler, in response to shaking the phone, or wherever you want to put it.
Intent intent = new Intent(MainActivity.this, CBLiteConsoleActivity.class);
Bundle b = new Bundle();
b.putString(CBLiteConsoleActivity.INTENT_PARAMETER_DATABASE_NAME, DATABASE_NAME);
intent.putExtras(b);
startActivity(intent);
NOTE: you will need to define the DATABASE_NAME variable to contain the database name your app uses.