2

Total Method Count in my project is155,323. There are many libraries i am using. First i was using play services like this.

compile 'com.google.android.gms:play-services:9.0.1'

I was getting ClassDefNotFound error in GoogleVR: related classes.

Then i removed the general library of play-services, and added the specific ones. The error was gone. I was happy and surprised.

Unfortunately the error has come again, Just after adding the following library i am getting ClassDefNotFound in one of my class.

repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
}

dependencies {
    compile 'com.commonsware.cwac:merge:1.1.+'
}

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/video_lib/android/utils/NetworkClient;

If i remove commonsware library, It works fine, but the commonsware library is essential for some other API, and i have to use it.

The error may be due to gradle conflict. Kindly guide me how to identify and remove gradle-conflict.

dev90
  • 7,187
  • 15
  • 80
  • 153

2 Answers2

0

Run gradle app:dependencies to view the dependency tree. Look for the multiple versions of the same library and / or multiple versions of libraries from the same family. Then use force to leave only one of them.

Ivan
  • 3,781
  • 16
  • 20
  • Thanks, I haven't worked on `gradle app:dependencies`. Kindly guide me or share a link from where i can learn how to execute `gradle app:dependencies`, and do i need to write anything on build.grade to forcefully remove libraries. – dev90 Oct 31 '16 at 12:59
  • @Kirmani88 You can start from [Gradle userguide dependency management section](https://docs.gradle.org/current/userguide/dependency_management.html). Forcing described in [24.8.2. Using dependency resolve rules](https://docs.gradle.org/current/userguide/dependency_management.html#sec:forcing_modules). [Excluding transitive dependencies](https://docs.gradle.org/current/userguide/dependency_management.html#sub:exclude_transitive_dependencies) in corresponding section of that guide. – Ivan Oct 31 '16 at 13:39
  • 1
    @Kirmani88 as for executing gradle command, you can use the gradle wrapper script android studio should have created in your project's root as described in http://stackoverflow.com/questions/24398041/build-android-studio-app-via-command-line – Ivan Oct 31 '16 at 13:42
  • Thanks a lot. Can you also answer this one as well http://stackoverflow.com/questions/40346988/how-to-exclude-multiple-file-reference-from-gradle-file – dev90 Oct 31 '16 at 17:12
-1

Just in case for Multi-dex issue where the method count exceeds 64k limit use
compile 'com.android.support:multidex:1.0.0'

enable the multidex support in your gradle file multiDexEnabled true

n your manifest add the MultiDexApplication class from the multidex support library to the application element.

Amardeep
  • 1,414
  • 11
  • 18