Today Android Studio started to behave strange. Source java files opens
as png files something. I can build and run the app and if I look in the file system the java files looks ok. I do Invalidate cache and restart, I delete .idea and build folders but no change. The strange thing is I can debug run the app. If I want to change java files I have to open like Notepad and save then build project again
There must be some file/setting in Android studio that control this. I delete the project ide and build folded but no change, where in Android Studio can I reset this to start working normal?
I found a solution that worked for me.
I hade to open every java source file and all xml files into a text editor(Notepad++) and change something then save the file back to origin.
Now Android Studio detect all files as normal
Another way to solve this:
Close Android Studio and delete the caches folder:
C:\Users\user_name\.AndroidStudio4.0\system\caches
When you save a file at notepad and open it in Android Studio, it will happen because notepad use a different encoding (ANSI).
You can set your project file encodings at Settings->Editor->File Encodings
You can also edit a unique file encoding at File->File Encoding
Make sure your project file encoding is UTF-8 (default)
Another important setting is File Types that you can take a look too. Here is mine .java file setting to you as example.
Related
I created an App which includes our source code as a native lib (so-file). I'm able to step into it and everything works fine so far with this code.
This native lib links against another native lib which was pre-build on a different machine and which I copied into the jni-abi-folder. I have checked out the svn-repository of this so-file in a different folder parallel to my project and need to be able to debug also into it.
When I now do a break, I can see the method names in the callstack so I assume that the symbols can be loaded, but Android Studio doesn't know where to find the source files.
Under Visual Studio, when I did a break, I could specify the symbols in the symbol path and then an error was displaced that I should navigate to the corresponding source file. Then I only needed to navigate to the folder and it was working.
How can this be done with Android Studio - I have the newest version 3.2.1 installed.
I finally found the solution.
I got a stripped version from my colleague, he basically gave me the version inside his apk which is stripped. Now he gave me directly the build version (I think it is located somewhere in the intermediate directory or so, just search for the name of the lib).
Under Run\Edit Configurations\Debugger\LLDB startup commands the original source directory can be mapped to the source directory on my computer which is different. To achieve this, enter "settings set target.source-map or-dir cur-dir"
There should be a way to find out the original source directory from the so file, but I don't know it right now.
I hope this can help somebody else
I have a Xamarin.Forms app that needs to read data from a json file. I placed the file into the Android assets folder and selected the build action AndroidAssets
Then I try to load the file in MainActivity with Assets.Open(filename) and I get a FileNotFoundException. I deleted the Android and PCL bin folders and tried to build the project again but got the same result. Then I opened the .apk file in WinRar and when I go to the assets folder, the files that I added to the project are not there.
Does anyone have any idea what's the problem here?
Did you set the files as embedded resources from the file properties?
If you not, right click on the file -> Properties -> set as Embedded Resources in Build Action
The problem was with using the "-" character in resource file names. Changed it as suggested by York Shen and it started working as it was supposed to.
I develop an SDK, and would like to be able to check in module files for both IntelliJ IDEA and Android Studio. I've devised the following solution, with one missing piece:
Create module files ending in -intellij-idea for the main project, and each module.
Create build.gradle files, and use the "sourceset" directive to use the old style src and res directory structure.
The problem is that the project information is always stored in a directory called ".idea". Before, I could have two IPR files, such as my-project-android-studio.ipr and my-project-intellij-idea.ipr. I could then open one in Android Studio, and the other in Intellij IDEA, but the actual source would remain the same.
How can I accomplish this? If there is a way to force Android Studio to generate IPR files instead of the ridiculous .idea directory, that would be optimal.
In my app, I decided to change a resource (a PNG file). So, I delete the old one and add the new one with the same name. However, when I run my app in both my phone and the emulator, I still see the old picture !!
I tried all these options:
Cleaning the project.
Refreshing the project folder.
Closing the project then opening it again.
Exiting Eclipse and launch it again.
Uninstalling the old version of the app from the phone before run it again.
For those who may ask about how I use this resource (PNG file), I assign a XML selector file as an ImageButton's drawable. My resource is referenced in that XML file.
Any ideas will be appreciated.
You should change the Modified Date of the file to later. I did it.
Use this http://www.nirsoft.net/utils/filedatech.html
Look through your project's folders for other png files. Many mobile platforms use pngcrush to optimize pngs for mobile, and it is caching them somewhere. When you replaced the file, the IDE didn't notice and hasn't recrushed the new file. The old files will be somewhere in either the workspace's folder, or less likely, Eclipse's application support folders.
Are you on Windows, Mac, or Linux?
Changing an image resource file won't cause Eclipse to build a new version. Try modifying a source file by adding a new line, deleting the line, then saving the file. Eclipse should then rebuild your app when you launch it.
You just need to clean the project before rebuilding it, this removes all previous states and should update resource files if you've changed them in anyway.
Eclipse has a bad habit of compiling all your code to a structure within it's .metadata directory. Not sure if this is the case for your mobile app though.
Try searching the .metadata directory for the original png and modifying/deleting it there. We've had the same issue with deploying to web servers previously and Eclipse not picking up the changes.
I solved it.
The trick was to choose a different name for my image, modify my xml selector file and re-build the project.
Thanks
I keep a couple of .css and .js files inside the res/raw folder of my android project. These files are loaded from a WebView instance and are in this folder mainly due to the access path limitations in WebView.
But my problem is that Eclipse does not include the css and js files into the build dependencies of my project. If I only touch one of these files the build flow is not regenerating the application. I did add the project/res folder to the the Java Build Path in the "source" tab but that didn't help. (I run eclipse 3.6.2 on mac as downloaded - no customizations)
How can I include these files in the build flow ?
UPDATE:
1) moving to the asset folder does not resolve the issue (changes to the css and js files are still not triggering a rebuild)
2) It actually seems like the modification of the js/css files has an impact on the 2nd build after the change. Touching only those files will result in a complete build after hitting the build button twice - Anyone else seen this ?
UPDATE 2:
1) I observer this only on MAC, the same version of eclipse works flawlessly on PC.
UPDATE 3:
1) This is only an issue when using an external editor for the files, once I switched to the Text view inside Eclipse, the rebuild happens correctly.
I did not find a clean workaround, but switching to the internal editor (regular TextView for all the js and html files) solved the problem partially. As long as I stay within the eclipse environment this works fine.
Resources such as these are better off in the assets/ directory and you should use AssetManager in order to read them.
http://developer.android.com/guide/topics/resources/providing-resources.html