Reputation: 424
I downloaded this : https://static.realm.io/downloads/java/realm-java-0.88.2.zip Then imported the "examples" folder inside Android Studio.
I can run examples but Android Studio cannot resolve symbols for Realm classes.
Is there something missing in this example project ? I want to enable completion.
Edit :
When I add "compile 'io.realm:realm-android:0.87.5'" to the build.gradle,
this error occur :
[...]
:introExample:generateDebugSources UP-TO-DATE
:introExample:compileDebugJavaWithJavac
Note: Processing class Cat
Note: Processing class Dog
Note: Processing class Person
Note: Creating DefaultRealmModule
:introExample:compileDebugNdk UP-TO-DATE
:introExample:compileDebugSources
:introExample:transformClassesWithRealmTransformerForDebug
:introExample:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lio/realm/RealmCache$Callback;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
FAILED
FAILURE: Build failed with an exception.
[...]
Upvotes: 0
Views: 4108
Reputation: 12953
Just try to include this in you dependencies inside your build.gradle file like:
compile 'io.realm:realm-android:0.87.5'
It is the last version that is provided without a Gradle plugin.
Upvotes: 1
Reputation: 424
The issue come from the main build.gradle.
Replace this :
allprojects {
def currentVersion = file("${rootDir}/../version.txt").text.trim()
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'com.novoda:gradle-android-command-plugin:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "io.realm:realm-gradle-plugin:${currentVersion}"
}
}
group = 'io.realm'
version = currentVersion
repositories {
mavenLocal()
jcenter()
}
}
By something like this :
buildscript {
def currentVersion = file("${rootDir}/../version.txt").text.trim();
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'com.novoda:gradle-android-command-plugin:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "io.realm:realm-gradle-plugin:0.88.2"
}
}
allprojects {
group = 'io.realm'
version = "0.88.2"
repositories {
mavenLocal()
jcenter()
}
}
Upvotes: 1
Reputation: 81529
Since v0.88.0, you need to use the AAR configuration (using Gradle), by adding the Realm plugin to the application classpath and applying the plugin.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:0.88.2"
}
}
apply plugin: 'realm-android'
Upvotes: 2