Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SOLVED] Execution failed for task ':app:compileDebugJavaWithJavac' java.lang.IllegalArgumentException: expected type but was null [UpperCamelCase not documented]] #972

Closed
andrewpros opened this issue Sep 4, 2016 · 14 comments
Assignees
Labels
Milestone

Comments

@andrewpros
Copy link

andrewpros commented Sep 4, 2016

DBFlow Version: 3.1.1 or develop snapshot

Bug

Description:

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

    java.lang.IllegalArgumentException: expected type but was null

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at 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)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: expected type but was null
    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)
    ... 14 more
Caused by: java.lang.IllegalArgumentException: expected type but was null
    at com.squareup.javapoet.CodeBlock$Builder.argToType(CodeBlock.java:225)
    at com.squareup.javapoet.CodeBlock$Builder.add(CodeBlock.java:176)
    at com.squareup.javapoet.CodeBlock.of(CodeBlock.java:94)
    at com.squareup.javapoet.FieldSpec$Builder.initializer(FieldSpec.java:157)
    at com.raizlabs.android.dbflow.processor.definition.column.ColumnDefinition.addPropertyDefinition(ColumnDefinition.java:256)
    at com.raizlabs.android.dbflow.processor.definition.TableDefinition.onWriteDefinition(TableDefinition.java:487)
    at com.raizlabs.android.dbflow.processor.definition.BaseDefinition.getTypeSpec(BaseDefinition.java:131)
    at com.raizlabs.android.dbflow.processor.utils.WriterUtils.writeBaseDefinition(WriterUtils.java:17)
    at com.raizlabs.android.dbflow.processor.model.ProcessorManager.handle(ProcessorManager.java:338)
    at com.raizlabs.android.dbflow.processor.DBFlowProcessor.process(DBFlowProcessor.java:98)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    ... 34 more


BUILD FAILED

I have tried EVERYTHING, nothing fixes it, my main app won't compile, made new test app with bare minimum, the same error, newest stable android studio

my gradle

apply plugin: 'com.android.application'

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

def dbflow_version = "develop-SNAPSHOT"; //"3.1.1"

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"


        defaultConfig {
        applicationId "app.sample.dbflowtest"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        incremental = false
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:24.2.0'

    apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
    compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"
}

It works with only database configured, but as soon as i add any model configuration with annotations it won't compile with that error, even a bare simple one:


import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;

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

    @PrimaryKey
    public int id;
}

Anyone have an idea, i need this working asap?

@trevjonez
Copy link
Contributor

It looks like it is failing to generate code related to a table field.
Maybe a type that needs a custom converter? what was the last thing you
changed when it broke?

On Sun, Sep 4, 2016 at 2:57 PM, andrewpros [email protected] wrote:

DBFlow Version: 3.1.1 or develop snapshot

Bug

Description:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    java.lang.IllegalArgumentException: expected type but was null

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at 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)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: expected type but was null
    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)
    ... 14 more
    Caused by: java.lang.IllegalArgumentException: expected type but was null
    at com.squareup.javapoet.CodeBlock$Builder.argToType(CodeBlock.java:225)
    at com.squareup.javapoet.CodeBlock$Builder.add(CodeBlock.java:176)
    at com.squareup.javapoet.CodeBlock.of(CodeBlock.java:94)
    at com.squareup.javapoet.FieldSpec$Builder.initializer(FieldSpec.java:157)
    at com.raizlabs.android.dbflow.processor.definition.column.ColumnDefinition.addPropertyDefinition(ColumnDefinition.java:256)
    at com.raizlabs.android.dbflow.processor.definition.TableDefinition.onWriteDefinition(TableDefinition.java:487)
    at com.raizlabs.android.dbflow.processor.definition.BaseDefinition.getTypeSpec(BaseDefinition.java:131)
    at com.raizlabs.android.dbflow.processor.utils.WriterUtils.writeBaseDefinition(WriterUtils.java:17)
    at com.raizlabs.android.dbflow.processor.model.ProcessorManager.handle(ProcessorManager.java:338)
    at com.raizlabs.android.dbflow.processor.DBFlowProcessor.process(DBFlowProcessor.java:98)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    ... 34 more

BUILD FAILED

I have tried EVERYTHING, nothing fixes it, my main app won't compile, made
new test app with bare minimum, the same error, newest stable android studio

my gradle

apply plugin: 'com.android.application'

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

def dbflow_version = "develop-SNAPSHOT"; //"3.1.1"

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"

    defaultConfig {
    applicationId "app.sample.dbflowtest"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    incremental = false
}

}

dependencies {
compile 'com.android.support:appcompat-v7:24.2.0'

apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"

}

Anyone have an idea?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#972, or mute the thread
https://github.com/notifications/unsubscribe-auth/AFIxBz-c8fkZYAhkk1yRDAu-3p6LvvgYks5qmzDRgaJpZM4J0oGT
.

@andrewpros
Copy link
Author

