I'm building an Android app in which I want to use the ActiveAndroid ORM. In the readme I read instructions on how to include it in Maven or ADT, but I'm using/trying to learn Android Studio with Gradle. So I guess I need to insert ActiveAndroid as a dependency. in my build.gradle file on these lines:
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
I don't really know what kind of string/url I should use so that Gradle can automatically find ActiveAndroid and compile it into my project.
Sicne I'm kinda lost; could anybody give me a tip here on how I should be tackling this?
[EDIT]
I now build the jar and compiled it using the suggested compile files('libs/ActiveAndroid.jar')
(I have no version name in my jar file). It now builds successfully, but I still cannot import classes from it. See the image below:
Give this a go - download the JAR from here
Add it to your libs folder.
Change your dependancies to look something like this
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile files('libs/ActiveAndroid-3.3.jar')
}
Maybe this is new since this question was answered, but this is in the getting started guide:
Modify your build.gradle to include:
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
https://github.com/pardom/ActiveAndroid/wiki/Getting-started
Download the JAR from this link
OR
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
I can't answer the comment since I don't have enough rep yet, but make sure you sync your project with your gradle files again after adding the .jar to your dependencies.
Tools > Android > Sync Project with Gradle Files
- Please make sure dependencies are added in individual module build.gradle file and NOT the common build.gradle file?
- Also, under "Open Module Settings" make sure the dependencies are present under the "dependencies" tab of the app.
- After you add the jar file to "libs" folder, build again and check if there is a build.gradle for ActiveAndroid module.This is what it should look like or a variation of this:
configurations.create("default")
def jarFile = file('ActiveAndroid.jar')
artifacts.add("default", jarFile)
Bit of an old question but having just run into this issue as I'm getting up to speed with both Android Studio/Gradle and AndroidActive, the documentation tells you what you need to add, but expects you to know how to add it. Basically in the build.gradle for the app (not the project). Add the repositories at the top of the file (if it doesn't exist already) and add the compile statement to the end of the dependencies section. I've attached screen shot of my Gradle file that worked.
My full build.gradle(app) with ActiveAndroid:
buildscript {
repositories {
mavenCentral()
}
dependencies {
}
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.michaelpardo:activeandroid:+'
// other dependencies
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName '1'
multiDexEnabled true
}
}