MonkeyTalk and Butterknife ViewInjector Generation - (Android + Annotations + AspectJ + Eclipse) - android

I have been using ButterKnife successfully to inject views in my application like so:
#InjectView(android.R.id.text1)
TextView mMessageText;
#InjectView(android.R.id.button1)
ImageView mButton;
... then later...
View.inflate(ctx, R.layout.layout_message_with_button, this);
ButterKnife.inject(this);
mMessageText.setText("Some Text");
This morning I integrated MonkeyTalk for some testing, and my injections now seem to be busted. I've removed/readded annotation processing for ButterKnife, but that didn't seem to fix the problem. Using findViewById fixed the issue (the views were found), but changing the project to use findViewById directly isn't really an option at this point.
I wasn't able to find any information about conflicts between the libraries (or using AspectJ with ButterKnife in general), so hopefully someone here can help provide some insight into what I might be doing wrong (or if they are just in general incompatible).
I am using ButterKnife 4.0.1 and MonkeyTalk Agent 2.0.9
UPDATE:
I have also tried changing the build order of the libraries in the Eclipse project properties, but this also doesn't seem to help.
UPDATE:
I narrowed it down to the generated files not being created in ButterKnife. It appears to be related to Annotation processing not happening in the org.eclipse.ajdt.core.ajbuilder. When I add org.eclipse.jdt.core.javabuilder to the .project as suggested here : https://bugs.eclipse.org/bugs/show_bug.cgi?id=169857, the classes are generated, but I'm getting NoClassDefFoundError at run time on .ajc files. Any idea how to get the annotation processor to run in the ajbuilder? That seems to be the correct solution for my problem.
UPDATE:
From this post (http://andrewclement.blogspot.ca/2014/08/annotation-processing-in-ajdt.html), it appears that Aspects and Annotations can be processed in the same project using Eclipse 4.4. It seems, however, that the combination of ADT 23 + Eclipse 4.4 + AspectJ is pretty unstable (and doesn't appear to generate the code from ButterKnife's Annotations anyway). Anyone know if Android Studio would be any help here?
UPDATE:
I converted my project to Android Studio and it looks like both the Aspects and the Annotations are working. I know I'm still not doing something right with the Aspects, since they weren't processing until I added Jake Wharton's Hugo library to the Android project.

Related

Type mismatch when creating a new ViewModel for Room implementation - kotlinx.coroutines obsolete since 1.3

I am building an app that will rely heavily on user data and plan on using Room to help manage and store their information. However, while following a tutorial I ran into a few versioning issues that I was having troubles resolving on my own.
Since I am fairly new to both Android development as well as using Room, I have been following this tutorial: Android Room with a View - Kotlin
I first noticed there might be some issues in step 3 when I updated my Gradle files. I was met by the following error on the last two lines of the dependencies block:
Library should be updated to be compatible with Kotlin 1.3
I was confused by this since the tutorial uses a variable of some kind to determine the library versions. I ran the app at this point and it seemed to work fine so I continued.
When I got to step 9, I also ran into additional errors which now prevent builds from completing:
Type mismatch: inferred type is kotlin.coroutines.experimental.CoroutineContext but kotlin.coroutines.CoroutineContext was expected
Type mismatch: inferred type is kotlin.coroutines.CoroutineContext but kotlin.coroutines.experimental.CoroutineContext was expected
This is on top of errors that implementations of kotlinx.coroutines.experimental are obsolete, however, I couldn't find references to libraries without experimental using Android Studio's intellisense.
What do I need to do in order to resolve these library issues and allow me to continue the tutorial?
To the best of my knowledge, here is the recommended way to resolve these issues.
To try and solve these issues, I started with the errors in my Gradle scripts to see if that would maybe resolve dependencies in the code. I did find this post, which I'm still not completely convinced is the best solution, but just following the first couple of suggestions in the top answer did clear most of my issues.
To be clear, I changed the following:
Changed the variable in the last line of the dependencies Gradle block to have a hard-coded version number (I did the latest as found in the kotlinx.coroutines repo). If possible, I would like this to be auto-generated again as the tutorial implies
Removed the kotlin block from the bottom of that same Gradle file
Synced my Gradle project
Update Kotlin and Gradle (I was asked by Android Studio, you might not be depending on your versions)
Manually removed problem libraries from code, and Alt+Enter'ed any missing libraries back into existence
If you update Gradle, you may also find it necessary to include the following in your Module: app Gradle file inside the android block:
packagingOptions {
exclude 'META-INF/*'
}
(* might be overkill for some, but the suggestion from this post didn't completely eliminate all of my errors.)
After all that, I was then able to rebuild the SDK which loaded to my phone with zero errors.

Android: Using several version of the same library for different flavors

I'm needing help again with my strange projects ;)
So I'm still building a library, and I need to use libA-1.01.jar and libA-2.1.jar
Of course I don't want them in the same flavor, so I used in my gradle file:
flavorACompile files('libs/libA-1.01.jar')
flavorBCompile files('libs/libA-2.1.jar')
This works fine when compiling with gradlew in command line. But the issue is that my classes don't see both libraries. So when I'm coding I can only import the first one (1.01). So I can't use my IDE to code properly I have to guess emacs style if everything is ok and compile to see...
How can I tell Android Studio that the 2 libraries are present? I tried added them both to compile without flavor (just to force android studio to use them) but it didn't work.
I'm sure there is a simple way to do this, but I can't seem to find it :(

Android Studio (0.8.1) cant use go to declaration/implementation

I cant seem to use go to declaration or implementation for any classes and methods that are outside of either the current class/file. It will work for classes that are from the android library but nothing that I created or that I import from another library. This is taking a huge toll on productivity... Anyone run into this? Have a solution? Ideas for a fix?
Also highlighting seems to be an issue as well, this might be related. It seems lighter then it used to be, like Annotations are not being highlighted. Maybe its a parser issue?
If you are using gradle to build your application, then make sure gradle project sync is not failing. If gradle project sync fails, then basic IDE functionality may not work properly e.g. goto type declaration (ctrl+shift+b) and implementation (ctrl+alt+b or ctrl+click). Android studio also does a wonderful job of notifying you when something fails.

Android Annotations and MonkeyTalk?

I just tried to update my project which uses Android Annotations to include the MonkeyTalk agent. However, as soon as I switch the project to an AspectJ project, all my Android Annotations references are not recognized.
Has anybody successfully used MonkeyTalk in an Android Annotations project?
I'm using Eclipse 4.2 SR2.
It looks like this issue has been raised on the Android Annotations FAQ:
https://github.com/excilys/androidannotations/wiki/FAQ#wiki-aspectj
In order to "fix" it, you have to remove / replace some project properties. I'm worried doing this will cause MonkeyTalk to not work, but I haven't tried it yet.
Any insight appreciated!
I was facing to this problem before. I added a solution in the FAQ page of AA. Could you test that and keep me updated ?
I had implemented the solution but still my android annotations references are not recognized,please let me know if there is any other way to tackle the same.

Having two or more Library Projects and the Main Project in Android Development

I added johannilsson-android-actionbar as a library to my project. It worked well, and everything was good for me. But recently, I have added the uitableView as a library and got this error:
/--mypath--/actionbar/res/values/attrs.xml:19: error: Attribute "tittle" has already been defined
And the R is not Known, so I cannot reference my XML. I have ADT 17 and Eclipse 3.7. I tried to remove the uitableview, and the project works fine, no Errors, and R is OK.
The authors of libraries need to take steps to avoid collisions on resource IDs. The authors of your libraries have not, apparently.
One possibility is to switch from johannilsson-android-actionbar to ActionBarSherlock and see if you have better luck.

Categories

Resources