Around 500 million years ago, there were animals on earth, but there were no plants yet. How did animals survive? I'm assuming some of the animals ate other animals, but did some animals eat rocks or something?
Since you're a new contributor, I'm going to go ahead and answer this despite the flaws in the question that have caused it to be at -4 when I write this answer (skip to the last paragraph to see what I have to say about that). The major reason the answer isn't more obvious is that your assumptions about how long plants and animals have been around is incorrect. Or rather is based on when a particular type of animal life (sea life with hard parts) arose 500 million years ago and comparing it to when complex plant life was able to colonize dry land (about 475 million years ago). Besides the obvious point that animal life in the oceans is not directly dependent on eating plant life on dry land, there a larger problem. You are treating complex multicellular life as the only type of life. It is not.
When most people think of 'animals' and 'plants' they are thinking about complex multicellular life. Things we can see with our own eyes. The problem is that this type of life is quite recent. For most of the history of life on earth, living creatures have been single celled. While composed of only one cell, these creatures (like animals and plants) could be divided into two groups based on how they got their food: heterotrophs that consumed other things (like animals do) and autotrophs that make their own food (like plants do)
The oldest fossils of single celled life date back to about 3.5 billion years ago. Since these fossils suggest relatively complex communities of multiple types of living creatures, including both heterotrophs (that ate autotrophs or other heterotrophs) and photosynthetic autotrophs (albeit using a less efficient form that did not make oxygen but otherwise lived much like plants do today). We think life originated before that, probably abut 3.8 billion years ago. Mostly because before 3.8 billion years ago, the earths surface was repeatedly blasted with meteorites and comets sent crashing through the inner solar system by the orbits of the outer planets shifting into their current positions (see https://en.wikipedia.org/wiki/Late_Heavy_Bombardment )
I draw your attention to the timeline of life on earth within that article and follow it to the article: https://en.wikipedia.org/wiki/Timeline_of_the_evolutionary_history_of_life
By 3 billion years ago, long before multicellular plants and animals, single celled autotrophs were engaging in photosynthesis essentially identical to how plants do today. Even at 3.5 billion years ago, there were single celled plant-like organisms for animal-like organisms to eat.
Before that? Classically, it has been thought that the first living creatures consumed the 'soup' of organic (carbon containing) molecules that made the first simple informational and catalytic macromolecules that were the likely basis for early protolife (or one well established idea, read about the "RNA world hypothesis" https://en.wikipedia.org/wiki/RNA_world). Either right about this time or soon thereafter, protocells that could make their own food evolved. Similar to very primitive life living in extreme ecological niches today, these chemoautotrophs likely made food from high energy chemical reactions that take place as a result of geothermal activity. In places like "black smoker" deep sea vents where single celled organisms use the boiling hot water and highly reactive chemicals dissolved in it to make food that is even today the basis for ecosystems that do not depend on the light of the sun (see https://en.wikipedia.org/wiki/Chemotroph). In a manner of speaking, these did sort of eat rocks.
By the time complex multicellular heterotrophic life (animals) had evolved hard bits that fossilize well about 500 million years ago (when you incorrectly have animals first evolving), animals without hard bits had existed for about 500 million more years. Even when they evolved, there was a 2.5 billion year history of single celled things to eat. When complex multicellular photosynthetic autotrophs (plants) first colonized dry land about 475 million years ago, some single celled photosynthetic autotrophs had been living there in or near fresh water for about 400 million years (https://en.wikipedia.org/wiki/Evolutionary_history_of_plants). And the most basic complex multicellular photosynthetic autotrophs (similar to simple seaweeds today) had been living is marine environments for a billion years (https://www.eurekalert.org/pub_releases/2020-02/vt-1bg022120.php)
So you can see, your question is predicted on incorrect assumptions. When these are corrected, there is no question at all. As to why this question is downvoted, the incorrect assumptions likely are a big part of it. But you may notice that all the key citations I make are from one source. Wikipedia. I could easily have made it from primary sources or college level textbooks. But I used wikipedia for a reason. You could have done it too. Before asking your question, you probably should have checked to see if what you thought was the timeline of animal and planet development was correct. You would quickly have found it was not. Stack Exchange, as I understand it, really isn't for asking questions that can be quickly answered with a wikipedia search. And that, I think, is why the question has been downvoted so much. As to why I answered it anyway, the question seemed genuine and it didn't seem like you were just trying to lazily answer a question from class. Besides, I think even a question that isn't ideal can teach. By answering, I show my reasoning which may help teach a reader how to answer questions themselves or ask a better question next time.
That and I think the issue of people forgetting that most of the history of life on earth is unicellular is widespread and deserves more consideration. For example, most alien life we are likely to encounter will look like slime on rocks. Just like it would have looked to a visitor to Earth for most of our history. So I rarely pass of a chance to make the point that life is mostly unicellular.