This repository was archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
static inner class error and NullPointerException #1177
Copy link
Copy link
Closed
Labels
Description
Hi there,
I made a similar class than this test class and when I build it I get more errors.
First I get "EBean cannot be used on a non static inner element" and then one NullPointerException.
If you comment the @AfterInject annotation you get only the first error (no NullPointerException).
package hu.simpe.androidannotationstest;
import android.app.ListFragment;
import android.content.Context;
import android.widget.ArrayAdapter;
import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.EFragment;
/**
* Created by Péter Simon on 2014.10.04.
*/
@EFragment(R.layout.fragment_test)
public class TestFragment extends ListFragment {
@Bean
protected TestAdapter mAdapter;
public TestFragment() {
// Required empty public constructor
}
@EBean
protected static class TestAdapter extends ArrayAdapter<String> {
private static String[] testElements = new String[]{"test1", "test2"};
public TestAdapter(Context context) {
super(context, android.R.layout.simple_list_item_1);
}
@AfterInject
protected void afterInject() {
for (String testElement : testElements) {
add(testElement);
}
}
}
}Note: Validating elements
Note: Validating with EFragmentHandler: [hu.simpe.androidannotationstest.TestFragment]
Note: Validating with EBeanHandler: [hu.simpe.androidannotationstest.TestFragment.TestAdapter]
Note: Validating with BeanHandler: [mAdapter]
Note: Validating with AfterInjectHandler: [afterInject()]
Note: Processing root elements
Note: Processing root elements EFragmentHandler: [hu.simpe.androidannotationstest.TestFragment]
Note: Processing enclosed elements
D:\Users\simpe\AndroidAnnotationTest\app\src\main\java\hu\simpe\androidannotationstest\TestFragment.java
Error:(25, 5) error: @org.androidannotations.annotations.EBean cannot be used on a non static inner element
Warning:(26, 22) Element EBeanHandler unvalidated by
Error:(16, 8) error: Something went wrong: Unexpected error in AndroidAnnotations 3.1!
You should check if there is already an issue about it on https://github.com/excilys/androidannotations/search?q=java.lang.NullPointerException&type=Issues
If none exists, please open a new one with the following content and tell us if you can reproduce it or not. Don't forget to give us as much information as you can (like parts of your code in failure).
Java version: javac 1.8.0_20
Javac processors options: androidManifestFile=D:\Users\simpe\AndroidAnnotationTest\app\build\intermediates\manifests\debug\AndroidManifest.xml, resourcePackageName=hu.simpe.androidannotationstest
Stacktrace: java.lang.NullPointerException
at org.androidannotations.handler.AfterInjectHandler.process(AfterInjectHandler.java:51)
at org.androidannotations.handler.AfterInjectHandler.process(AfterInjectHandler.java:27)
at org.androidannotations.process.ModelProcessor.processThrowing(ModelProcessor.java:136)
at org.androidannotations.process.ModelProcessor.process(ModelProcessor.java:120)
at org.androidannotations.AndroidAnnotationProcessor.processAnnotations(AndroidAnnotationProcessor.java:243)
at org.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:185)
at org.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:113)
at
Thrown from: hu.simpe.androidannotationstest.TestFragment.TestAdapter
Element (MethodSymbol):
@org.androidannotations.annotations.AfterInject
protected void afterInject();