Sunday, November 25, 2012

Library projects again

You can see new version of NBAndroid plugin on our auto-update center again. This time there is a fix for classpath resolving to find correctly sources belonging to Android library projects.

I noticed the bug few days ago and probably it was caused by a change in build process that creates a copy of AndroidManifest.xml file in bin directory now. This confused our plugin that expected there is another nested project. Anyway the problem is resolved now.

Together with this change there I integrated a (slightly modified) patch from Steve Roy to give you direct access to either AVD manager or SDK manager.

Tuesday, November 20, 2012

Migrated to SDK tools release 21

There is a new update for NBAndroid plugin that contains updated versions of Android SDK libraries. This is good because there were some small incompatible changes in SDK and those newer libraries will help us to handle them. All the basic stuff seems functional now and layout preview is working in this version as well.

Sunday, November 18, 2012

Where is my R.java?

The most common question related to Android development in NetBeans these days is 'where is my R.java?'

Simple answer: Don't worry, it is not there and it will be created once you build the project.

Why is this so and what is this class for? R.java in your project is a class generated during the build to provide an access to various resources used in your application from Java code. You can find details in in Android developers documentation. For example you will most likely store strings used by your application in res/values/string.xml file. They will be referenced in Java code by identifier defined inside this R class.

Now when the skeleton Android project is created it already contains some of these resources and the Java code for generated activity uses these resource knowing how the generated identifiers look like. Their R class is in the package specified in AndroidManifest.xml file and it is the same package as the main activity uses in this generated code. It means there is no need to modify the source by importing this class. The reason why those as shown as errors is that there was no build to generate R.java (and then compile it to .class and package into .dex and finally create application file .apk) yet. As described above all will be resolved during the build. We may decide to run priming build right after project generation in the future but there are many other more important tasks at the moment.

Note: there is also android.R class. Its purpose is the same as R class defined in your project. It contains references to resources defined in the system. You will use it sometimes to reuse parts of UI to keep the user experience consistent.

Thursday, November 15, 2012

SDK Tools 21

Android team released a new version of their SDK tools - r21. While the main plugin functionality should be mostly compatible I will need some time to update NBAndroid completely. There are various refactorings in the tools area and those need to be reflected.

Tuesday, November 6, 2012

Early version of preview functionality

Just look for Window | Output | Android Layout Preview menu item in the last update. It is raw functionality but hopefully someone will find it useful.