android studio

Things You May Not Know: Tools Attributes

Things You May Not Know: Tools Attributes

You may have seen an extra namespace, xmlns:tools="http://schemas.android.com.tools", in layout files generated by Android Studio. Adding this namespace to your layout provides you access to attributes, the Tools Attributes, that add metadata to resource files, that facilitate manipulating, rendering, and testing layouts in Design view, and (while I do not condone excess of this kind of behavior) that suppress certain Lint warnings (but only if you have a good reason for ignoring them, she nags). 

Hunting Unused Android Resources with Lint

Hunting Unused Android Resources with Lint

I love Lint. I love Lint because it mocks me. Lint mocks me with little yellow markers pointing out questionable code that I need to tidy, and being on the OCD-ish side, I do that.

Lint can also generate a full warnings and errors report. The report can be (and depending on your code base, often is) overwhelming, but a fairly straightforward-to-find section is the "Unused Resources". Unused resources (layouts, strings, colors, drawables, etc.) bloat the application and slow down builds. So obviously, these jerks have got to go.

Adjusting VM Options for Android Studio on Mac

After six weeks of being knee-deep in iOS, I am switching back to the Android side of my brain, which includes finally getting into Android Studio.

For those of you in the same boat as me and wanting/needing to tweak your VM options on Mac OS X, you will follow the same basic procedure as editing VM options on IntelliJ, which JetBrains's Serge Baranov spells out in a couple of posts.

  1. Find Android Studio in your /Applications folder.
  2. Right-click on Android Studio and select "Show Package Contents."
  3. Open the bin directory.
  4. Copy idea.vmoptions to ~/Library/Preferences/AndroidStudioPreview.
  5. Open ~/Library/Preferences/AndroidStudioPreview/idea.vmoptions in your text editor of choice.
  6. Tweak them settings.

If you wanted, for instance, to change the value for ${USER}, which is used in the Java file header, you can add the following:

    -Duser.name=Elisabeth Braddock

(Of course, inserting the user name of your choice.)

Curious as to why we copy idea.vmoptions to the Prefences folder rather than just editing the original options file (as works with Eclipse)? Serge warns that changing the file violates the application signature. On the perk-y side of things, utilizing a copy means your tweaks will persist through application updates.

Note: The folder name "AndroidStudioPreview" will more than likely change whenever Android Studio does a proper release. So do not forget to verify the preferences directory, all you future Android devs.