So I've been trying to use GraphView. I've imported it into my dependencies but for some reason I get a dependency resolution error. Here is my app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'android.arch.lifecycle:extensions:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.jjoe64:graphview:4.2.2'
}
But When I try to run the app, the build fail and I get the following error:
"Duplicate class com.jjoe64.graphview.GraphView found in modules GraphView-3.0.jar (GraphView-3.0.jar) and classes.jar (com.jjoe64:graphview:4.2.2)
Duplicate class com.jjoe64.graphview.GraphView$1 found in modules GraphView-3.0.jar (GraphView-3.0.jar) and classes.jar (com.jjoe64:graphview:4.2.2)
Go to the documentation to learn how to Fix dependency resolution errors."
And the line "implementation 'com.android.support:appcompat-v7:28.0.0'" shows error, and claims that I'm using both version 28.0.0 and 27.1.1.
What am I missing?
The problem probably could occur because of that both libraries use the same class. In this case it's GraphView-3.0.jar
. The compiler can't choose which one is needed to be used. So you could remove this .jar in one of the libraries and then try to use it.
Otherwise, you could just use the version of support library appcompat-v7:27.1.1
and then both libraries would use the same version and there won't be any conflict.
The similar problem and possible solution are described here: link