Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

NullPointerException #378

Description

@Bersh

Hello! Today I've got it when compiling my project. Unfortunately I've no idea how to reproduce it.

StackTrace:
Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException
at com.googlecode.androidannotations.model.ModelExtractor.buildAnnotationTypes(ModelExtractor.java:68)
at com.googlecode.androidannotations.model.ModelExtractor.extract(ModelExtractor.java:51)
at com.googlecode.androidannotations.AndroidAnnotationProcessor.extractAnnotations(AndroidAnnotationProcessor.java:233)
at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:209)
at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:194)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.compiler.JavacRunner.main(JavacRunner.java:71)

Activity

  1. pyricau commented on Nov 5, 2012

    @pyricau
    Contributor

    Hello @Bersh ! Thank you for reporting this error.

    I checked ModelExtractor:

        private Set<DeclaredType> buildAnnotationTypes() {
            Set<DeclaredType> annotationTypesToCheck = new HashSet<DeclaredType>();
            for (Class<? extends Annotation> annotation : lookupAnnotations) {
                TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(annotation.getName());
                annotationTypesToCheck.add((DeclaredType) typeElement.asType());
            }
            return annotationTypesToCheck;
        }

    Here is appears that typeElement is null.

    This means that processingEnv.getElementUtils().getTypeElement(annotation.getName()) returns null. The javadoc of getTypeElement() states that it returns the named type element, or null if it cannot be found.

    From this we can deduce that at least one of the annotations could not be found in the classpath of the processor. lookupAnnotations is the list of annotations supported by AndroidAnnotations, so those should be in the annotation processor classpath.

    I see that you are using AndroidAnnotation 2.7. Are you using 2.7-SNAPSHOT, or the 2.7 stable release (released yesterday night) ?

    So my next question is : are you using Maven (and if yes, could you paste the dependencies configuration block for AndroidAnnotations), or the bundled zip ?

  2. Bersh commented on Nov 5, 2012

    @Bersh
    Author

    I'm using 2.7-SNAPSHOT. Sorry, it seems that it was just some broken version in my local maven repository. After removing androidannotations from repo and downloading it again everything is ok. Or maybe this bug may was alrady fixed

  3. pyricau commented on Nov 5, 2012

    @pyricau
    Contributor

    I think the problem may be that the androidannotations-api.jar wasn't updated at the same time the androidannotations.jar was. So the annotation processor expected some new annotations but couldn't find them on the classpath because androidannotations-api.jar didn't contain them.

    Thank you anyway !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions