我正在尝试学习Realm for Android并按照https://realm.io/docs/java/latest/#installation的安装说明进行操作。
项目build.gradle文件
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
}
app level build.gradle文件
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'
}
然后我添加了一个用户扩展RealmObject的类,并试图编译项目只是为了看到evrything是好的..但我收到错误
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;
}
我的申请文件
import android.app.Application;
import io.realm.Realm;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
}
}
- Stacktrace o / p
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.
com.sun.tools.javac.code.Symbol $ CompletionFailure:找不到rx.Observable的类文件
FAILED
失败:构建因异常而失败。
出了什么问题: 任务执行失败':app:compileDebugJavaWithJavac'。
编译失败;有关详细信息,请参阅编译器错误输出。
尝试: 使用--info或--debug选项运行以获得更多日志输出。
例外情况是: org.gradle.api.tasks.TaskExecutionException:任务':app:compileDebugJavaWithJavac'执行失败。 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 在org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66) 在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) 在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) 在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor $ TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor $ TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) 在org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) 在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) 在org.gradle.execution.DefaultBuildExecuter.access $ 000(DefaultBuildExecuter.java:23) 在org.gradle.execution.DefaultBuildExecuter $ 1.proceed(DefaultBuildExecuter.java:43) 在org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) 在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) 在org.gradle.initialization.DefaultGradleLauncher $ 4.run(DefaultGradleLauncher.java:153) 在org.gradle.internal.Factories $ 1.create(Factories.java:22) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) 在org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150) 在org.gradle.initialization.DefaultGradleLauncher.access $ 200(DefaultGradleLauncher.java:32) 在org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:98) 在org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:92) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) 在org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92) 在org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83) at org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run(InProcessBuildActionExecuter.java:99) 在org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46) 在org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 在org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58) 在org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48) 在org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30) 在org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) 在org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) 在org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52) 在org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.ForwardClientInput $ 2.call(ForwardClientInput.java:74) 在org.gradle.launcher.daemon.server.exec.ForwardClientInput $ 2.call(ForwardClientInput.java:72) 在org.gradle.util.Swapper.swap(Swapper.java:38) 在org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) 在org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) 在org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) 在org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 在org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy $ 1.run(StartBuildOrRespondWithBusy.java:50) 在org.gradle.launcher.daemon.server.DaemonStateCoordinator $ 1.run(DaemonStateCoordinator.java:237) at org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl $ 1.run(StoppableExecutorImpl.java:40) 引起:org.gradle.api.internal.tasks.compile.CompilationFailedException:编译失败;请参阅编译器错误输出以获取详细信 在org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:48) 在org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33) 在org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104) 在org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53) 在org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38) 在org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35) 在org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25) 在org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:163) 在org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:145) 在org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93) 在com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49) 在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245) 在org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) ......还有70多个
答案 0 :(得分:2)
根据https://realm.io/docs/java/latest/#jackson-databind
1)创建一个名为" rx"
的包2)在名为" Observable"的包中创建一个空类。如下所示:
package rx;
public class Observable {
}