2

我正在尝试使用 DBFlow 库进行数据库设计。之后,从网络上设置所有东西,编译时我在 Gradle 中遇到错误。

错误:

16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] 
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] 
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:compileDebugJavaWithJavac'.
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] > java.lang.NullPointerException
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] 
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
16:52:52.716 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
16:52:52.717 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:54)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:49)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
16:52:52.718 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.util.Swapper.swap(Swapper.java:38)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
16:52:52.719 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.RuntimeException: java.lang.NullPointerException
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.main.Main.compile(Main.java:553)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:45)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:101)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:50)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:36)
16:52:52.720 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:34)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:157)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:137)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:91)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    ... 57 more
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NullPointerException
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at com.raizlabs.android.dbflow.processor.definition.BaseDefinition.setOutputClassName(BaseDefinition.java:96)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at com.raizlabs.android.dbflow.processor.definition.TableDefinition.<init>(TableDefinition.java:145)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at com.raizlabs.android.dbflow.processor.handler.TableHandler.onProcessElement(TableHandler.java:32)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at com.raizlabs.android.dbflow.processor.handler.BaseContainerHandler.handle(BaseContainerHandler.java:23)
16:52:52.721 [ERROR] [org.gradle.BuildExceptionReporter]    at com.raizlabs.android.dbflow.processor.model.ProcessorManager.handle(ProcessorManager.java:257)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.raizlabs.android.dbflow.processor.DBFlowProcessor.process(DBFlowProcessor.java:98)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    at com.sun.tools.javac.main.Main.compile(Main.java:523)
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter]    ... 76 more
16:52:52.722 [ERROR] [org.gradle.BuildExceptionReporter] 

我在我的项目中使用 ForeignKeys,但我不知道这是否是问题所在。我放了两张桌子,看看我做得好不好。

卡车实体

@ModelContainer
@Table(database = AppDatabase.class)
public class mTruck extends BaseModel {

    @PrimaryKey(autoincrement = true)
    long _id;

    @Column
    long id;

    @Column
    String license;

    @Column
    @ForeignKey(references = {@ForeignKeyReference(columnType = Long.class, columnName = "creationDate", foreignKeyColumnName = "_id")})
    mDate creationDate;

    @Column
    @ForeignKey(references = {@ForeignKeyReference(columnType = Long.class, columnName = "modificationDate", foreignKeyColumnName = "_id")})
    mDate modificationDate;

    @Column
    @ForeignKey(references = {@ForeignKeyReference(columnType = Long.class, columnName = "vModelo", foreignKeyColumnName = "_id")})
    mModel vModel;

日期实体

ModelContainer
@Table(database = AppDatabase.class)
public class mDate extends BaseModel {

    @PrimaryKey(autoincrement = true)
    long _id;

    @Column
    @ForeignKey(references = {@ForeignKeyReference(columnType = Long.class, columnName = "timezone", foreignKeyColumnName = "_id")})
    mTimezone timezone;

    @Column
    int offset;

    @Column
    long timestamp;

}

我不知道我做错了什么。你能帮我解决这个问题吗?

谢谢。

4

1 回答 1

3

我刚刚找到了解决方案。显然这是库的 master 分支的问题,它解决了在 Gradle 中更改编译分支的依赖关系:

dependencies {
    apt 'com.github.Raizlabs.DBFlow:dbflow-processor:3.0.0-beta1'
    compile "com.github.Raizlabs.DBFlow:dbflow-core:3.0.0-beta1"
    compile "com.github.Raizlabs.DBFlow:dbflow:3.0.0-beta1"
  }

dependencies {
    apt 'com.github.Raizlabs.DBFlow:dbflow-processor:develop-SNAPSHOT'
    compile "com.github.Raizlabs.DBFlow:dbflow-core:develop-SNAPSHOT"
    compile "com.github.Raizlabs.DBFlow:dbflow:develop-SNAPSHOT"
  }
于 2016-01-11T16:52:48.407 回答