Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 27th, 2013, 02:57 PM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
Reply With Quote
  #2 (permalink)  
Old March 6th, 2013, 09:56 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #3 (permalink)  
Old March 6th, 2013, 10:58 AM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #4 (permalink)  
Old March 6th, 2013, 01:55 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #5 (permalink)  
Old March 12th, 2013, 03:49 PM
Authorized User
Points: 111, Level: 2
Points: 111, Level: 2 Points: 111, Level: 2 Points: 111, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
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
Reply With Quote
  #6 (permalink)  
Old March 12th, 2013, 04:01 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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/
Reply With Quote
  #7 (permalink)  
Old March 12th, 2013, 07:26 PM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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)
Reply With Quote
  #8 (permalink)  
Old March 20th, 2013, 05:12 PM
Authorized User
Points: 189, Level: 3
Points: 189, Level: 3 Points: 189, Level: 3 Points: 189, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #9 (permalink)  
Old May 21st, 2013, 09:10 AM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:59 PM.


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