andrewpros commented Sep 4, 2016

I hadn't changed anything, it is my first time using dbflow in project, so i never had it working, started about 3 hours ago, that is the time i tried fighting with it, but no luck.

I had setup the simplest test app possible and still, won't work.

Just as in updated issue above, as soon as i add any model configuration with annotations it won't compile.

@trevjonez
Copy link
Contributor

Is it a public project? Will be easier if we can see the full consumption

On Sep 4, 2016 3:05 PM, "andrewpros" [email protected] wrote:

I hadn't changed everything, it is my first time using dbflow in project,
so i never had it working, started about 3 hours ago, that is the time i
tried fighting with it, but no luck.

I had setup the simplest test app possible and still, won't work.

Just as in my first updated comment, as soon as i add any model
configuration with annotations it won't compile.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#972 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFIxB9mceg2nNgc8gOZcCxZ130ruvXNYks5qmzKPgaJpZM4J0oGT
.

@andrewpros
Copy link
Author

Well no, but i can provide the bare minimum sample project here http://www39.zippyshare.com/v/iMpVdXEG/file.html

But it is nothing fancy, so i don't see where i would make a mistake, other libs just works plug and play, so i think it is in the library itself or some software incompatibility?

Is there a way i can setup it to debug the the dbflow processor where the issue pops out?

@andrewpros
Copy link
Author

andrewpros commented Sep 5, 2016

@trevjonez Ok i have found something, managed to debug the annotation processor, seems like i know why it fails with IllegalArgumentException expected type but was null, but don't know the source of this yet.

The first screen, tableClass is null, this is important.

Then it goes here, due to tableClasss being null the args don't have a parameter at index 1, only 0 or 2, this code goes from index 0 to max, and don't check if there are some holes

And this goes to argToType that throws the error, cuz index 1 is null

So i don't know if there is a problem that tableClass is null but it never can be, so need to look why it is null or if the code in CodeBlock add function (screen two) should not iterate from 0 to max args, but check and omit the gaps.

Any advice?

@andrewpros
Copy link
Author

andrewpros commented Sep 5, 2016

Found the problem. @agrosner

It is in getElementClassName that uses JavaPoet ClassName bestGuess method

According to bestGuess method documentation

This method assumes that the input is ASCII and follows typical Java style (lowercase package names, UpperCamelCase class names) and may produce incorrect results or throw IllegalArgumentException otherwise

So my table class was not UpperCamelCase compliant BUT DBFlow docs doesn't state that it is necessary and haven't seen any tutorial that states this, so maybe it would be good to update the docs.

Well as soon as i make it UpperCamelCase it works, not sure what if i have lower case table name in db, hope table name attribute is sufficient.

@trevjonez
Copy link
Contributor

It may be nice to have a sort of FAQ but there may be a better way to handle getting a class name from an element than using toString and bestGuess. The wide use of code block in the processor code gives me the feeling that a good deal of the APT code could be refactored to use the control flow / statement api's of javapoet to be made more safe, and to just let things like that best guess throw with a meaningful error.

the advantage of using begin and end control flow is that javapoet can throw an exception if you start an if block and never close it rather than waiting for the output and trying to figure out where the syntax problem is coming from.

@agrosner agrosner added the bug label Oct 2, 2016
@agrosner agrosner added this to the 4.0.0-beta1 milestone Oct 2, 2016
@agrosner agrosner self-assigned this Oct 2, 2016
agrosner pushed a commit that referenced this issue Oct 2, 2016
…mediately resolved by classname.get(typeelement). #972
@agrosner
Copy link
Owner

agrosner commented Oct 2, 2016

in develop, slated for 4.0.0-beta1. You might be able to upgrade to develop version but dependiing on implementation might have breaking changes.

@agrosner agrosner closed this as completed Oct 2, 2016
@andrewpros andrewpros changed the title Execution failed for task ':app:compileDebugJavaWithJavac' java.lang.IllegalArgumentException: expected type but was null [SOLVED] Execution failed for task ':app:compileDebugJavaWithJavac' java.lang.IllegalArgumentException: expected type but was null [UpperCamelCase not documented]] Oct 10, 2016
@rogerhu
Copy link

rogerhu commented Oct 30, 2016

This problem also happens if you have package names that are not all lowercase as well, not just tables that are not upper camel case.

The 4.0.0-beta1 fixes this issue regardless.

@SheharyarEjaz
Copy link

Its smart answer is that there is some syntax error in your Code may be in Java file or xml. FIx them error will gone. work 100 percent for me every time

@wilson1234567891962
Copy link

wilson1234567891962 commented Jul 19, 2019

you need to disabled the next option

Instant run app

it was functioned to me

@SheharyarEjaz
Copy link

Desabilitar el instant run del android esto me funciono

Translate in English Plz

@wilson1234567891962
Copy link

ready

@anneonyejemuo
Copy link

you need to run androidstuio as an administrator- worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants