Is it not possible to comment out lines in the top-level Android.mk file of an Android Studio NDK project?
If I remove the Hello.mk line shown below, I get no errors. If I add a # then I get the error "This file is not part of the project."
How can I temporarily remove this line (i.e. comment it out) ?
For some weird reason Android Studio tries to treat your Android.mk as a C++ source. You can safely ignore this and many other warnings that AS displays.
OTOH, you can safely delete the line, instead of adding # in front: Android Studio keeps local history of the files that you edit thorough it; so, you can easily restore any changes to this file when you need that.
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 opened a folder in Android Studio which contains a Kotlin script file (.kts). I configured a JDK as SDK in Project Structure (but I added no gradle files), and running the file as Kotlin script works fine. However the syntax highlighting is only PARTIALLY working, see below example (Linux Mint 19.3 and AS 4.1.3):
Some of the stuff missing:
unused variable should be gray (val unused)
to/forEach keyword should be yellow and italic
misspelled variable names should be red
bad style such as extra spaces should be underlined
etc.
What's even going on here? Is this some sort of "fallback" mode?
Any way to use the "full" syntax highlighting from normal Android projects, so I can spot mistakes earlier?
For reference, this is what it "should" look like (pasted into a random Android project):
Renaming the file to end in *.main.kts (scriptname.main.kts) enabled full highlighting for me!
I get this type of issues from time to time with IntelliJ IDEA. I haven't found the reason why it happens, neither do I know the 100% working solution. But here are the options that usually help me solve it:
Restart IDE
Invalidating caches: File > Invalidate Caches...
Re-import the project. Remove the .idea folder and the project.iml file and try to import the project again.
Update the IDE. Last time I had this issue, nothing helped but updating IDEA to 2021.1.
I hope some of these options will help.
I like how Android Studio and Visual Studio , generate the comments for each closing brackets, but when I open the same file in notepad++ or any other text editor, I don't see those comments. Is there a way to generate the saved dart file so it has those comments stored as part of the text code( in comment) ?
Here is one code example that how code looks in android studio.
but when opened with notepad it does not have the comment MaterialApp. I am guessing there is some settings in android studio that will let me save file with generated comments, so it can be useful outside of Android studio like in git etc.
These comments are generated "on the fly" by the Flutter plugin for Android Studio. At no time, these comments are inserted into your source files. They are just shown within the IDE. So I think there is no way to "export" these comments.
Recently updated to Android Studio 3.5 and now my code is full of annoying yellow lines with warning that I would like to suppress.
However, when trying clicking on the yellow bulb and use the solution proposed, it does not work, it just adds a comment-like line that has no effect, example:
When getting this warning:
"Use => for short members whose body is a single return statement"
Yellow bulb just adds a line above like this:
// ignore: prefer_expression_function_bodies
Any permanent solution to these annoying warnings in Android Studio?
The Dart analyzer does this and the ignore comment should suppress the warnings. By the way, this should not have anything to do with your Android Studio version.
There are two main ways to suppress specific lints "globally":
Use ignore_for_file comments. This is analogous to ignore, but works for the whole file.
Simply add the following somewhere:
// ingore_for_file: prefer_expression_function_bodies
Specify exclusions in your analysis_options.yaml file. You can always view documentation for all the lints, e.g. for prefer_expression_function_bodies, and any lint can be excluded in your analysis_options.yaml file (it should be placed in the same directory as your pubspec.yaml):
linter:
rules:
prefer_expression_function_bodies: false
Learn more.
Every once and a while I have an issue with the new Android Studio. Sometimes while editing, if I make a mistake in one of my files, then try to build it, Android studio will come back with some "Gradle" error. It will then automatically REVERT back to my original code (thus deleting any of my changes). I do not necessarily like this behavior, but I could deal with it.
However... sometimes, in the course of SAVING and editing, it gets into this weird state where Android Studio will REMEMBER the error, and wont let me correct it. I.e. it will keep restoring the OLD version of the file, with the error in it, no matter how many times I try to correct it and re-save it. An example of this is as follows. In the following XML document fragment, I mistakenly added the [android:backcolor="#00000000"] to one of my XML layout files...
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#111"
android:background="?android:attr/activatedBackgroundIndicator"
android:backcolor="#00000000"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
After trying to build, Android Studio came back with the following error:
"Error:(1, -1) Gradle:No resource identifier found for attributed 'backcolor' in package 'android'.
Of course, I tried to simply DELETE the offending line that I added to return my code to its original state, before I added the line. I saved it (i.e. save-all/etc...) then tried to rebuild. To my dismay, Android Studio RESTORES the bad version, reinserting the erroneous [android:backcolor="#00000000"] line again back into the file.
I have also tried SAVING (save all) exiting out, going back in, the rebuilding it again, and just about every variation of this. Though the ONLY way that seems that will correct it sometimes is to completely exit out of Android Studio, start it back up again, and try again.
I am guessing that this is really a "feature" and has something to do with source control, and/or Gradle, and that I just don't fully understand it yet. I am also guessing that there is some setting somewhere to adjust and/or correct this - but I am clueless as to what is going on and what to do to fix it.
Is there a way to correct this annoying behavior of Android Studio?
I've had a similar issue when I make a mistake in my strings.xml file, for example when I have an apostrophe without preceding with a '\'. The trouble is that when the build fails, Android Studio automatically opens app\build\intermediates\res\merged\debug\values\values.xml to show me the broken string. If I then try to correct the string in that file, it doesn't do any good because when I try to rebuild, strings.xml is still broken. The crucial thing is to make sure that you're making the correction in strings.xml rather than the values.xml file.
I have the same issue, but i followed following steps and it resolved my issue,
1) Edit your layout file and open the same layout file in notepad, if you can see updated data in notepad then its Studio Synch issue. then re-synch project.
2) If your edited layout file is not reflecting new changes in notepad file then, first re-synch Studio project and followed step 1.
I hope this will resolved your issue as well.
I still have this issue, the only way I have found to fix it is to go to the terminal in android studio and run
rm -R app/build/intermediates/data-binding-layout-out
Android Studio is failing to delete the last build of the layout, when you try to compile again. Once you do it manually everything is back to normal.
While this issue still occasionally happens (as of currently the latest version is 0.5.+), a simple workaround is to manually edit the xml file with a text editor, then save it. Android Studio will then force resync those files.
To save the latest edits, click on the particular file in project window and select synchronize, and rebuild the code. then the latest edits will be saved.
I just had the same error and made me go crazy
I solved it by copying my project file to another directory and then importing it as a new project and the problem disappeared