The masterpiece called Android Studio is painful to work with: I can't help but seek your help with a following problem:
Once I ran some code, changed it a few times since then, but no changes were actually made and studio keeps running the old code (which does not even exist anymore). After I clean & rebuild the project, it sometimes works and the new code runs, but then after a couple of changes I encounter this trouble again.
Since building/rebuilding and compiling again takes more time than writing code, this is no option for me. I checked some related questions, one advice was to turn on Virtualization in BIOS. I did, but nothing changes.
My laptop is Lenovo G50
Virtualization is on.
Win10 x64
Android Studio 2.2
MainActivity as configuration (with red cross and "No main method found" sign).
Any help appreciated.
This is happening because there is error in your code and you have selected run without warning when error in program exists. In such a case the last successfully built code would get pushed! Try doing a clean (Build --> Clean Project), if the project now shows up errors you have your culprit, else make sure your XML files are all proper.
MainActivity as configuration (with red cross and "No main method found" sign).
this can happen in two cases:
Your MainActivity class isn't properly added in the AndroidMainfest.xml
Your MainActivity.java or activity_main contains error
make sure to check both of this thing,and then clean your project(Build --> Clean Project).This tells the IDE to delete any previously compiled binaries and rebuilds them. (The APK file).
Related
To complete the question: I believe either this is due to patch update to Gradle or project Gradle settings, but I am clueless.
gradleVersion = '4.2.2'
compileSdkVersion = 31
minSdkVersion = 21
targetSdkVersion = 31
buildToolsVersion = '31.0.0'
com.android.tools.build:gradle:4.2.2
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
I use Android Studio for development.
Version:
After frequent system crashes on Windows 10, due to corrupt memory modules, some of the features crashed. I searched in Google and Android Studio documents for troubleshooting, but it seems that my search keywords were not strong, to get me a relevant solution to roll back Android Studio to a stable state.
.git files corrupted: due to which I could see bad file contents where in fact the codes in the files were intact. What I was seeing in the files was due to .git files that were corrupted.
I simply left the project and cloned it in another directory. With .git restored I saw the files in their original form.
Problem started after that. Though the code compilation to the creation of APK was intact, the LINT worked partially correctly.
I re-installed the Android Studio, but due to the previous installation, there was no change. I want to restore the LINT to the previous state. I have the image to show what is happening.
Some keys and flow of control of Kotlin are not recognized showing unnecessary errors. It is difficult to know whether I am writing the correct spelling (one example for the difficulties I am facing) or not until I build my project.
When my .git files crashed, the code was intact, but show garbled texts in the Android Studio Editor for the same file.
Some Kotlin flow of controls are not recognized by Lint
Update:
Intelliscence and Lint are not working in Kotlin Android:-
Kotlin is unable to find OkHttp's extension method: toMediaOrNull().
I found this link :- Uninstall Android Studio with complete effect
Note: Some sections here will be moved to the question section above, and also some
sections from the above question section are worthy to be moved here in the answer.
Once verified whether this is working successfully, I will update a detailed answer.
Update:
The Lint and the IntelliSense, both are not working, and TODOs are not highlighting, after this solution. Now I don't see any red marks, so it is just like working in a plain text editor, except for the keywords highlighting.
IntelliSense not working:
The Analysis process (top end of the editor screen), never stops.
There is not a single change after I deleted the .gradle and .idea folders in the root folder.
Some of the IntelliSense came back after invalidating the cache and restarting Android Studio.
Following: Rename folders inside your {{user_dir}}/.android
folder.
Step by step, we are coming to a close and only this is left: Some of the newly added variables in the binding (layout) are not recognized while the older widget ids are still recognized (in the camel case (Kotlin), from snake case (layout XML)).
New Ids in layout --> binding, are not recognized:
Old Ids in layout --> binding, are still recognized:
Let me observe this for some time, to see whether it comes to normal and come up with more updates. As usual, I face no issues while building and running the APK on my Android device.
I know this has been asked many times, but usually the advice is something along the lines of "decrease Android gradle plugins version" or something like that. Firstly, that doesn't seem to work for me, secondly, decreasing the version in order to solve this kind of problem doesn't seem like a good practice and I'd like to avoid it (especially since Android Studio warns me I should increase the version back again when I try to decrease it).
So now what exactly is happening + some details that might help:
Every class is underlined with red color in the project explorer and there are loads of "java package R does not exist" messages in the Problems view
When I open any class, suddenly its red underline disappears and there are actually no errors in this class
It happens if and only if AS does an automatic build (I can see "21:03 Auto build completed with errors" in the Event log). When I build manually, there are no errors in the Problems view, and no class is underlined (that is, until AS does auto build again, which happens all the time)
In any way, this doesn't prevent building of the application/APK/AAB, installing it on the phone/virtual, and running it
This has been happening ever since I updated Android Studio to v4.1 (I now use Android gradle plugin v4.1.0)
(Of course, I also tried all the obvious stuff - deleting every temporary/generated file, invalidating cache, restarting, cleaning, etc. etc. Everything I could think of.)
I had a problem like this before, it had nothing to do with the gradle ijust add "import com.package.appname.R;" into myclass and is worked
A couple days ago I tried to initialize Visual Studio Code to be able to code in C++ using online instructions. They ended up not working at all, but I had edited some settings files (such as a .json file) in Visual Studio Code that I thought were all C++ specific. Afterwards, however, I no longer have the convenient "run | debug" buttons appearing above any "main" functions that I make in java files. In the past I used to be able to just click run and my program would run in the terminal at the bottom of the screen, as opposed to manually compiling and running the program using a terminal. I am running Windows 10. Does anyone know of any way to get these buttons back?
This is an example of what the two buttons look like, appearing above any main functions in a java program.
I also found on the Visual Studio Code website a description of how to begin debugging, attached here, that describes that you need Language Support for Java(TM) by Redhat in order to get these two buttons. I have this extension downloaded, but it is still not working. Please help if you recognize this issue!
What worked for me:
Make sure you have Java extensions, Java Debugger and other basic Java packages installed.
Then making sure the main function is formatted properly like below allowed the Run|Debug buttons to be seen.
public static void main(String[] args) {}
First of all, for troubleshooting, actually we need to have a reproduce steps which can understand what happened in your environment. So can you tell us what you have done to your settings first?
Second, there is a setting under common setting tab, that is Java>Debug>Settings>Enable Run Debug Code Lens. Please check whether this option has been unchecked. Although I think it should not be changed by you.
I need help resolving the following error:
Error 2 Could not copy the file "obj\x64\Release\project_name.xr.xml" because it was not found.
NOTE:
This error does not occur when I package the same solution on x86.
This only occurs on x64.
In addition, this error is now exposed ever since I downloaded VS2012 Update 2.
The error went away as a result of me fixing the list of warnings that resulted from building the solution.
For me the issue was fixed simply by removing spaces from Assembly Name parameter. This can be found in the properties of the Windows 8.1 application project.
Ok, this is a weird problem and I could not solve it till I looked at the solution from Ken.
Click here for his solution
Ken's issue and solution gave me an idea and it worked.
I had x:Class="project_name.App" in my App.xaml file and Ken said the issue was with the app name.
So I removed the .App from x:Class="project_name.App" and just had x:Class="project_name" and received the error "Invalid value for 'project_name'. Event values must be text."
Ok so I put it back in.
Well, then it worked and the error went away.
Um, I do not have any idea why it now worked as it was exactly the same text, but the process of changing it back and forth fixed it. Hope this saves someone hours of pain.
And I am using Visual Studio 2013 Update 2 that I reinstalled onto my PC yesterday since the PC had a melt down and needed a rebuild.
I have been using the customer preview of Visual Studio 2012 up until day before yesterday when the Release Candidate became available. After I installed the Release Candidate, I can't get to the Test Window (Test / Windows / Test Explorer).
I get the following lengthy error which I've copied manually here. (Since this is my first question, I couldn't post the picture, and the screen would not allow me to copy the text to the clipboard. Hopefully there are no typos.)
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) Value cannot be null.
Parameter name: testPlatform
Resulting in: An exception occurred while trying to create an instance of type 'Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory'.
Resulting in: Cannot activate part
'Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory'.
Element: Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory -->
Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory --> CachedAssemblyCatalog
Resulting in: Cannot get export
Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory
(ContractName="Microsoft.VisualStudio.TestWindow.Model.RequestConfigurationFactory")' from part
'Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory'.
Element:
Microsoft.VisualStudio.TestWindow.Model.ReqeustConfigurationFactory
(ContractName="Microsoft.VisualStudio.TestWindow.Model.RequestConfigurationFactory") --> CachedAssemblyCatalog
The error occurs regardless of whether I have opened a solution or not. A second attempt to open the window yields "Cannot create the tool window." After restarting Visual Studio, and attempting to get to the Test Window, I get the long message again.
At the time I upgraded Visual Studio to the Release Candidate, I had installed:
NUnit
SpecFlow
ReSharper (Beta)
Code Contracts -- the last thing I had installed before upgrading Visual Studio. I cannot guarantee that the test window was working after I installed this.
I have searched the web for key phrases out of the error message, but found no help.
I have also:
Repaired Visual Studio (which solved a problem I was having getting to the Extension Manager, but not the Test Window problem)
Uninstalled Visual Studio and reinstalled it
Uninstalled each of the Extensions/packages listed above (NUnit, SpecFlow, ReSharper, Code Contracts). Uninstalling didn't seem to help, so I have re-installed all of them,
one at a time. I've also confirmed that I can run tests in the ReSharper test window.
Deleted the currentsettings.vssettings file from C:\Users\\Documents\Visual Studio 11\Settings, hoping it contained the problem and would be recreated correctly. I got a message that "The IDE will use your most recent settings for this session". I don't know where to find those...
Reset settings from the Import and Export Settings option.
None of these actions has helped.
It looks to me like a config file somewhere is missing an element for testPlatform, but I have no idea where that would be (or in what format, or what Options page entry would set it.)
Any help would GREATLY be appreciated.
I didn't figure out exactly what was causing the error, but I did get it fixed. Here's what finally worked
I installed all VS 2012 one more time, plus the extensions, then looked for bits that might have been left behind by the uninstall. I found and deleted the following before reinstalling:
C:\Users\<my id>\Documents\Visual Studio
C:\Users\<my id>\AppData\Roaming\Microsoft\VisualStudio
C:\Users\<my id>\AppData\Local\Microsoft
Registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
Upon re-installing Visual Studio 2012 RC, the original problem was resolved. Re-installing the extensions also worked successfully.