Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Android 2 Application Development
This is the forum to discuss the Wrox book Professional Android 2 Application Development, 2nd Edition by Reto Meier; ISBN: 978-0-470-56552-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 2 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 23rd, 2010, 09:54 PM
Registered User
 
Join Date: Jan 2008
Location: West Chester, PA
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Android requires .class compatibility set to 5.0.

I'm getting the following errors when I open every chapter's project within Eclipse Galileo ...

1) Android requires .class compatibility set to 5.0. Please fix project properties.
2) Project 'Chapter ## Project' is missing required source folder: 'gen'
3) The project cannot be built until build path errors are resolved

... can anyone enlighten me on why these errors are occurring as well as provide me with a possible solution?

Never worked with Android, never worked with Eclipse ... I apologize in advance if the solution is blatantly obvious.

Thanks!

Last edited by bryan_cook; June 23rd, 2010 at 10:00 PM.. Reason: Clarity
  #2 (permalink)  
Old June 25th, 2010, 09:02 PM
Registered User
 
Join Date: Jan 2008
Location: West Chester, PA
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I took the following steps and got one example working ..

Within Eclipse, I right-clicked the project (in the Package Explorer) and navigated to Properties ...

With Java Build Path selected on the left, I navigated to the Order and Export tab. Within the list, I made sure that 'Google APIs [Android 2.1-update1] was checked.

Jumping back to the Package Explorer, I dug into my project and double-clicked on AndroidManifest.xml. Within the Application tab, I checked the 'Define an <application> tag in the AndroidManifest.xml' checkbox. Within the AndroidManifest.xml tab, I changed the android:minSdkVersion attribute from 7 to 5.

At this point, I saved my project. I'm assuming I had 'Build automatically' checked (within the Project menu) and the project built, because once I saved the gen folder appeared.

With all the above finished, my errors went away but I had a warning remaining .. something along the lines of having the wrong API level. I changed the android:minSdkVersion attribute back to its original value of 7, saved and built and all was well; I ran the project in the emulator without a problem.

I'm willing to bet all the steps I accomplished above weren't necessary, but it gave me the end result I was after .. hope this helps others who encounter the same problem!
  #3 (permalink)  
Old June 25th, 2010, 09:15 PM
Registered User
 
Join Date: Jan 2008
Location: West Chester, PA
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Walked through it again with another project ... started with the same errors as before ... disabled 'Build Automatically' for a bit more control over the steps ...

I changed the android:minSdkVersion value from 7 to 5, saved and built .. the .class compatibility error disappeared and the following warning appeared ..

Attribute minSdkVersion (5) is lower than the project target API level (7)

.. additionally, when I built the /gen folder appeared. I changed the android:minSdkVersion value back to 7, saved and built ... no more errors.

It appears as though the extra steps I took before weren't necessary .. however, I did leave a step out ..

Before running, I went to Run > Run Configurations. With 'Android Application' selected in the left pane, I clicked the 'New' button. Within the new entry that appeared, I began in the 'Android' tab .. for Project, I browsed to my project. I left all other values at their defaults and clicked the Run button. Since I already had a virtual device prepared, it jumped right into the emulator.
  #4 (permalink)  
Old July 10th, 2010, 11:10 AM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Generally speaking you should correlate the minimum API level written in the manifest to your target AVD API level.

Within Eclipse, have a look in Project->Properties->Android for the list of targets and their related API versions.

So for the AndroidManifest.xml file the line
<uses-sdk android:minSdkVersion="7" />
means you its best to use "Android 2.1 - update1" as the target library for the emulator (or you actual Android device).

The book is confusing since it sets the AVD to be an earlier version. However, the anomaly helps you understand more about AVD versions and the manifest so its not necessarily an issue.

Last edited by Efraser65; July 10th, 2010 at 11:15 AM..


Similar Threads
Thread Thread Starter Forum Replies Last Post
Article: Using the Android Camera jminatel BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 December 4th, 2013 06:17 AM
i am new to android janardhan BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 July 29th, 2010 03:37 PM
Horizontal Scrolling in Android code_lover BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 October 9th, 2009 03:51 AM
Class to set student name & id curiaquita Visual C++ 2 February 3rd, 2009 01:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.