Archive for February, 2012

When programming Android apps, the accepted way to implement your program’s resources is defining them via an external XML file, thus ensuring your presentation layer is divorced from your application layer. What this essentially means is that instead of creating things like user interfaces and strings in code, you create an XML file to hold this information under the ‘res’ project directory.
The Eclipse ADT plugin handles actually holding references to all these resources via the R class, which is re-generated whenever a new resource is defined or the project is rebuild and is held under the ‘gen’ project directory. However, this doesn’t always work as expected. For example, say I had defined a simple Activity layout called “maingui” and tried to reference this in my Activity start up code like so: -

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Inflate your view.
    setContentView(R.layout.maingui);
}

However, when you try and run your Android app, you get Eclipse displaying the following error: -


'R cannot be resolved or is not a field'

The first thing you might notice is that the R.java file under your Eclipse project is missing. This will naturally bring up the error because R cannot be found. The first thing to try is to clean the project so that the Eclipse ADT will automatically attempt to rebuild the R.java file. Under Eclipse, go to: -


Project -> Clean

and then click on


Project -> Build Project

If this doesn’t work, the next thing to check is the top of your Activity or whatever class is referencing the R resources. Check for the following line: -

import android.R;

This is a “helpful” line added by the Eclipse ADT to your project which is supposed to import your R resource into your project for easy referencing. However, this isn’t the R file including in your project package. For example, say my Activity classes or whatever are included in the “com.thenode.mobile” package and you’re trying to reference the above “maingui” View layout (R.layout.maingui), you’re actually trying to reference: -

android.R.layout.maingui

rather than the correct:-

com.thenode.mobile.R.layout.maingui

Remove the “import android.R;” line and replace with:-

import com.thenode.mobile.R;

…i.e, your package namespace and your R file should be regenerated on the next build of your project. If it still doesn’t work, you definitely, absolutely have an error in one of your external resource XML files – in this case, my maingui.xml file. Check your external XML files closely.
The reason I think this happens is that whatever process auto-generates R.java file starts at the top of your resources and works it’s way down to the bottom. If it encounters an error somewhere along the way, it just stops – leaving whatever resources haven’t been added to R.java out but neglecting to tell you why R cannot be resolved. I think this is why some of them will say “unresolved”, and others will be fine. Anyway, that’s basically the three things you should search for when getting this error. Took me ages to figure this one out in all circumstances.

Well, 2012 hasn’t gone well for me so far tech-wise. My WiFi Kindle died a death, as did my ancient Ubuntu laptop. My venerable Xbox 360 Pro (yes, the fat one) finally died a death after six years and surviving a RRoD repair at Microsoft. So had to get one of the new shiny black Slim 250GB models to replace it. So now I have to transfer all my save data, games and DLC to the new Slim. Annoyingly, the old-style Xbox hard drives are not compatible with the new Slim models so the data will have to be transferred. This is from an old 250GB Xbox to a new 250GB Slim model.
Luckily, I still had my Transfer Cable from the 250GB hard drive upgrade from about a year back and this is by far the easiest way to transfer your stuff. Bear in mind that this is transferring data into a perfectly new Xbox 360 Slim which has never been used. If you have used it, any data on the Slim’s drive will be wiped and replaced with the transferred data.

Transfer data using the Transfer Cable

First make sure both consoles are switched off – not a problem for my 360 Pro model, because it’s wrecked :D So, first you need to remove the old hard drive from the 360 Pro and plug it onto the Transfer Cable. Plug the USB end of the cable into one of the USB sockets on the back of the Xbox Slim and boot it up.
You should see a dialog pop up which says “Transfer Cable Detected”. Select “Yes, transfer to the Console” and then either choose what you want to transfer or simply select “Start” to transfer everything. Depending on the amount of data, this might take an hour or so.

Transfer DRM content licenses

Once this is done, unplug the old hard drive and transfer cable. You can sell or throw away the old hard drive as it is now blank – no copy of the original data is held on it after the transfer. Fire up the new Slim and sign in with your imported GamerTag. This is important, because you’ll need to transfer the DRM licenses from the old console profile to the new one, else your purchased content won’t work without you being signed into LIVE with the GamerTag used to originally purchase the content. By transferring the licenses to the new machine, you don’t have to be signed in at all to play it. Also, this process can only be done once every four months.

The DRM licenses actually consist of two parts. One is the system license which is linked to the GamerTag profile used to purchase it and the other is the local license which relates to the actual console hardware used to purchase the content. After signing into Xbox LIVE after transferring your data, you’ve already satisfied the first part, but you need to transfer the second part so that your new Slim model has the updated local licenses.

So, on the new Slim, sign into Xbox LIVE using your regular GamerTag (or the one used to purchase the content) and go to “Settings” and then “Account”. Select “Your Billing Options” and then “License Transfer”. Follow the on-screen prompts to transfer the license to local. To complete the update, you’ll need to download the content again to link the system and local licenses to your new console.

That should be it – bear in mind that the only thing not transferred by the Transfer procedure are game patches. When firing up a game on the new console, make sure that you’re connected to Xbox LIVE so that you can re-download any patches for your games. No, I have no idea why these are excluded from the transfer process.

Update 16/02/2012: You will also find that if you try to add items to your download queue via the web marketplace on xbox.com, you’ll get a “assigned to another console” message when you check your Active Downloads. This was very annoying for me, as I wanted to play the Mass Effect 3 Demo. Basically, this is because Microsoft assigns the first console you use to download items from the Marketplace as your “primary console” and all pending downloads from the web marketplace will be assigned to this console only.
To switch your new primary console to your new Slim model, simply navigate to the Active Downloads screen and on the item you see the “assigned to another console” message on, press A and select “Download All Items”. This essentially switches your primary console to the one with which you are currently logged into Xbox LIVE. Job done!

Search The Node
XBox LIVE Gamertag
The Node Downloads
Mini Tweets

Switch to our mobile site