Reputation:
I have this in my gradle file for an android studio application...`
apply plugin: 'com.android.application'
def ftcLibLocation = "../../../android/ftc_lib/ftc_app/FtcRobotController/libs"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "teamXXXX.testbot"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('${ftcLibLocation}/FtcRobotController-debug.jar')
compile files('${ftcLibLocation}/FtcCommon-release.jar')
compile files('${ftcLibLocation}/ModernRobotics-release.jar')
compile files('${ftcLibLocation}/RobotCore-release.jar')
compile files('${ftcLibLocation}/WirelessP2p-release.jar')
compile files('${ftcLibLocation}/Analytics-release.jar')
compile files('${ftcLibLocation}/d2xx.jar')
}
and yet when I compile the program gradle/android studio complains that it can't find packages that I know are located in those jars.
Error:(3, 47) error: package com.qualcomm.robotcore.eventloop.opmode does not exist
That package is located in ${ftcLibLocation}/RobotCore-release.jar why isn't the build locating it?
Upvotes: 1
Views: 3808
Reputation: 10288
There are several reasons that this could happen. Probably the most useful tool for starting is the gradle dependencies
command. It will tell you things about your dependencies that may surprise you. More about it here:
What is the Gradle artifact dependency graph command?
ftcLibLocation
is not set properly in the environment in which gradle is running. Usually gradle will display the full path during the build or you can display or log it:https://discuss.gradle.org/t/accessing-the-buildscript-classpath/5297
The jar file has been changed, but gradle cache does not know that. I run into this sometimes and I have to go to:
{userhome}\.gradle\.caches
and in there you will find a lot of folders that have cached references to libraries. Those libraries are usually remote, but I have seen problems with local libs being cached. You can delete this directory - or find the part that has the problem. Deleting will cause all your dependencies to download again, and may take awhile.
Another potential problem is Android Studio and gradle. Sometimes the plugin does not update properly. Reboot Android Studio and try again.
Upvotes: 0
Reputation: 1697
Create a libs
folder (adjacent to the src
directory) and include all your jars in that directory.
Then in your build.gradle
file, use this :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
You don't have to compile every dependency separately.
Upvotes: 1