当前位置: 首页 > 知识库问答 >
问题:

错误:任务“:app:CompileDebugJavaWithJavac”执行失败。>扩展RealmObject类后编译失败

狄新翰
2023-03-14
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'
    classpath "io.realm:realm-gradle-plugin:2.1.1"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

task clean(type: Delete) {
 delete rootProject.buildDir
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
    applicationId "com.app.practice.realm.realmpractice"
    minSdkVersion 18
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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.0.0'
testCompile 'junit:junit:4.12'
 }
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

编译失败;有关详细信息,请参阅编译器错误输出。

用户类:

package com.app.practice.realm.realmpractice;

import io.realm.RealmObject;

public class User extends RealmObject {

private int id;
private String name;
}

Myapplication文件

import android.app.Application;

import io.realm.Realm;

public class MyApplication extends Application {

@Override
public void onCreate() {
    super.onCreate();
    Realm.init(this);
}
}
Note: Processing class User
Note: Creating DefaultRealmModule
An exception has occurred in the compiler (1.8.0_05). Please file a bug at     the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after   checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
FAILED

尝试:使用--info或--debug选项运行以获取更多日志输出。

共有1个答案

谢胤
2023-03-14

根据https://realm.io/docs/java/latest/#jackson-databind

1)制作一个名为“RX”的包

2)在包内创建一个名为“Observable”空类,如下所示:

package rx;

public class Observable {

}
 类似资料: