Java – use gradle with jcenter in Android studio
Editor: I've made it clear. I implemented jbaruch's suggestion for the all projects - > repositories section of the project wide build. Gradle file
I am writing a project that relies on ioio. Compiling ioio libraries on my project has caused me trouble. I try to put. AAR and. Jar files directly in my LIBS / directory. However, using. AAR files in gradle has proved to be a trouble. Now, I am trying to find these libraries using jcenter
Using jcenter as my repository, gradle initially failed to resolve
com.github.ytai.ioio:IOIOLibCore
However, specifying the version number 5.05 can solve this problem. However, gradle cannot solve it now
com.sparetimelabs:purejavacomm:0.0.22
This is not the library I asked to compile with the project
Here is a copy of my app / build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.agrc.elkausbtransfer"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.github.ytai.ioio:IOIOLibCore:5.05'
compile 'com.github.ytai.ioio:IOIOLibPC:5.05'
compile 'com.github.ytai.ioio:IOIOLibAndroid:5.05'
compile 'com.github.ytai.ioio:IOIOLibAndroidAccessory:5.05'
compile 'com.github.ytai.ioio:IOIOLibAndroidDevice:5.05'
/* To use IOIO from source
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'IOIOLibAndroid-release', ebxt: 'aar')
compile(name: 'IOIOLibAndroidAccessory-release', ext: 'aar')
compile(name: 'IOIOLibAndroidDevice-release', ext: 'aar')
*/
}
After trying jbaruch's suggestion and adding Maven URL to my project (root) build.gradle file, I noticed that the gradle build file is as follows:
Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature.
FAILURE: Build Failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.sparetimelabs:purejavacomm:0.0.22.
Searched in the following locations:
https://jcenter.bintray.com/com/sparetimelabs/purejavacomm/0.0.22/purejavacomm-0.0.22.pom
https://jcenter.bintray.com/com/sparetimelabs/purejavacomm/0.0.22/purejavacomm-0.0.22.jar
file:/home/eric/Libs/Android/extras/android/m2repository/com/sparetimelabs/purejavacomm/0.0.22/purejavacomm-0.0.22.pom
file:/home/eric/Libs/Android/extras/android/m2repository/com/sparetimelabs/purejavacomm/0.0.22/purejavacomm-0.0.22.jar
file:/home/eric/Libs/Android/extras/google/m2repository/com/sparetimelabs/purejavacomm/0.0.22/purejavacomm-0.0.22.pom
file:/home/eric/Libs/Android/extras/google/m2repository/com/sparetimelabs/purejavacomm/0.0.22/purejavacomm-0.0.22.jar
required by:
ElkaUsbTransfer:app:unspecified
ElkaUsbTransfer:app:unspecified > com.github.ytai.ioio:IOIOLibPC:5.05
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD Failed
Total time: 2.061 secs
That is, gradle does not search the Maven web address provided. How can I force gradle to do this?
resolvent:
Com.sparetimelabs: purejavacomm: 0.0.22 is a transitive dependency of the ioio project. The problem is that the spare time lab has its own repository and will not publish its artifacts to binray. What you need to do is to add its repository to the repository list in gradle:
repositories {
jcenter()
maven {
url 'http://www.sparetimelabs.com/maven2'
}
}