简体   繁体   中英

Android Studio build.gradle compile error

I'm using a the MPAndroidChart to plot graphs in my android application. I am doing a radar plot, a pie chart and a line graph. My problem is that the radar plot needs a different version of this library which does not work for the other two plots.

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

compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'

compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'


}

As you can see in my dependancies I compile two different versions. This causes errors and only one of them will work therefore either the radar plot will not work, or else the other two won't work.

Does anyone know how I can compile two versions of the same library?

To download multiple version of the same library:

repositories {
  mavenCentral()
}

configurations {
  compile5
  compile6
}

dependencies {
  compile5 'org.osgi:org.osgi.core:5.0.0'
  compile6 'org.osgi:org.osgi.core:6.0.0'
}

task libs(type: Sync) {
  from configurations.compile5
  from configurations.compile6
  into "$buildDir/libs"
}

You can check How to get Multiple Versions of the same library

There were major changes with MPCharts in v3.0.0 vs 2.xx

I think you would be better off using the latest library and adjusting the two charts that are not working properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM