Android Native Mobile First depends on too many libs?

250 Views Asked by At

I am currently playing around with Bluemix and Mobile First Platform researching whether it might fit my needs as backend for the Android app I am developing.

Starting from an empty Android project I have only successfully implemented IBM Push Notification. I followed this official sample.

My next step was to implement the lib Couchbase Lite for Android (so far the data I will used is placed in my own CouchDB service). To do so I added the dependency to Gradle so the file looked like this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "es.woozycoder.android.bluemixpayaround"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'

    compile group: 'com.ibm.mobilefirstplatform.clientsdk.android',
            name:'core',
            version: '1.+',
            ext:'aar',
            transitive: true

    compile group: 'com.ibm.mobilefirstplatform.clientsdk.android',
            name: 'push',
            version: '1.+',
            ext: 'aar',
            transitive: true

    compile 'com.couchbase.lite:couchbase-lite-android:1.1.0'
}

What is my surprise when I compile and see the following error which I believe is closely related to too many dependencies.

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_72\bin\java.exe'' finished with non-zero exit value 2

The answer linked above suggests that Google Play Services dependency would be the problem and I agree as the lib Push depends on the whole google-services lib instead of only the specific ones (I guess those would be gcm (com.google.android.gms:play-services-gcm) and base (com.google.android.gms:play-services-base)).

Has anyone an idea of what could be the solution to this issue?

UPDATE

  1. This is a native Gradle-based Android Application created with Android Studio.
  2. The problem arises at the moment I add the couchbase-lite-android dependency.
  3. I have seen that the lib googleauthentication also depends on the whole lib com.google.android.gms:play-services instead of the specific ones only.

UPDATE 2

Here is the Github project. Pull it and compile. You'll see that it compiles and runs successfully. But, now uncomment the couchbase-lite dependecy in the module's gradle.build. Now, build the project. It will fail.

1

There are 1 best solutions below

1
On

It is not clear from your question if you are actually developing a Hybrid Android app or a native one...

If you are developing a native app and adding the MFP SDK to it, then you should create a Gradle-based Android project in Android Studio.

If you are developing a Hybrid Android app in MobileFirst Studio then you have two options:

  1. If using MPF 7.0/7.1, try adding ProGuard support which will help in decrease the amount of files and maybe solve this
  2. Import the generated Android project into Android Studio and convert it to a Gradle-based project, and then add Google Play Services. Of course, the next time you will build the app in MFP Studio, it will not be Gradle-based, so you will have to repeat this step.

As you may have guessed, MFP does not support Gradle-based projects at this time.