views:

2331

answers:

5

Hi All,

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?

+14  A: 

Check what API Level you are using.

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

dbyrne
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
A: 

Thanks! This solved my issue!

chris
A: 

Yes,

My problem too!

Thanks

Dean
A: 

Worked for me as well -- while working through the Notepadv2 tutorial.

I don't know if it's related but the next problem I had was: "Conversion to Dalvik format failed with error 1". The key to this one was: deleting the android.jar file in the build path per http://www.mentby.com/vant/conversion-to-dalvik-format-failed-with-error-1.html

This mixed with random project cleans, rebuilds, and refreshes, has me back on track ;)

mjhm
A: 

Does this cause any headaches for making an app that will work on all API levels? I don't like the idea of keeping two copies of all of my layout xml files just to account for this one keyword change.

Sam Svenbjorgchristiensensen
This would have been better as a comment. But no you don't need to keep 2 XMLs. You can target all previous API levels by targetting the highest, AFAIK.
Goz
Cheers.Yeah...I'm a bit of a noob here. If it's not too stupid a quesiton, I can't seem to find the 'comment' button anywhere except under your comment that I should have done so. Seriously, i've spend 10 minutes looking.
Sam Svenbjorgchristiensensen