Hi
We have worked this weekend too...
Tried to explain layout reuse (like UserControls) and got following
exception:
MonoDroid.Utils.CommandFailedException:
Operation is not valid due to the current state of the object
by mandroid.exe
Googled and led us to original post (by us/me) about resources and
filename casing in
monodroid samples.
1. Selector for pngs
There is selector in xml file to select png to display. Probably
java code is generated
based on this xml.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/androidpressed"
android:state_pressed="true" />
<item android:drawable="@drawable/android_focused"
android:state_focused="true" />
<item android:drawable="@drawable/android_normal" />
</selector>
To solve exception AndroidPressed was changed to androidpressed
2. xml layout (wrapped in <merge> tag) for reuse.
Idea was for hardcore .netters to explain "Simulation" of UserControls
main layout <let say Form>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/MyButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Hello"
/>
<RelativeLayout android:id="@+id/RelativeLayout03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<include layout="@layout/usercontroladvertizer" />
</RelativeLayout>
</LinearLayout>
And UserControlAdvertizer looked like
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/UserControlAdvertizer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/textViewAdvertisement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"
/>
</LinearLayout>
</merge>
We colud not get rid off exception until filenames in parent
control/layout
for child layouts/controls were not lowercase
It seems that this exception can be avoided if in parent/master layout
ids that are mapped
to filenames should be lowercase, cos this is probably where
java/native-stuff steps in and
it is mostly done in lowercase...
greetings
mel
On 2011.09.21 10:53, Miljenko Cvjetko wrote:
HI
I know this Asset naming problem is known, just it would be nice to
correct
samples on github for those which are not familiar with this issue and
for those
to come.
For a purpose of one presentationfor several students, just pulled src
from github
yesterday and got error.
Problem:
1. Select device started, message "Packaging Application"
2. new window "Packaging failed"
Could not create the Android package. See the Output (Build)
window for more details.
3. Output/Build:
C:\Program Files\MSBuild\Novell\mandroid.exe -v --nosign
--sdk-dir="C:\Program Files\Android\android-sdk-windows"
--builddir="D:\SRC\MonoDroid\monodroid-samples\ApiDemo\obj\Debug\android"
--framework-dir="C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v2.2"
--framework-dir="C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0"
-S="D:\SRC\MonoDroid\monodroid-samples\ApiDemo\obj\Debug\res"
--package="mono.samples.apidemo" --nolink --abi="armeabi"
--java-sdk-dir="C:\Program Files\Java\jdk1.6.0_26" --debug
--manifest-template="D:\SRC\MonoDroid\monodroid-samples\ApiDemo\Properties\AndroidManifest.xml"
--sdk-platform="8"
-A="D:\SRC\MonoDroid\monodroid-samples\ApiDemo\obj\Debug\assets"
"D:\SRC\MonoDroid\monodroid-samples\ApiDemo\bin\Debug\MonoDroid.ApiDemo.dll"
"C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll"
"C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll"
"C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll"
"C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll"
"C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll"
"C:\Program Files\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll"
MonoDroid.Utils.CommandFailedException: Operation is not valid
due to the current state of the object
at
MonoDroid.Utils.ProcessRocks+<ReadStandardOutput>c__Iterator6.MoveNext
() [0x00000] in <filename unknown>:0
at Monodroid.Toolbox.InvokeCommand (IEnumerable`1 commandLine)
[0x00000] in <filename unknown>:0
at Monodroid.Toolbox.InvokeAapt (System.String packageName)
[0x00000] in <filename unknown>:0
at Monodroid.Droidinator.CreatePackagedResources
(System.Collections.Generic.List`1 javaTypes) [0x00000] in
<filename unknown>:0
at Monodroid.Droidinator.CreateApk () [0x00000] in <filename
unknown>:0
at Monodroid.MainClass.Main (System.String[] argv) [0x00000]
in <filename unknown>:0
D:\SRC\MonoDroid\monodroid-samples\ApiDemo\Resources\drawable\android_button.xml(4):
error 1: No resource found that matches the given name (at
'drawable' with value '@drawable/AndroidPressed').
[D:\SRC\MonoDroid\monodroid-samples\ApiDemo\ApiDemo.csproj]
Done Building Project
"D:\SRC\MonoDroid\monodroid-samples\ApiDemo\ApiDemo.csproj"
(SignAndroidPackage target(s)) -- FAILED.
Build FAILED.
Solution:
1. in
D:\SRC\MonoDroid\monodroid-samples\ApiDemo\Resources\drawable\android_button.xml
changed:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/AndroidPressed"
android:state_pressed="true" />
<item android:drawable="@drawable/android_focused"
android:state_focused="true" />
<item android:drawable="@drawable/android_normal" />
</selector>
to:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/androidpressed"
android:state_pressed="true" />
<item android:drawable="@drawable/android_focused"
android:state_focused="true" />
<item android:drawable="@drawable/android_normal" />
</selector>
2. renamed/moved:
D:\SRC\MonoDroid\monodroid-samples\ApiDemo\Resources\drawable\AndroidPressed.png
to
D:\SRC\MonoDroid\monodroid-samples\ApiDemo\Resources\drawable\androidpressed.png
regards
mel
--
--
Miljenko Cvjetko dipl.ing. ET
Direktor/CEO
Projektant rjes(enja/Solution Architect
Razvojni programer/Senior developer
Voditelj projekta/Project Manager
IX juz(na obala 13
Kajzerica Zagreb
T: 385 1 7775555
M: 385 91 557 447 3
F: 385 1 7779556
e: [email protected]
w: http://www.holisticware.net
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid