Wrox Programmer Forums
|
BOOK: Beginning Android 4 Application Development
This is the forum to discuss the Wrox book Beginning Android 4 Application Development by Wei-Meng Lee; ISBN: 978-1-1181-9954-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android 4 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
 
Old January 27th, 2013, 02:57 PM
Registered User
 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't get it to work

I am in Chapter 1 of "Beginning Android 4". Note I have installed version 4.2.

For the "Hello World" application, the book asks for the following code:

<?xml version = "1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first Android Application!" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="And this is a clickable button" />

</LinearLayout>

I am getting an error message on android:text = "@string/hello"

The error is : No resource found that matches the given name (at 'text' with value '@string/hello'). activity_main.xml /helloworld/res/layout line 7 Android AAPT Problem

What am I doing wrong?
 
Old March 6th, 2013, 09:56 AM
Registered User
 
Join Date: Mar 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you haven't defined the string.

Look in res/values/strings.xml

I know this is an old post but the answer might help someone else.
 
Old March 6th, 2013, 10:58 AM
Registered User
 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you so much for your reply. I gave up on the Android Book because I could not get past this issue. Now that I have your reply, I will try again.

Thank you so much for your reply.
 
Old March 6th, 2013, 01:55 PM
Registered User
 
Join Date: Mar 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've just tried the code from the book and it threw up a few errors.

Someone else has stated the book is a bit out of date in another topic.

Try the intro I found here, explains the use of strings, I'm very much a beginner like yourself - so I can't be much use.

Phil
 
Old March 12th, 2013, 03:49 PM
Authorized User
 
Join Date: Dec 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just bought the book a few days ago. Have spent hours trying to get the very first example to work. There seems to be a disconnect between the book and version 4.2.2, which is the latest that I am running.

Very frustrated!
George Race
 
Old March 12th, 2013, 04:01 PM
Registered User
 
Join Date: Mar 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm slowly working through this.

developer[dot]android[dot]com/training/basics/firstapp/
 
Old March 12th, 2013, 07:26 PM
Registered User
 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default My First App

Thanks very much. I have added this to my Bookmarks and will use it once I finish my book "Java in 21 Days" (It has a few errors too)
 
Old March 20th, 2013, 05:12 PM
Authorized User
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 2 Times in 2 Posts
Default

See this thread:

http://p2p.wrox.com/book-beginning-a...e-adt-etc.html

It should get you moving.
 
Old May 21st, 2013, 09:10 AM
Registered User
 
Join Date: Feb 2012
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

To get back on the original problem:

It seems that the current versions of Eclipse force you to use resource-strings instead of hardcoding text(strings).
My message sounds like this: 'Hardcoded string "hello", should use @string
resource'

It tells you right here: do not use hardcoded strings, use '@string' to point to the related resource-string.

So change your line of code:
Code:
android:text="hello"
to
Code:
android:text="@string/hello"
now you get another message: 'Error: No resource found that matches the given name (at 'text' with value '@string/test').'

The message sais it can not find the related resource-string. So you need to add it:
- open the 'strings.xml' file located in the 'res/values' folder.
- click on the strings.xml-tab (by default the Resources-tab is selected)
- add a new line:
Code:
<string name="hello">hello to you</string>
save your file and retry to run the app.





Similar Threads
Thread Thread Starter Forum Replies Last Post
SMS API does not work online but work fine offline. Tonik Beginning PHP 1 January 4th, 2013 08:30 AM
Chapter 1 Ctrl+F5 don't work, F5 does work? jimboak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 June 29th, 2008 03:46 AM
Able to Get it work !! rsrika C# 2005 0 March 8th, 2006 09:16 AM





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