43

I'm starting to learn the android NDK and I've instantly come up against a problem.

I'e built the tool chain (which took a LOT longer than I was expecting!!) and I've compiled the C++ code with no problems and now I'm trying to build the java code.

Instantly I come up against a problem. There is a file "main.xml"

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
<TextView  
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Hello World, DemoActivity"
    />
</LinearLayout>

and I get the following errors:

Description Resource Path Location Type
error: Error: String types not allowed (at 'layout_height' with value 'match_parent'). main.xml /DemoActivity/res/layout line 2 Android AAPT Problem
error: Error: String types not allowed (at 'layout_height' with value 'match_parent'). main.xml /DemoActivity/res/layout line 2 Android AAPT Problem
error: Error: String types not allowed (at 'layout_width' with value 'match_parent'). main.xml /DemoActivity/res/layout line 2 Android AAPT Problem
error: Error: String types not allowed (at 'layout_width' with value 'match_parent'). main.xml /DemoActivity/res/layout line 7 Android AAPT Problem
error: Error: String types not allowed (at 'layout_width' with value 'match_parent'). main.xml /DemoActivity/res/layout line 7 Android AAPT Problem

So I can see the problem lies in the fact that these "match_parent" strings are in there. Anyone know how to fix this?

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
Goz
  • 61,365
  • 24
  • 124
  • 204
  • 1
    Removed the NDK tags. The question as it stands now has nothing to do with NDK or native development. Please consider changing the title accordingly! – Alex Cohn Sep 20 '12 at 07:20

1 Answers1

101

Check what API Level you are using.

FILL_PARENT was renamed to MATCH_PARENT in API Level 8 (Android 2.2).

dbyrne
  • 59,111
  • 13
  • 86
  • 103
  • yeah I've just discovered that changing it to fill_parent solved the issue. Strangely it is on api level 4 (which is what eclipse auto set it up as ... I assumed thats what the files were talling it .. may be wrong though!). Cheers for the help! :) – Goz Jun 08 '10 at 18:45
  • 2
    I'm going through the introductory Notepadv2 exercise on the official Android Developers website; it would have been nice if they'd have mentioned that fact. But good to know, thanks! – Brian Lacy Sep 16 '11 at 20:45
  • when creating a new project in eclipse, and choosing `Android Sample Project` in the wizard, and then on to a `Google APIs` target of API 10 or older, the `Sample4Demos` that is created ends up containing a bunch of xml that refers to match_parent instead of fill_parent (amongst other problems). – john.k.doe May 03 '12 at 07:19