I'm looking for a way to preview the rendering of an Anko view DSL in Android Studio. I've searched a lot and found only some deprecated or not working Android studio plugins. Is there a trick or something to make it works ?
The Anko Support plugins doesn't work...
I use Anko support plugins to preview DSL layouts all the time. There may be a few reasons why it may not work in your case:
Your layout should be defined in an external class that implements AnkoComponent interface.
Try rebuilding your project if the layout does not render properly. The preview works after the project is rebuilt.
Try refreshing the layout if that might solve your issue.
Make sure your Anko dependencies are latest and Android Studio 3+.
If you can share more info like the versions of your plugins and your code, maybe I can help pinpoint the exact issue.
Meanwhile here is an article that can surely help you out: https://blog.mindorks.com/how-to-preview-dsl-layouts-made-using-anko-layouts-f885c6bf67b3
Related
I have tried adding different implementations for constraintlayout
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
Cleaning the project, still right clicking on constraintLayout does not show "Convert to motionLayout". I need to manually add another xml file under the xml directory for the motion. Looked into other people's problems. Seems they had the dependency issue. Any helps will be appreciated.
The MotionLayout editor is available in Android Studio starting from version 4.0.0. Make sure that you have updated your IDE.
use
"implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
Make sure your project compiles at that point.
Then convert.
This small (< 2min) video shows the conversion:
https://twitter.com/i/status/1187075643118239744
Android Studio cannot find MotionLayout in xml. I use the androidx.constraintlayout.motion.widget.MotionLayout tag and get a gray screen. I’m also implementing 'com.android.support.constraint:constraint-layout:2.0.0-alpha4' and changing to alpha02 changes nothing. I already found a question with the same problem, but it also had no solution.
I used the wrong implentation in gradle. Correct is implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
after i updated everything is needed ,my problem resolved with clean project in build!
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.
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.
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.