Reputation: 49
So I am just starting to learn to program with Android. Everything works great (I'm using Eclipse as IDE by the way). I only had this problem. Every time I make a new project that I chose API 8 as the Minimum required SDK, and chose a theme (Holo Light with Dark Action Bar for example), Eclipse will ALWAYS import a NEW COPY of the Android Support Library v7 (appcompat). I know this is required for the ActionBar and Fragments on old devices (API 7 - 10). But what I don't get is why Eclipse has to import a new copy of the support library all the time (well I'm just starting to learn and I am thinking that the support libraries can be and is meant to be edited, I'm not sure).
So due to this, I made my own solution. I followed what is said here from the Android Developer website. I imported the support library to my Eclipse workspace by myself. Then I created a new project. So, Eclipse (once again) imported it's own appcompat-v7 support library. I deleted it and then on the Properties of my project, I replaced the deleted appcompat-v7 library with my own-imported v7 library I added earlier.
This could have been a solution, but I encountered some problems
Eclipse added a new package in my PROJECT_FOLDER/gen named from the Support Library I imported manually, and as a result (which I don't understand why), it creates it's own R.java file (which causes a name collision-like effect). That is, when I mention something like this on my code, the R.java file that is searched was not the right R.java (but the duplicate R.java file)
EditText editText = (EditText) findViewById(R.id.edit_message); // this shows an error because the duplicate R.java file contains different fields from what the project's R.java file have
Another thing, when I create a new Activity, many errors are popping on the Eclipse Console like
[2014-04-08 14:53:49 - MyFirstApp] C:\Users\ME\Documents\Android\Android Workspace\android-support-v7-appcompat\res\values\attrs.xml:572: error: Attribute "textAllCaps" has already been defined
Is there a right way of doing this? Or the Support Library is really needed to be imported always? Thank you.
Upvotes: 2
Views: 2477
Reputation: 1
right click on project, go to properties, go to android, and then remove all app
Upvotes: -2
Reputation: 1143
I faced the same problem when accidentally recreating the MainActivity. As a result it imported a new reference to the Appcompat libraries.
You see these errors because there has been duplicate reference to the reference to the Appcompat libraries. Do not delete anything yet.
First thing you must do is remove the duplicate reference by right clicking on your project or press Alt+Enter to show the project properties window. Then click on Android tab and go to Library.
On the list of referenced libraries, you will likely see more than one reference to the Appcompat library. Select one and click Remove then click Apply and OK.
You can then the unwanted MainActivity activity, its layout and menu XML files. But be sure to take extra care.
I hope this helps.
Upvotes: 5