agrosner / DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
MIT License
4.88k stars 599 forks source link

Build failed when creating a table #1104

Closed r0b0t3d closed 7 years ago

r0b0t3d commented 7 years ago

DBFlow Version: 4.0.0-beta3 and develop-SNAPSHOT Issue Kind (Bug, Question, Feature):

Please note if you are using Instant Run, there may be bugs where generated classes are not created. Ensure you are using the apt or kapt plugins and that incremental compilation is off.

Description: Whenever I define a table

@Table(database = AppDatabase.class)
public class Report extends BaseModel {
    @Column
    @PrimaryKey(autoincrement = true)
    public int _id;
}

this build error happened

Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: com.squareup.javapoet.CodeBlock.of(Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/javapoet/CodeBlock;
    at com.sun.tools.javac.main.Main.compile(Main.java:553)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:46)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
    at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:163)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:145)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93)
    at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
    at 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)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 70 more
Caused by: java.lang.NoSuchMethodError: com.squareup.javapoet.CodeBlock.of(Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/javapoet/CodeBlock;
    at com.raizlabs.android.dbflow.processor.definition.column.ColumnAccessorKt.<clinit>(ColumnAccessor.kt:13)
    at com.raizlabs.android.dbflow.processor.definition.column.ColumnDefinition.addPropertyDefinition(ColumnDefinition.kt:253)
    at com.raizlabs.android.dbflow.processor.definition.TableDefinition.onWriteDefinition(TableDefinition.kt:364)
    at com.raizlabs.android.dbflow.processor.definition.BaseDefinition.getTypeSpec(BaseDefinition.kt:135)
    at com.raizlabs.android.dbflow.processor.utils.WriterUtils.writeBaseDefinition(WriterUtils.kt:16)
    at com.raizlabs.android.dbflow.processor.ProcessorManager.handle(ProcessorManager.kt:292)
    at com.raizlabs.android.dbflow.processor.DBFlowProcessor.process(DBFlowProcessor.java:95)

Note: I also use Otto bus in my project

agrosner commented 7 years ago

its quite plausible that you have a dependency on Java poet in another annotation processor, which is a different version. What other annotation processors do you have?

r0b0t3d commented 7 years ago

I don't know @agrosner , Could you please guide me how to know that? I'm using android studio with gradle version 2.2.3 This is my build.gradle file

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

repositories {
    maven { url "https://jitpack.io" }
    // EasyPreferences
    maven { url "http://dl.bintray.com/pixplicity/maven" }
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.1'
    defaultConfig {
        applicationId "com.okee.drive"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        dataBinding {
            enabled = true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

def dbflow_version = "4.0.0-beta3"
//def dbflow_version = "develop-SNAPSHOT"

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:support-v4:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    // Calligraphy
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    // Glide
    compile 'com.github.bumptech.glide:glide:3.7.0'
    // Socket io
    compile 'io.socket:socket.io-client:0.7.0'
    // Dagger
    apt 'com.google.dagger:dagger-compiler:2.2'
    compile 'com.google.dagger:dagger:2.2'
    // PhotoView
    compile 'com.github.chrisbanes:PhotoView:1.3.0'
    // JieCaoVideoPlayer
    compile 'fm.jiecao:jiecaovideoplayer:4.8.3'
    // EasyPreferences
    compile 'com.pixplicity.easyprefs:library:1.8.1@aar'
    // DBFlow
    apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
    // use kapt for kotlin apt
    compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"

    // Otto
    compile 'com.squareup:otto:1.3.8'
}
agrosner commented 7 years ago

please run a ./gradlew :app:dependencies and print it here. Its proably b/c Dagger2 also depends on JavaPoet, but might be choosing an older version of lib.

r0b0t3d commented 7 years ago

I did update dagger 2 to latest version and it solved the problem. Thanks!

agrosner commented 7 years ago

np!