ben_lize
ben_lize

Reputation: 107

Too many libraries in Android Project?

I am having some issues including 4 libraries in the project. Microsoft Face Detection/Recognition, Google Play Services, libUVCamera and Firebase.

To simplify the problem, I made a project called library aggregation. The only thing it has in it are those four libraries added to it. Whenever there are any 3 libraries included, everything works fine. Adding the fourth one (which ever one it is) will cause the following error:

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_79\bin\java.exe'' finished with non-zero exit value 2

Some people on Stack overflow have recommended that there are too many methods (65k is the maximum), apparently “minifyEnabled true” would help. I have tried to clean the project, but nothing very successful. I am looking for any ideas on how I could go forward to tackling the problem. I also tried multiDex ... with no success.

Was wondering Android developers deal with this such problem in general? how do you usually deal with big libraries in Android studio?

Clue: it takes 1min 28 seconds to build … if that is of any use.

Here is my build.gradle file: Any help would be greatly appreciated.

Build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.benjaminlize.libraryaggregation"
    minSdkVersion 18
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
    }
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.microsoft.projectoxford:face:0.5.0'
compile project(':libuvccamera')
}

Regards!

Upvotes: 1

Views: 537

Answers (1)

mattm
mattm

Reputation: 5949

I think the issue is compile 'com.google.android.gms:play-services:8.3.0'.

Google has broken the play services into separate libraries that you can include separately, instead of everything together. Try including only those sections you actually need.

https://developers.google.com/android/guides/setup

My guess is that all of play services now has many functions.

Upvotes: 1

Related Questions