Reputation: 1604
I am using realm database
to maintain product log in my app.! my app getting a crash while configuring realm builder.! I used the following code to configure the realm builder.
RealmConfiguration configuration = new RealmConfiguration.Builder(AddProductItems.this).build();
realm = Realm.getInstance(configuration);
realmHelper = new RealmHelper(realm);
I have also tried this code too.
realm = Realm.getInstance(MyActivity.this);
I am still getting the same error.I am using Android Studio 3.0 beta 2
and 3.0.0-beta2 of gradle version
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "come.ajay.bill"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.0.0'
testImplementation 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:26.0.0'
compile 'com.android.support:cardview-v7:26.0.0'
provided 'io.realm:realm-android:0.87.5'
annotationProcessor 'io.realm:realm-android:0.87.5'
}
gradle(Project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here i add my console log
Upvotes: 1
Views: 417
Reputation: 81539
provided 'io.realm:realm-android:0.87.5'
That won't work because that means you're not actually including Realm in your code (which is why you're getting the error you're getting).
In AS 3.0, provided
should be replaced by compileOnly
However in your case, it should be
implementation 'io.realm:realm-android:0.87.5'
annotationProcessor 'io.realm:realm-android:0.87.5'
(I hope that works, because there is a chance you'll just get the following error - I have not tested this:
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
Alternatively, set
android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
)
It's worth noting that Realm 0.88.0 to 2.1.1 does NOT support annotationProcessor
scope yet (only apt
scope, which is NOT supported by AS 3.0!) if you use apply plugin: 'realm-android'
, in which case you'd need to manually do what the Realm Gradle Plugin does in the background (add the right dependencies + register the RealmTransformer task)
Also worth noting that the latest version at this time is Realm-Java 5.7.0, which is much newer than 0.87.5.
Upvotes: 2