Installation instructions
I'm new at gradle, but i feel the instructions on the front of http://realm.io are missing info and/or don't match what android studio is doing today.
Can they be updated?
On realm.io. the instructions says "Realm is installed as a Gradle plugin." and a blob of DSL. It doesn't say how and where to put this blob of text.
The nearest match is the project build.gradle. In a newly created android studio project this has an ominous comment:
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Which reads to me as "Don't put your app stuff here". I also can't see where you'd put the last bit: apply plugin: 'realm-android'
The next guess i had was in the Module: app build.gradle. however adding classpath to the dependencies gives
Gradle DSL method not found: 'classpath()'
I have an older app that has Realm installed, but that looks more like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'io.realm:realm-android:0.87.3'
}
However updating that version to 0.88.0 results in errors. Failed to resolve: io.realm:realm-android:0.88.0
So something has changed somewhere ?? !!?
I'm new at gradle, but i feel the instructions on the front of realm.io are missing info and/or don't match what android studio is doing today.
Can they be updated?
The comment says Do not place your application dependencies, not stuff.
A dependency is something like compile 'io.realm:realm-android:0.87.3'.
It is safe, and meant to be like that, to add extra classpath commands there.
I am not an expert in Gradle, so I can not give you more details about this.
But what you have to do to include the latest release of Realm is:
- In your root
build.gradlefile, addclasspath "io.realm:realm-gradle-plugin:0.88.1"underbuildscript. dependencies. - In your module
build.gradlefile, apply the Realm plugin by addingapply plugin: 'realm-android'near the top of the file. - Remove the Realm dependency in your module
build.gradle
Hi @Br3nda You can see an example here: https://github.com/realm/realm-java/blob/master/examples/build.gradle and here: https://github.com/realm/realm-java/blob/master/examples/introExample/build.gradle
But we will look into making it clearer where the different things go.
+1
After debug for sometimes, the solution for me is to manually delete all build folder in the project then rebuild project. Android studio clean project doesn't work for me. Hope this helps.
Fixed by https://github.com/realm/realm.io/pull/1931
after i removed the Realm dependency in your module build.gradle --> it worked !