I\'ve updated my eclipse and ADT Plugin to the latest version recently and recognised some big changes. Whenever I create a new Android Application Project there appears a new a
Why is that?
Because Google engineers added that stuff to the new-activity templates, for at least the "BlankActivity".
Why is the activity_main.xml file not preferred for activity layout directly anymore
You are certainly welcome to use activity_main.xml
for whatever you want. It so happens that Google's current templates want you to use fragments. Google's templates are just templates. One can argue -- and I have, vehemently -- that a "BlankActivity" template should not be doing what it is doing. However, beyond that, it is just a template.
why appcompat library is now included in every project ?
Presumably, they wanted to start you off with a consistent action bar, even on older API levels.
I realize it has something to do with actionbar but the problem is that whenever I create a new project a red exclamation mark shows up on both project's file and appcompat_v7 file and this prevents me from compiling/running the application or even sometimes appcompat_v7 file doesn't create and the only thing I get is damaged code
I reported this issue a week or so ago.
so how can I remove this dependency
Step #1: Right-click over the project name in the Package Explorer, and choose Properties. Click on Android in the list of property categories on the left, and scroll down on the right to the bottom:
Step #2: In the list of attached library projects that you will now see in the properties dialog, you may see an entry akin to the "appcompat_v7_6" one that you see in the above screenshot. Your last digit will differ, and it may be that yours has a red X instead of a green checkmark. Regardless, if there is an entry for "appcompat_v7_NNN" in the list, click on it, then click the Remove button to the right of the list. Then, click the OK button to close up the dialog.
Step #3: In res/values/styles.xml
, change the parent of AppBaseTheme
from Theme.AppCompat.Light
to @android:style/Theme.Light
. In res/values-v11/styles.xml
, change the parent of AppBaseTheme
from Theme.AppCompat.Light
to @android:style/Theme.Holo.Light
. In rest/values-v14/styles.xml
change the parent of AppBaseTheme
from Theme.AppCompat.Light.DarkActionBar
to @android:style/Theme.Holo.Light.DarkActionBar
. Note that these values assume that you chose the default "Light theme with dark action bar" when you created the project -- you will need to make slight adjustments to those instructions for anything else.
Step #4: In res/menu/main/xml
, remove xmlns:app="http://schemas.android.com/apk/res-auto"
from the root element and the
app:showAsAction="never"
attribute from the
element.
Step #5: In your activity (e.g., MainActivity
), change the parent class of the activity to something other than ActionBarActivity
-- FragmentActivity
would be a good choice, to minimize the number of other changes you will have to make immediately. Also, clean your imports (e.g., Ctrl-Shift-O).
At this point, other than perhaps cleaning your project (Project > Clean from the main menu), the appcompat
stuff should be ripped out of a project created using the "BlankActivity" template and with a "Navigation Type" of "None". Other templates, or navigation options on the "BlankActivity" template, will probably require more work.