Please help me solve the following bug. After many attempts, I came to the conclusion that the point is not which program template I am using, but specifically in the xml files that have a design section (like activity_main.xml), it seems to me that I have already re-tried everything:
installed new gradle
deleted the .idea .gradle folders, files with the .iml extension, modules, settings.gradle files a million times
Invalidate Caches / Restart
changed the path for the SDK
imported the project using "Import project (Eclipse ADT, Gradle, etc.)"
deleted all files along this path C: \ Users (Your UserName). AndroidStudio (version) and not only these files
did chkdsk
And it still doesn't work. The crash occurs only when opening xml files with design sections, on other files, including .xml, everything is ok. Has anyone come across a similar one?
P.S. the error occurs by default along with the creation of a new template.
I seem to have figured out this error.
For those who will come across something similar in the future:
If I start a project and open an xml file that has a design in it (for example, activity_main.xml), then the program crashes. If you do not open this file, then everything is ok. You can even run it. The solution is as follows: you need to go to your project, while the main thing is that the xml files (similar to those I described above) are closed. Then start the MainActivity class with a debugger (set a breakpoint and then shift + F9) and then you need to walk a little (I mean step into with debugger) (maybe this is not necessary at all) through the files using F7 (step by step) and then open the file activity_main.xml (or any similar ) and voila! It will load and will not kick you out. Then you can work. You can even go out and go into the project and then it shouldn't crash anymore, but after the reboot your system you will need to repeat this process. I don’t know what it’s connected with at all, but it seems to me that the problem is that something prevents the .xml files (that is, the design tab) from loading and the program starts to crash with an unknown exception. And in order to solve this, you need to somehow run this file.
Try to install the latest Android Studio version from here and reinstall all files from beginning on your set-up
Restore default settings
I think its work.
I've solved the issue by installing Android Studio 4.2 RC 1 from https://developer.android.com/studio/archive.
When trying to run the Xamarin.IOS project of my mobile application I get the following error.
File not found: /Users/USERNAME/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/665113b8e3040a55db5fc43a003035bd/NLogLogger.xcassets/AppIcons.appiconset/Contents.json
Q1.) I have another project which runs successfully, and that projects checks for the Contents.json file in the directory:
/Users/USERNAME/Library/Caches/Xamarin/mtbs/builds/OtherApp.iOS/665113b8e3040a55db5fc43a003035bd/Assets.xcassets/AppIcons.appiconset/Contents.json
This leads me to think that the issue is coming from Xamarin looking for Contents.json in the wrong directory, any idea how to get it to look in the proper location? (I think this could fix the problem)
Q2. Does anyone understand this error and how to fix it, I have been stuck with this for quite a while now.
Note: I have been focused on the Xamarin.Android for this project and this is the first time I am running it the Xamarin.IOS version.
I was able to solve it this way:
Right click your ios project > unload project > and edit the csproj file.
Scroll down and delete the following inside the csproj:
.csproj:
<ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcons.appiconset\Contents.json">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\LaunchImages.launchimage\Contents.json">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
Reload csproj.
Clean
Rebuild
The Contents.json file is automatically created when you add a new xxx.xcassets to your iOS project. This usually happen if you forget to include it to your project.
You can check if the Contents.json file exist by right click NLogLogger.xcassets --> Reveal in Finder and then you can see the Contents.json file in the folder.
What I recommend you to do is creating a new xxx.xcassets and readd your images there, then clean and rebuild project.( Remember to delete the NLogLogger.xcassets)
Fixed my issue by excluding the NLogLogger.xcassets (which was located in Asseets.xcassets) from my project and then deleting it.
I also had to make changes to the file MyApp.iOS.csproj, and remove the <ItemGroup> that specified the NLogLogger.xcassets directory (and some other items in the xml that were unnecessary). Rebuilding did not fix this initially because I did not exclude them from the project.
I cleaned, and rebuilt my project after this and it works.
Recently my project got messed up. I don't know how it became like this. There was no power failure or anything happened while using Android Studio. Next day I opened my project and now it's a full mess. I attached the images of how they look now.
Classes are not recognized as you can see they have .java extension showing and when I opened one of them it show like below. but if I opened the file directly from notepad or something the source-code of these files are not changed.
I did delete .idea all .iml files inside the project then invalidate & restart build project again. But no luck, no matter what I did it doesn't get resolved. I have an old backup of this project and not a recent one, so I want to get this fixed .
I tried opening my other projects and they work very well. The problem seems to be only in this project. Android Studio is updated to last version before this problem persisted. So it's not also a bug in Android Studio.
This is how the Java file looks when I opened with Notepad++. The code didn't disappear, no I also didn't write xml code in my Java file:
I just had to copy all the source code in .java files back into android studio editor, which the files are with .java extension. Problem solved
I have same problem occur few days ago, solved by below steps
uninstall android studio,
download latest from link
delete all file from default android studio folder
(C:\Program Files\Android\Android Studio)
install new downloaded android studio , all worked well.
I had a similar problem, but with Kotlin files.
What worked for me was shortening the file name by a few characters (but not the class name).
I suspect that there's a limit to the length of the path which can get quite long if you try to organise a large(ish) project using subfolders.
If you have just created a new package directory inside your project and moved class files from the project into the package directory you just created you will get this error.
To avoid it. Instead of moving class files, copy them and next build your project. Very important this part to build the project.
Next you need to delete the duplicate class files outside the package (Can't use safe delete for this)
And finally you need to change the imports on all affected class files to reflect the new namespace / location. My suggestion is to use "replace in path" from the Menu Edit > Find
Being a week old in AS, I am trying to find the folder/file paths that are being referenced in some posts. For example, when reading posts about trying to understand how to resolve the lack of an R.java file, several posts refer to a path, such as
"build/source/flavor/r/build type(optional)/package/R.java."
In Android Studio 1.2.2, I created a new project, named it, pasted some XML layout code into the generated layout file, then also the associated Java code for making a popup window, into the Activity window. Then ran the project. It could not find the R.java file so crashed.
My problem at this point is that I cannot seem to find such a path anywhere so I can track things. The path components look like they would be hierarchies in Android projects. But I cannot find anything like this in Windows Explorer, in the Android project window, the Android structure window.... Any ideas?
I don't know if the crashing prevents the R file from generating, since the build never finishes. Or rather if I just need to read more documentation ;) Thanks for any help.
It could not find the R.java file so crashed.
You have an error in one of your resources or your manifest, preventing R from being built. If you do not see an error indicator on any of those files in the project tree (left-hand pane in Android Studio), run Tools > Rebuild Project, and you should get an error pane popping up at the bottom of the screen after a moment.
My problem at this point is that I cannot seem to find such a path anywhere so I can track things.
In Android Studio 1.2.2, for a standard Android Studio project, the generated R.java file will be in:
app/build/generated/source/R/.../your/package/name/R.java
where:
... is typically going to be debug for the sorts of builds that you are doing, but technically will be tied to whatever build variant you are building (see the Build Variants view, docked on the lower left side)
your/package/name/ will be based on the package attribute in the <manifest> element of your AndroidManifest.xml file
Before coming to the problem let me explain what I did that has landed me in the problem.
I created an account on github and made a repository named Android.
Then I installed github client in my windows 7.
Then I opened this client, provided my authentication and cloned the repository to a local directory C:\Users\Aniket\Documents\GitHub\Android(This folder has the .git folder in it).
Then I went to my Eclipse ADT and installed EGit plugin as described here. Also I
Then in Eclipse I right click on my project TicTacToe go to Team->Share Project and provide my repository path i.e C:\Users\Aniket\Documents\GitHub\Android.
My Project was added to the local repository and in my github client it shows me all option to commit file in the actual repository on the github site.
But my project is suddenly showing error with a red '!' sign on it.
Description --> Archive for required library: 'C:/Users/Aniket/AndroidWorkspace/TicTacToe
/libs/android-support-v4.jar' in project 'TicTacToe' cannot be read or is not a valid ZIP file
Resource --> TicTacToe
Path Location --> Build path
Type --> Build Path Problem
Note : the Error was a single line displayed in error console on Eclipse. I just split it up for readability.
Even after detaching repository it shows that error.
Has anyone encountered this scenario before. What is the solution or workaround? I googled and first few links suggest it is an Eclipse bug. Please suggest what can be done to bring my project back to executable state?
It is an Eclipse bug. I have faced the similar problem several times. closing and reopening the project works sometime. if it doesn't work try restarting Eclipse.
I've seen the same issue. I removed that jar file, and then rightclick on the project, select maven, and do "update project...". The jar was downloaded again, and the problem was gone.
There is other case to display error Archive for required library
Right click on project and open --> project project properties --> java build path --> Android private libs
if there are two jar files with same name then remove one from libs.
jar file may the hidden some times then
open you libs folder in window and check if any hidden files are exist
Organize --> folders and search options --> view --> check show hidden files
and Delete the hidden jar file , The same cass delete if hidden java fies exist in src and packages if any
Looks like everyone has different story to tell! For me, I had to delete the error from eclipse Markers tab, and then cleaned the project again. Before that, I closed and re-opened the project/eclipse several times as suggested by #rachit, which did not work for me.
In my case, i'd downloaded project from internet, after unzipping project some files had been blocked, just unblock files and try again, then problem was solved.
In my case I tried all the tips suggested but the error remained. I solved changing version with a more recent one and writing that in the pom.xml. After this everything is now ok.
In my case restarting Eclipse did not solve the problem. I restarted the computer and did a Project -> Clean in eclipse
A solution that worked for me:
go to *.classpath and delete the line :
<classpathentry kind="lib" path="the_problematic_class.java"/>
Could be due to corrupted jar files as well. Better to check that first as that was the reason in my case:
jar tf myjar.jar
should list the content inside.
i was facing same problem in Eclipse Mars. I downloaded the jars from [https://oss.jfrog.org/webapp/#/artifacts/browse/tree/General/repo/org/ethereum/ethereumj-core/1.0.0-SNAPSHOT][1]
and replaced it in the directory.
I got error while adding ethereum.jar using pom.xml at C:\Users{machineName}.m2\repository\org\ethereum\ethereumj-core\1.0.0-SNAPSHOT\ethereum-core-1.0.0-SNAPSHOT.jar , i added the downloaded jar(ethereum-core-1.0.0-SNAPSHOT.jar) here and the problem was solved.
I will say that it can be that some answers work for some cases, but for me it was necessary to go an extra mile. So I will try to make a summary of what can be done:
Verify that the jars are intact:
jar tf myjar.jar
Restart eclipse and update projects setting over right click on project -> Maven -> Update project
The option which has work for me was to navigate in the workspace folder and then delete the files:
.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache
.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache
After that restart eclipse and rebuild project.
I found no duplicates anywhere and tried restarting eclipse, rebuild project. I was getting error for only one libary. So I just tried to rename the jar file from ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar to ksoap2-2.5.8.jar
So if none of the problems solves from above you can also try this one
In my case, the java installation was not proper. So, I uninstalled Java and reinstalled a new version. Now, it works.
For us, the problem seemed to be the size of the .jar file. I would recommend doing the following test to see whether this is the case or at least rule it out. First have a look at other jars in your Eclipse project and compare them to the problemetic jar. Is it a lot bigger than the others? If so, try the following workaround. Else, this answer probably won't help you. Before starting, configure Windows to treat .jar files as .zip files with the following command line command:
assoc .jar=CompressedFolder (see https://superuser.com/questions/121540/can-you-configure-windows-to-open-jar-files-like-zip-files-without-a-3rd-party-t)
Optional: A simple Test
Before trying the workaround, here is a test to see if it is indeed the jar file size that's tripping you up.
Create a large .jar full of random .class files that aren't in your problematic jar. You can do this by making a folder full of files, zipping it, and renaming the .zip extension to a .jar. Windows might warn you about changing the extension. Ignore this. Make sure you have enough files in the folder so that it's a bit larger than the problematic jar.
Try to import this artificially created jar. If it fails with the same error, then size is probably the issue.
The Workaround
If it is indeed size that's the problem, which you might have identified by doing the optional simple test above, you can try the following workaround.
Decompress your .jar file. You should be able to do this easily in Windows
Split the folder you get from step 1 into smaller sub-folders. It could be just two folders, or more, depending on how big the original is. You want the folders to be smaller than some of your existing "good" jars so that size won't be an issue. Make sure to keep the package structure intact when you're doing this.
Zip up all the folders you created in step 2, and rename the .zip to .jar.
Import all of the .jars from step 3 individually.
The steps might be a bit unclear, so here's an example. Imagine your jar file was called mylib.jar. You unzip this to a folder called mylib. Inside, let's say there are three sub-folders called package1, package2 and package3. Create 3 folders called mylib1, mylib2 and mylib3, and put in package1, package2 and package3 respectively. Then zip these up and rename extension to .jar. You'll then be importing mylib1.jar, mylib2.jar and mylib3.jar.
For Java web application, web.xml added as jar in the project. In project explorer, try to find web.xml as in jar icon and remove from the project. Error will go away!!
I was stacked on this problem for days despite searching for a solution on the net. I first moved my project to Netbeans and all worked fine. I then returned to eclipse->properties->java compile-> Building and changed "Incompartible build path" option from error to warning and then did maven update and it worked.
I realize this is an old question, but I have yet another solution if none of these work for other people coming across this thread.
I had this same problem, and spent alot of time trying to figure it out, only to find that my Eclipse classpath/buildpath has a .json file in it, it doesn't like that, so it wouldn't compile.
So, check to make sure no text files or json files, etc are in your build path.
I had accidentally put the web.xml into the build path :x