Menu
  • HOME
  • TAGS

Android annotations and flavors in Android Studio 1.0.1

android,android-studio,android-annotations,android-productflavors

I'm myself using AndroidAnnotations for a while now and I have a few projects that require product flavors as well. So far I managed to make it work. My guess would be that you misconfigured your resourcePackageName in your apt. Here is what I do in my (truncated) build.gradle file:...

Dagger and AndroidAnnotations - how to inject @Pref, @Bean, etc?

android,android-annotations,dagger

Your @Provide methods should call the getInstance_ method of generated bean classes. This methods creates a new instance and injects the necessary objects. For the generated preference, you should call the constructor new Prefs_(context). However, this is not a too clean way since these generated methods are supposed to called...

Missing generated folders in Android Studio

android-studio,android-annotations

The author of android-apt has already updated his plugin to support Gradle's new version, just change this line in your build.gradle classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+' To classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3' ...

Sending images with AndroidAnnotations RestService

android,spring,android-annotations

You should use a multipart POST request: Client: @Rest(rootUrl = "your_url", converters = FormHttpMessageConverter.class) public interface UploadClient extends RestClientHeaders { @Post("/Image/{id}") @RequiresHeader(HttpHeaders.CONTENT_TYPE) String uploadImage(int id, MultiValueMap<String, Object> data); } Usage: MultiValueMap<String, Object> data = new LinkedMultiValueMap<>(); FileSystemResource image = new FileSystemResource("path_to_image"); String description = "description"; String title = "title"; data.put("image",...

Android Annotation Error with Android Studio Update 1.0

android,android-studio,build.gradle,android-annotations

There are some changes to apply with the new version of Android Studio. See this wiki page to get an example of the build.gradle. Pay attention to this line : androidManifestFile variant.outputs[0].processResources.manifestFile ...

Android annotations access singleton class object into other class static method

android,android-annotations

I am afraid you are using AA @EBean incorrectly. Did you read the documentation? You do not have to write a getInstance() method yourself, AA will generate the appropriate method, do the injections in it, and automatically call it when injecting the bean into other components. You got a NullPointerException...

AndroidAnnotations using REST with BaseAdapter throw 'Can't create handler inside thread that has not called Looper.prepare()'

android,rest,android-studio,android-annotations

The culprit is here: searchProducts(); adapter = new ProductListAdapter(products); searchProducts() is a @Background annotated method, which means it will do its work on a background thread. While bindAdapter() will continue execution on the main thread. It means products is still null when you call the constructor, so it will pass...

What its the first, the annotated class (egg) or used class (chicken)?

android-annotations,annotation-processing

But suppose someone now download the project, how can the use? Because the class where used SharedPreferencesInterface_ not compile because the class does not exist, and the class does not exist because compilation errors ... This is the same situation when you compile a project in a full build...

How to do a progress bar to show progress download of a big file with AndroidAnnotations?

android,download,progress,android-annotations

With AndroidAnnotations, you can use background threads and publishing progress easily: @EActivity public class MyActivity extends Activity { public void onCreate(Bundle icicle) { super.onCreate(icicle) doSomeStuffInBackground(); } @Background void doSomeStuffInBackground() { // will run on a background thread publishProgress(0); // Do some stuff publishProgress(10); // Do some stuff publishProgress(100); } @UiThread...

Building app with library module cannot find AndroidManifest.xml

android,gradle,android-gradle,android-annotations

Since android gradle plugin 14.4, the following line does not work anymore: variant.outputs.processResources.manifestFile orvariant.processResources.manifestFile You have to use this one instead: variant.outputs[0].processResources.manifestFile Please note if you have multiple outputs (when using splits), you may want to use another output (other index than zero)....

Android Studio with AndroidAnnotations NoClassDefFoundError

java,android,android-studio,android-gradle,android-annotations

The problem is with multiDexEnabled true It is only supported on Android 5 natively. So I need a library for this to run in older versions. I found the fix....

Android annotations not injecting RestService

android,android-annotations

Ok so here is the answer to my question. I hope it can be of use to other people who ask themselves the same as I did. Thanks to WonderCsabo for pointing me in the right direction. Android Annotations generates the annotated classes at compile time. So Player becomes Player_....

AndroidAnnotations bean initialize when OnActivityResult called

java,android,onactivityresult,android-annotations

Sorry @WonderCsabo My problem is related to TabInfo+ViewPager UI structure and its children fragments. below code is darn dirty but works. In adapter, private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); public void addTab(ImageButton btn, Class<?> clss, Bundle args) { TabInfo info = null; if (mContext.getSupportFragmentManager().getFragments() != null && mContext.getSupportFragmentManager().getFragments().size() >...

android annotations @background NetworkOnMainThreadException

java,android,android-annotations,networkonmainthread

You probably use wrong Activity in your Manifest - You should use MainActivity_ instead of MainActivity

How to use the RestErrorHandler with AndroidAnnotations?

android,error-handling,resttemplate,android-annotations

May not be the most elegant solution, please weigh in if anyone has a better approach. Of course an Unchecked Exception can be thrown from the customerrorhandler and pass the parameters within the exception but I still have no idea how to access the headerfields of a response. RestTemplate throws...

Multiple dex files define Lorg/springframework/http/ContentCodingType$1

rest,android-annotations,spring-android

Two things: First, the declared dependencies: //compile 'org.springframework.android:spring-android-rest-template:2.0.0.BUILD-SNAPSHOT' compile 'org.springframework.android:spring-android-rest- template:1.0.1.RELEASE I know you commented out the first dependency, but make sure you do not have two at the some time. This will cause duplicate classes in your classpath and dex fails. Secondly, you have the spring android rest template...

Do Dagger 2 and Android Annotations work together?

android,android-annotations,dagger-2

I'm using dagger2, AndroidAnnotations and ButterKnife(for adapters) all together and they work fine. One difference to note from dagger1 is that you have to inject every specific class(not just the parent activity) that declares @Inject fields though. But you don't have to inject classes generated by AndroidAnnotations, since the injected...

AndroidAnnotations and EventBus

android,android-annotations,greenrobot-eventbus

You have three options: Use Otto. It also has the same problem what you faced with EventBus, however AndroidAnnotations has specific Otto integration which solves that problem. If you want to stick with EventBus, you can try out the experimental version, which does not has the issue as 2.4.0. It...

AndroidAnnotation REST handling calbacks

java,android,rest,android-annotations

I'm sorry, this may not be the answer you are looking for, but I would recommend using Retrofit to handle the REST calls....

How do I get the headers from a HttpResponse with Spring resttemplate and androidannotations in case of an Error?

android,spring,rest,error-handling,android-annotations

Basically I found a solution. The RestClient @Rest(rootUrl = "https://proji.at/japi/v1", converters = { MappingJackson2HttpMessageConverter.class }, interceptors = { HttpBasicAuthenticatorInterceptor.class }) public interface ProjiRestClient extends RestClientErrorHandling { RestTemplate getRestTemplate(); } The ErrorHandler: @EBean public class ProjiResponseErrorHandler implements ResponseErrorHandler { private static final String TAG = "ProjiResponseErrorHandler"; @Override public void handleError(ClientHttpResponse response)...

Android annotations and applicationIdSuffix

android,gradle,android-annotations

Remove this line from your build.gradle file: resourcePackageName android.variant.applicationId Edit: try to add this line to your apt block: resourcePackageName "org.me.myapp" ...

AndroidAnnotations: how to access View on @ItemClick

android,android-annotations

Unfortunately you cannot add a View parameter, but you can use the position parameter. The problem with that there is no method to return the clicked View, so you have to use some logic to get the View from all the children. @ViewById(R.id.gridViewId) GridView gridView; @ItemClick(R.id.gridViewId) void itemClicked(int position) {...

@ViewById inside @EBean using android annotations

android,android-annotations

@EBean annotated classes aren't supposed to do any view-related work as they can be injected in every enhanced classes (ie annotated with @EService, @EBean, @EActivity, ...). If you're able to do a findViewById in the context retrieved via @RootContext, it's only because – in this case – the context given...

AndroidAnnotations. button click inside actionLayout of menuItem

android,appcompat,android-menu,android-annotations

I am afraid you cannot bind a listener with @Click to a menu action view, since Activity.findViewById cannot find that view inside the menu items. What you can do is injecting the menuitem, then, manually bind your listener as you already did. @EActivity(R.layout.activity_question_post) @OptionsMenu(R.menu.menu_done) public class QuestionPostActivity extends FragmentActivity {...

Migrating android application project using AndroidAnnotations from Android Studio 0.8 to 1.0 version

android,android-studio,migration,android-annotations

Editing Gradle file as follow should solve the problem: apt { arguments { androidManifestFile variant.outputs[0].processResources.manifestFile resourcePackageName "your.package.name" } } ...

Generate bitmap from view

android,bitmap,android-annotations

Found a method somewhere that did the trick: public static Bitmap getScreenViewBitmap(View v) { v.setDrawingCacheEnabled(true); // this is the important code :) // Without it the view will have a dimension of 0,0 and the bitmap will be null v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); v.buildDrawingCache(true); Bitmap b...

Otto. Avoid @Produce validation warnimg message

android,android-annotations,otto

As @WonderCsabo mentioned, it works great in current release of AndroidAnnotations(v3.2) and otto(v1.3.6). Do not have to use otto-2.0.0-SNAPSHOT version.

AndroidAnnotations Rest view response data

android,spring,android-annotations

Create this interceptor: public class LoggingInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { ClientHttpResponse response = execution.execute(request, body); String responseString = stringOf(response.getBody()); Log.d("RESPONSE", responseString); return response; } public static String stringOf(InputStream inputStream) { inputStream.mark(Integer.MAX_VALUE); BufferedReader r = new BufferedReader(new...

Migrating from android-annotation 2.7.1 to 3.3.1 break app

android-annotations

As wondercsabo said, the original code wasn't copy correctly and there is no problem with version upgrade. Thanks again wondercsabo...