gpt4 book ai didi

java - Realm android, RealmTransformer 好像没有应用

转载 作者:太空宇宙 更新时间:2023-11-03 12:28:35 28 4
gpt4 key购买 nike

我是新手。

我使用:

  • 安卓工作室 2.2.3
  • 等级:2.14.1
  • Realm 插件:“类路径”io.realm:realm-gradle-plugin:2.2.1“”

但是当我调用 Realm.init(context) 时它抛出异常;在我的 Activity 的 onCreate 中。

日志:

12-14 16:40:51.096 3541-3541/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: *.demo, PID: 3541
java.lang.ExceptionInInitializerError: RealmTransformer doesn't seem to be applied. Please update the project configuration to use the Realm Gradle plugin. See https://realm.io/news/android-installation-change/
at io.realm.RealmConfiguration.<clinit>(RealmConfiguration.java:77)
at io.realm.RealmConfiguration$Builder.initializeBuilder(RealmConfiguration.java:414)
at io.realm.RealmConfiguration$Builder.<init>(RealmConfiguration.java:402)
at io.realm.Realm.init(Realm.java:188)
at *.demo.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

我的类(class):

import io.realm.Realm;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


Realm.init(this); //crashing line
}
}

Build.gradle 模块级别:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "*.demo"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:multidex:1.0.1'

compile 'com.github.pwittchen:reactivenetwork:0.7.0'
testCompile 'junit:junit:4.12'
}

在此先感谢您的帮助。

最佳答案

Jack 不使用 Gradle 中的转换 API。

因此,依赖于 Transform API 的 Realm-Transformer 无法与 Jack 一起使用。

使用 Retrolambda 而不是 Jack 来支持 Java 8 功能。

关于java - Realm android, RealmTransformer 好像没有应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41153879/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com