Long story short, Android Studio's new Refactor feature to Migrate to Android X is buggy. In the end, I ended up with dozens of invalid, incomplete, non-existent component classes in my XML files and the compiler didn't complain. Only when testing at runtime did I realize what it's done.
Is there a lint option to find invalid class names / component types so that it flags something like this (which does not exist):
<androidx.widget.AppCompatSeekBar>....</androidx.widget.AppCompatSeekBar>
The actual class name is androidx.appcompat.widget.AppCompatSeekBar. I've had to do a lot of manual find and replace, but I feel reluctant posting this as an update and break an app that was working perfectly before.
Related
First of all, I Google it, and find no answer to this. Also, I've found some questions here, but they dated 2016 and 2017. Now we have 2019.
I'm used to Java in Android Studio. When I override methods, IDE puts them in order - how they placed in parent class or implemented interface.
Also when I'm developing, for example, Repository pattern:
I create an interface.
Create classes which implements this interface
When I am adding functions in interface and then I override (ctrl+o, or alt+Enter on class name) them in my classes: In Java they placed at the same position as they defined in my interface, In Kotlin - the placed in top of the class (this is really bad!)
Also, code does not get reformatted automatically, for example: global vars placed on top, then goes constructors, etc.
So I'm asking.
It's just me? I've tried deleting all Android Studio settings, reinstalling, etc. It did nothing. Also, Googling did not take any results.
Is there any solution to all of this? Because I really liked kotlin, but this inconvenience is just very annoying.
Maybe this plugin Kotlin Code Sorter can fulfill your request. But this plugin only distinguishes the property, class, constructor or function. That the differences are inside some topics likes private, lateinit, val or var can not be order.
Android Studio/IntelliJ official doesn’t have support for the Kotlin code rearrangement.
First select that code which you want to rearrange or reformatted.
Than Just press ctrl+alt+L for rearrange or reformatted code.
I'm developing an DSL with jetbrains MPS. It's not obvious to use, but I succeeded so far with the design-part.
It's possible to right-click on a solutions node and "run" it, assuming the language is executable (extends executing.util). Plus I use a seperately developed jar as a library (used by the generator).
I build a new project to test, as simple as possible, added some extra nodes and loops in the generator, the error occures and it can't be undone.
As far as I can see, there are several possible sources of errors.
dependencies (they are tricky in MPS)
my jar
wrong cached files or so
Executing "run" causes the following error:
error: could not find or load main class MySolution.package.map_concept
Has some of you out there experience with this?
Tell me, if there are some extra information that would help.
It seems that you have added the jar file as a model to the language, which makes it invisible for the solution. Following the instructions at https://confluence.jetbrains.com/display/MPSD32/Getting+the+dependencies+right#Gettingthedependenciesright-AddingexternalJavaclassesandjarstoaprojectruntimesolutions and creating a separate library solution worked for me.
To me this looks like a problem of the generator. Have you fully rebuilt the project - right-click on the "project" node in the structure tree?
Is the root mapping template correct? If you can share your project, I can have a look.
A small tip that could have saved me some time and might also solve this problem for someone else, even if you followed the instructions in other answers.
When prompted to add your libraries to modules after including the libraries on Java tab, dismiss the window if you already included them in the first place on the Common tab. Otherwise they are listed once despite having been added twice, leading to a compilation failure.
I have two c# projects within a solution.
The first project is a winforms project with several classes and is called QuantumGUI. The second project is a class library project with several classes and is called QuantumDAL.
My objective is from a class in QuantumDAL to access and set variables in a QuantumGUI class or and in Form.cs.
I have tried adding a reference to QuantumGUI in my QuantumDAL project but received the following error: “A Reference to ‘QuantumGUI’ could not be added. Adding the project as a reference would cause a circular dependency”.
I received a similar error message trying to add Project Dependencies. When you think about it, the error message makes sense.
I’ve tried other, what I consider possible ways of doing this but came up empty. I believe there must be a clever way of getting this done.
If I’m going about this in a wrong way, is there a way to have a “global” class that can be accessed by code in both projects?
Thank you for taking the time to look at this.
There are two problems with what you're trying to do:
First, as the IDE is warning you, you're about to create a circular dependency. This means that the compiler would need to build project A before it can build project B, but it would need to build project B before it can build project A. Neither project can go "first".
The second problem is that your WinForms project is most likely an executable, and you cannot add references to *.exe files via the IDE. You can add those references via the command-line, but the fact that Visual Studio is trying to stop you from doing it should be a red flag that it's a really bad idea.
The correct way to do what you want is to refactor the common classes into a third class library that you reference from both other projects. If needed, you can wire up events (in particular, look at the INotifyPropertyChanged interface and its event) that notify interested observer objects when things change.
I have Resharper and it's a fantastic tool
Starting a projects and I need to use CodeContracts. However Resharper ignores them.
After checking a few blogs I came across this one:
http://www.infinitec.de/post/2010/11/18/Using-Code-Contracts-Visual-Studio-and-with-Resharper.aspx
However I get an error
Error 2
The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite"
"#MyProject.Coreccrewrite.rsp"" exited with code 1.
Has anybody managed to have codecontracts and resharper to work together?
Edited
What I am doing is
Trying to use codeContract and resharper gives a Method invocation is skipped etc..
Googled and found lots of people with same problem and no solution.
As you can see I attached a link that should have done the trick but didnt
Create a new project in vs2012 and try to use code contract and resharper will not let you.
It will be disabled and if you enable it you get another error
Comment from Resharper team on
http://youtrack.jetbrains.com/issue/RSRP-182553#comment=27-200330
ReSharper will not support "Code Contracts" as is in the mid-term
future. There are 2 main reasons for this:
CodeContracts are written in the code block, and, moreover, in the separate assembly. ReSharper requires contracts to be at the
metadata level
Current contract are too complex and are not supposed to be analyzed in real-time.
During ReSharper development, we analyze CodeContracts and building
corresponding ReSharper code annotation marks. We are going to extent
our annotations, and always keep them in-sync with contracts.
I am stuffed!!!
I'm using xUnit for unit testing and in one of my test classes I have 65 tests. Resharper is flagging one of them as not used and is keeping the file flagged yellow/orange until I delete it. I don't want to delete it. I want to keep that test method.
I assume that you have xunitcontrib for ReSharper installed, since other test methods are not marked as unused. I also assume that your method is public and has the same test attributes as other test methods (e.g., Fact or Theory). If that is not the case, you might check that you have external annotations for attributes of this method (they are provided with xunitcontrib for ReSharper).
One of possible reasons for incorrect issue reporting by ReSharper is that some of its caches have not been updated. If you can reproduce the problem (given that almost a month passed since you asked your question, it seems to be unlikely), try clearing caches via menu RESHARPER -> Options -> General -> Clear Caches and then restart Visual Studio.
It could also be that the ReSharper annotations are turned off.
You could verify this via RESHARPER > Options > Code Inspection - Code Annotations.