Author Archive

Android Code Styles in IntelliJ IDEA 12

Monday, December 17th, 2012

If you are developing for Android, you probably deal with XML files every day. These are the manifests, layouts, drawables, resource files and many others. That’s why in IntelliJ IDEA 12 we have added a new option for the code formatter, which is aware of Android-specific code styles.

The new option is available in Settings → Code Style → XML and can be enabled via Set From… → Predefined Style → Android.

(more…)

New XML Refactorings for Android Developers

Wednesday, September 5th, 2012

Recently, we’ve added a number of new refactorings for Android XML layout files. All the refactorings can be used right in the editor, in the UI designer (from “Design” panel or “Component Tree”) or can be invoked from the Structure View.

So, here’s what we’ve prepared for you:

  • Extract Style. Styles in Android is an analogue of cascading stylesheets in web design — they allow you to separate the design from the content. With this new refactoring you can create a new style from a layout XML tag. To perform refactoring just place the caret into an XML tag and choose Refactor | Extract | Style… from a popup menu in XML editor or Refactor | Extract Style… in the UI designer.   Moreover, it is possible to extract parent style from an existing style declaration.

(more…)

Launching Android tools right from IntelliJ IDEA

Tuesday, March 27th, 2012

This is a post from MobileTech conference in Munich, Germany where we enjoy talking to a bunch of mobile developers about IntelliJ IDEA for Android and AppCode for iOS. And we thought like sharing with you one more feature coming in IntelliJ IDEA 11.1.

With the latest IntelliJ IDEA 11.1 EAP you can easily launch Android tools such as DDMS, Hierarchy Viewer and Draw 9 Patch right from the IDE. New actions are available in Tools | Android menu.

For a proper interaction with ADB we highly recommend launching DDMS from the IDE, not from a file manager or command line. If you want to launch it from the outside of the IDE or launch Eclipse+ADT without closing IntelliJ IDEA, please disable ADB service from Tools menu before it.

Please feel free to give us feedback in comments here or submit bug reports in our tracker.

Validation of unknown tags and attributes in Android XML files

Monday, March 12th, 2012

In the latest IntelliJ IDEA 11.1 EAP we’ve added 2 new inspections that warn you about unknown attributes and tags in Android XML resource files and AndroidManifest.xml:

IntelliJ IDEA can validate both system attributes and local ones defined in attrs.xml file in your project. Of course, you can disable or tune these inspections according to your needs in the IDE settings.

Integration with Android Lint tool in IntelliJ IDEA 11.1

Thursday, February 23rd, 2012

In IntelliJ IDEA 11.1 we’ve added many inspections based on Android Lint tool, which reports many kinds of potential problems in the sources of your Android project.

For example IntelliJ IDEA will notify you about useless views in layout xml files and will offer to remove it:

Another example is that IDE warns you about hardcoded text and offer to extract a new string resource:

Some issues (such as duplicated icons or incomplete translations) aren’t shown in the editor, but reported when you run inspections for your project. Simply launch Analyze | Inspect Code from the main menu:

You can see all the Lint based inspections and tune them in Settings | Inspections | Android | Lint.

The feature is available to try it in the latest IntelliJ IDEA 11.1 EAP.

New in IntelliJ IDEA 11: Improved filtering in Android logcat

Wednesday, November 30th, 2011

In IntelliJ IDEA 11 we’ve improved Android logcat view, so now watching the logs of your applications became much more convenient.

First, you can create your own named filters and switch between them:

You can use regular expressions to filter the log, e.g. by a tag or message text. Note that autocompletion of tags already presented in the log is available: 

Another noteworthy improvement is that multiline messages aren’t cut anymore when you filter them by a named filter or using search. For example, if you search for “ActivityThread.java”, you’ll see full stacktrace containing the query, but not just separate lines: 

New in IntelliJ IDEA 11: Preview of Android UI layouts

Thursday, October 13th, 2011

IntelliJ IDEA 11 introduces a new feature that makes it much easier to design UI layouts for Android applications — UI layouts preview. Just open some layout xml file from your Android project and you’ll see a new Preview tool window. 

Preview is updated as you edit the file, so you can see the changes immediately. Many different options such as screen size, target platform version, theme, etc. are available for tuning what you see.

Custom view components are also supported and shown correctly. But since IntelliJ IDEA uses class files from your output directory to render such components, you have to build your project first.

Please note, that layout preview feature is under development, so we really need to know your opinions. You’re welcome to try it in the latest Nika EAP and let us know what you think. If the IDE doesn’t preview some of your layout xml files, please submit bugreports with these files attached.

New in 10.5: Attach debugger to a running Android process

Friday, May 6th, 2011

Recently, we’ve introduced a new feature that should make it MUCH easier to debug your Android applications. Now, you can attach IntelliJ IDEA debugger to any process running on an Android device or in the emulator, which is related to the source code of your project.

Just click “Attach debugger to Android process” toolbar button and you’ll see the list of processes grouped by device they are running on:

Note: to be shown in the list above the name of the process should be specified in AndroidManifest.xml as a “package” or “process” XML attribute.

The feature is, of course, available in the IntelliJ IDEA 10.5 Release Candidate. So, you are welcome to try and let us know what you think.

New in 10.5: Highlighting of HTML tag tree

Wednesday, April 20th, 2011

Recently we’ve added a new code highlighting feature that should make it easier to work with big and complex HTML files, with deep nested tags structure:

Please note that highlighting is only activated when there is more than one tag with the same name in the hierarchy.

By default, only 6 parent tags are highlighted with 6 different colors. You can change the depth to highlight or completely disable the feature in Settings | Editor | Appearance | Enable HTML tag tree highlighting.

Also you can tweak the colors in Settings | Colors & Fonts | HTML.

This feature is very new and we want your opinions. You are welcome to try it in the latest IntelliJ IDEA 10.5 EAP build and let us know what you think.

New concept of Android SDK in IntelliJ IDEA 10.5

Wednesday, March 30th, 2011

The recent EAP of IntelliJ IDEA 10.5 introduces a new presentation of Android platform inside a project.

Previously, you could configure Android SDK inside Android facet settings, while JDK played the role of the main Project/Module SDK. IntelliJ IDEA 10.5 considers Android platform itself as a Project/Module SDK:

Thus, the standard JDK jars aren’t included to the classpath of your Android module. So, the IDE will not complete the java classes which are not supported by the Android platform anymore. Also, the usages of such classes will be correctly highlighted as errors:

Note, that in addition to the Android SDK, you still need a Java SDK because IntelliJ IDEA uses it for compilation. You’ll be prompted for it while creating a new Android SDK.

It is important to mention that once you open an existing Android project in IntelliJ IDEA 10.5 it will be converted automatically, no manual configuration needed.

You are welcome to try it in the latest IntelliJ IDEA 10.5 EAP build and let us know what you think.