programatically add elements to a scrollview gives me Java.Lang.IllegalStateException - android

I'm trying to add textview and progressbar's to a scrollview but it gives me a Java.Lang.IllegalStateException:
I'm using xamarin so this is not java but c# but it's the same principe
here's the code (summarized) :
SetContentView(Resource.Layout.Usage);
ScrollView scrollView = FindViewById<ScrollView>(Resource.Id.scrollView1);
LinearLayout linearLayout = FindViewById<LinearLayout>(Resource.Id.linearLayout2);
while (...){
TextView textView = new TextView(this);
textView.Text = "Some text";
textView.SetTextSize(Android.Util.ComplexUnitType.Sp, 18.0f);
linearLayout.AddView(textView);
ProgressBar progressBar = new ProgressBar(this, null, Android.Resource.Attribute.ProgressBarStyleHorizontal);
progressBar.Progress = 25;
linearLayout.AddView(progressBar);
}
scrollView.AddView(linearLayout);
Stack :
04-15 08:49:00.603 I/MonoDroid( 1389): UNHANDLED EXCEPTION: Java.Lang.IllegalStateException: Exception of type 'Java.Lang.IllegalStateException' was thrown.
04-15 08:49:00.603 I/MonoDroid( 1389): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00023] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:368
04-15 08:49:00.603 I/MonoDroid( 1389): at Android.Views.ViewGroup.AddView (Android.Views.View) [0x0003e] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Views.ViewGroup.cs:1186
04-15 08:49:00.603 I/MonoDroid( 1389): at MyOrangeDroid.Usage.OnCreate (Android.OS.Bundle) [0x001be] in c:\Users\clement\Documents\Visual Studio 2012\Projects\MyOrangeAndroid\MyOrangeDroid\Usage.cs:70
04-15 08:49:00.603 I/MonoDroid( 1389): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.App.Activity.cs:1490
04-15 08:49:00.603 I/MonoDroid( 1389): at (wrapper dynamic-method) object.6c050c56-6d80-48bc-9425-e832938cdfa7 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
04-15 08:49:00.603 I/MonoDroid( 1389):
04-15 08:49:00.603 I/MonoDroid( 1389): --- End of managed exception stack trace ---
04-15 08:49:00.603 I/MonoDroid( 1389): java.lang.IllegalStateException: ScrollView can host only one direct child
04-15 08:49:00.603 I/MonoDroid( 1389): at android.widget.ScrollView.addView(ScrollView.java:211)
04-15 08:49:00.603 I/MonoDroid( 1389): at myorangedroid.Usage.n_onCreate(Native Method)
04-15 08:49:00.603 I/MonoDroid( 1389): at myorangedroid.Usage.onCreate(Usage.java:28)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.os.Looper.loop(Looper.java:123)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-15 08:49:00.603 I/MonoDroid( 1389): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 08:49:00.603 I/MonoDroid( 1389): at java.lang.reflect.Method.invoke(Method.java:507)
04-15 08:49:00.603 I/MonoDroid( 1389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-15 08:49:00.603 I/MonoDroid( 1389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-15 08:49:00.603 I/MonoDroid( 1389): at dalvik.system.NativeStart.main(Native Method)
In mgmain JNI_OnLoad
04-15 08:49:01.503 W/dalvikvm( 1389): JNI WARNING: JNI method called with exception raised
04-15 08:49:01.503 W/dalvikvm( 1389): in Lmyorangedroid/Usage;.n_onCreate (Landroid/os/Bundle;)V (CallObjectMethod)
04-15 08:49:01.503 W/dalvikvm( 1389): Pending exception is:
04-15 08:49:01.503 I/dalvikvm( 1389): Ljava/lang/IllegalStateException;: ScrollView can host only one direct child
04-15 08:49:01.513 I/dalvikvm( 1389): (no stack trace data found)
04-15 08:49:01.513 I/dalvikvm( 1389): "main" prio=5 tid=1 NATIVE
04-15 08:49:01.513 I/dalvikvm( 1389): | group="main" sCount=0 dsCount=0 obj=0x4001f1a8 self=0xce48
04-15 08:49:01.513 I/dalvikvm( 1389): | sysTid=1389 nice=0 sched=0/0 cgrp=default handle=-1345006528
04-15 08:49:01.513 I/dalvikvm( 1389): | schedstat=( 7098128094 1495743800 310 )
04-15 08:49:01.513 I/dalvikvm( 1389): at myorangedroid.Usage.n_onCreate(Native Method)
04-15 08:49:01.523 I/dalvikvm( 1389): at myorangedroid.Usage.onCreate(Usage.java:28)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.os.Looper.loop(Looper.java:123)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-15 08:49:01.523 I/dalvikvm( 1389): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 08:49:01.523 I/dalvikvm( 1389): at java.lang.reflect.Method.invoke(Method.java:507)
04-15 08:49:01.523 I/dalvikvm( 1389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-15 08:49:01.523 I/dalvikvm( 1389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-15 08:49:01.523 I/dalvikvm( 1389): at dalvik.system.NativeStart.main(Native Method)
04-15 08:49:01.523 I/dalvikvm( 1389):
04-15 08:49:01.523 E/dalvikvm( 1389): VM aborting
04-15 08:49:01.533 I/mono ( 1389): Stacktrace:
04-15 08:49:01.533 I/mono ( 1389):
04-15 08:49:01.533 I/mono ( 1389): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00000] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:129
04-15 08:49:01.533 I/mono ( 1389): at Java.Lang.Throwable.get_Message () [0x0003e] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Java.Lang.Throwable.cs:195
04-15 08:49:01.533 I/mono ( 1389): at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Unhandled Exception:
Java.Lang.IllegalStateException:
Thanks for the help/read :-)

ScrollView must have only one Direct child
if you are trying to add like below
layout.AddView(textView);
layout.AddView(progressBar);
it will throw the Exception saying ScrollView must have only one direct child
Solution:
Take LinearLayout and add textView and progressbar to it and then add LinearLayout to the ScrollView
And also in your code, method names are given in Capital Letters, Remember java is Case Sensitive. I think you are just giving the above code for the overview.

Any chance you have anything inside your scrollview on your xml? If there is nothing there, try to remove all views before adding a new one. This is java but you must have an equivalent in c#.
scrollView.removeAllViews();
If you have nothing like that, remove the very first view, there will be only one anyway.
scrollView.removeView(0);
Remove all views

Related

Androidx libraries for Xamarin.Android in Visual Studio NuGet

Are the androidx libraries available in Visual Studio's NuGet package manager?
My app is targeting Android P so I can use the androidx libraries in Android Studio but I can't find them in NuGet.
With Android Studio I can use:
<androidx.constraintlayout.widget.ConstraintLayout
but throws exception in Visual Studio:
02-09 21:31:59.970 I/MonoDroid( 8843): UNHANDLED EXCEPTION:
02-09 21:32:00.137 I/MonoDroid( 8843): Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class androidx.constraintlayout.widget.ConstraintLayout ---> Android.Views.InflateException: Binary XML file line #1: Error inflating class androidx.constraintlayout.widget.ConstraintLayout ---> Java.Lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.ConstraintLayout" on path: DexPathList[[zip file "/data/app/Keystore.Keystore-aaHeQkjsNRoUnkfPmnf7Tw==/base.apk"],nativeLibraryDirectories=[/data/app/Keystore.Keystore-aaHeQkjsNRoUnkfPmnf7Tw==/lib/x86, /data/app/Keystore.Keystore-aaHeQkjsNRoUnkfPmnf7Tw==/base.apk!/lib/x86, /system/lib]]
02-09 21:32:00.137 I/MonoDroid( 8843): --- End of inner exception stack trace ---
02-09 21:32:00.137 I/MonoDroid( 8843): --- End of inner exception stack trace ---
02-09 21:32:00.137 I/MonoDroid( 8843): at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <8acc8089c2ed40d08469fbaa6710a44c>:0
02-09 21:32:00.137 I/MonoDroid( 8843): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <8acc8089c2ed40d08469fbaa6710a44c>:0
02-09 21:32:00.137 I/MonoDroid( 8843): at Android.App.Activity.SetContentView (System.Int32 layoutResID) [0x00022] in <957bbfdfda4341e2939c881206c1140a>:0
02-09 21:32:00.137 I/MonoDroid( 8843): at Keystore.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00009] in H:\My Projects\Android\Samples\Keystore\MainActivity.cs:19
02-09 21:32:00.137 I/MonoDroid( 8843): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <957bbfdfda4341e2939c881206c1140a>:0
02-09 21:32:00.138 I/MonoDroid( 8843): at (wrapper dynamic-method) System.Object.3(intptr,intptr,intptr)
02-09 21:32:00.138 I/MonoDroid( 8843): --- End of managed Android.Views.InflateException stack trace ---
02-09 21:32:00.138 I/MonoDroid( 8843): android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
02-09 21:32:00.138 I/MonoDroid( 8843): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
02-09 21:32:00.138 I/MonoDroid( 8843): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.ConstraintLayout" on path: DexPathList[[zip file "/data/app/Keystore.Keystore-aaHeQkjsNRoUnkfPmnf7Tw==/base.apk"],nativeLibraryDirectories=[/data/app/Keystore.Keystore-aaHeQkjsNRoUnkfPmnf7Tw==/lib/x86, /data/app/Keystore.Keystore-aaHeQkjsNRoUnkfPmnf7Tw==/base.apk!/lib/x86, /system/lib]]
02-09 21:32:00.138 I/MonoDroid( 8843): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
02-09 21:32:00.138 I/MonoDroid( 8843): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
02-09 21:32:00.138 I/MonoDroid( 8843): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
02-09 21:32:00.138 I/MonoDroid( 8843): at md561c0eefc2ba1e38323457d81b00d3caf.MainActivity.n_onCreate(Native Method)
02-09 21:32:00.138 I/MonoDroid( 8843): at md561c0eefc2ba1e38323457d81b00d3caf.MainActivity.onCreate(MainActivity.java:31)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.app.Activity.performCreate(Activity.java:7136)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.app.Activity.performCreate(Activity.java:7127)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
02-09 21:32:00.138 I/MonoDroid( 8843): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
02-09 21:32:00.139 I/MonoDroid( 8843): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
02-09 21:32:00.139 I/MonoDroid( 8843): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
02-09 21:32:00.139 I/MonoDroid( 8843): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
02-09 21:32:00.139 I/MonoDroid( 8843): at android.os.Handler.dispatchMessage(Handler.java:106)
02-09 21:32:00.139 I/MonoDroid( 8843): at android.os.Looper.loop(Looper.java:193)
02-09 21:32:00.139 I/MonoDroid( 8843): at android.app.ActivityThread.main(ActivityThread.java:6669)
02-09 21:32:00.139 I/MonoDroid( 8843): at java.lang.reflect.Method.invoke(Native Method)
02-09 21:32:00.139 I/MonoDroid( 8843): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
02-09 21:32:00.139 I/MonoDroid( 8843): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
So is there a way to use the androidx libraries with Xamarin.Android?
The reason you cannot find it is because you must not have its NuGet
We need to add Xamarin.Android.Support.Constraint.Layout package to support ConstraintLayout in our Xamarin.Android project. So to add this package right click on
Packages > Add Packages. //MAC
References -> Manage NuGet Packages //Windows
Search for ConstraintLayout and add a package by accepting a licence.
And use the following namespace <android.support.constraint.ConstraintLayout> in XML
Update
In my knowledge <androidx.constraintlayout.widget.ConstraintLayout is unavailable in Mono.Droid and hence you might have to bind it to an AAR and then use that AAR to make a Xamarin Binding fix the issues that happen while making that binding and then use it into your Droid project as a .dll
So, it is finally available https://devblogs.microsoft.com/xamarin/androidx-for-xamarin/
The NuGet list is here.

In PagerSlidingTabStrip for xamarin InflateException

I'm using PagerSlidingTabStrip-for-Xamarin.Android
Material Pager Sliding Tab Strip for Xamarin.Android lib
I import PagerSlidingTabStrip lib to my solution (using vs2013) and added to the xml com.refractored.PagerSlidingTabStrip
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<com.refractored.PagerSlidingTabStrip
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:pstsPaddingMiddle="true"
app:pstsDividerWidth="1dp"
app:pstsDividerPadding="12dp"
app:pstsDividerColor="#50FFFFFF" />
<!--Change this to true if you want to center items-->
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:context=".MainActivity" />
</LinearLayout>
But InflateException in SetContentView "com.refractored.PagerSlidingTabStrip"
05-15 14:26:59.848 D/Mono (27464): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
05-15 14:26:59.848 D/Mono (27464): Searching for '__android_log_print'.
05-15 14:26:59.848 D/Mono (27464): Probing '__android_log_print'.
05-15 14:26:59.848 D/Mono (27464): Found as '__android_log_print'.
05-15 14:26:59.863 I/MonoDroid(27464): UNHANDLED EXCEPTION:
05-15 14:26:59.878 I/MonoDroid(27464): Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
05-15 14:26:59.878 I/MonoDroid(27464): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068>
05-15 14:26:59.878 I/MonoDroid(27464): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896
05-15 14:26:59.878 I/MonoDroid(27464): at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:4763
05-15 14:26:59.878 I/MonoDroid(27464): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2380
05-15 14:26:59.878 I/MonoDroid(27464): at (wrapper dynamic-method) object.fc7251ee-439d-41fd-9acb-83d045358433 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
05-15 14:26:59.878 I/MonoDroid(27464): --- End of managed exception stack trace ---
05-15 14:26:59.878 I/MonoDroid(27464): android.view.InflateException: Binary XML file line #1: Error inflating class com.refractored.PagerSlidingTabStrip
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-15 14:26:59.878 I/MonoDroid(27464): at dalvik.system.Na05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-15 14:26:59.878 I/MonoDroid(27464): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.Activity.setContentView(Activity.java:1924)
05-15 14:26:59.878 I/MonoDroid(27464): at scrollmenu.MainActivity.n_onCreate(Native Method)
05-15 14:26:59.878 I/MonoDroid(27464): at scrollmenu.MainActivity.onCreate(MainActivity.java:28)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.Activity.performCreate(Activity.java:5206)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.access$700(ActivityThread.java:140)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-15 14:26:59.878 I/MonoDroid(27464): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 14:26:59.878 I/MonoDroid(27464): at android.os.Looper.loop(Looper.java:137)
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.main(ActivityThread.java:4946)
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Method.invoke(Method.java:511)
05-15 14:26:59.878 I/MonoDroid(27464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
05-15 14:26:59.878 I/MonoDroid(27464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
05-15 14:26:59.878 I/MonoDroid(27464): at dalvik.system.NativeStart.main(Native Method)
05-15 14:26:59.878 I/MonoDroid(27464): Caused by: java.lang.reflect.InvocationTargetException
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Constructor.constructNative(Native Method)
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-15 14:26:59.878 I/MonoDroid(27464): ... 23 more
05-15 14:26:59.878 I/MonoDroid(27464): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01009c a=-1}
05-15 14:26:59.878 I/MonoDroid(27464): at android.content.res.Resources.loadDrawable(Resources.java:2001)
05-15 14:26:59.878 I/MonoDroid(27464): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.View.<init>(View.java:3444)
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.ViewGroup.<init>(ViewGroup.java:432)
05-15 14:26:59.878 I/MonoDroid(27464): at android.widget.FrameLayout.<init>(FrameLayout.java:101)
05-15 14:26:59.878 I/MonoDroid(27464): at android.widget.HorizontalScrollView.<init>(HorizontalScrollView.java:202)
05-15 14:26:59.878 I/MonoDroid(27464): at android.widget.HorizontalScrollView.<init>(HorizontalScrollView.java:198)
05-15 14:26:59.878 I/MonoDroid(27464): at com.refractored.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:38)
05-15 14:26:59.878 I/MonoDroid(27464): ... 26 more
An unhandled exception occured.
05-15 14:27:01.188 E/mono (27464):
05-15 14:27:01.188 E/mono (27464): Unhandled Exception:
05-15 14:27:01.188 E/mono (27464): Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
05-15 14:27:01.188 E/mono (27464): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068>
05-15 14:27:01.188 E/mono (27464): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896
05-15 14:27:01.188 E/mono (27464): at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:4763
05-15 14:27:01.188 E/mono (27464): at ScrollMenu.MainActivity.OnCreate (Android.OS.Bundle) [0x00009] in d:\j.vso\bbalde\android\ScrollMenu\ScrollMenu\MainActivity.cs:22
05-15 14:27:01.188 E/mono (27464): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2380
05-15 14:27:01.188 E/mono (27464): at (wrapper dynamic-method) object.fc7251ee-439d-41fd-9acb-83d045358433 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
05-15 14:27:01.188 E/mono (27464):
05-15 14:27:01.188 E/mono (27464): --- End of managed exception stack trace ---
05-15 14:27:01.188 E/mono (27464): android.view.InflateException: Binary XML file line #1: Error inflating class com.refractored.PagerSlidingTabStrip
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-15 14:27:01.188 E/mono (27464): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
05-15 14:27:01.188 E/mono (27464): at android.app.Activity.setContentView(Activity.java:1924)
05-15 14:27:01.188 E/mono (27464): at scrollmenu.MainActivity.n_onCreate(Native Method)
05-15 14:27:01.188 E/mono (27464): at scrollmenu.MainActivity.onCreate(MainActivity.java:28)
05-15 14:27:01.188 E/mono (27464): at android.app.Activity.performCreate(Activity.java:5206)
05-15 14:27:01.188 E/mono (27464): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
The activity can call methods on the library
So it did not connect library..?
If you use MvvmCross framework you must register PagerSlidingTabStrip assembly on Setup class:
public class Setup : MvxAndroidSetup
{
protected override IList<Assembly> AndroidViewAssemblies {
get {
var assemlies = base.AndroidViewAssemblies;
assemlies.Add(typeof(ViewPager).Assembly);
assemlies.Add(typeof(PagerSlidingTabStrip).Assembly);
return assemlies;
}
}
}

MvvmCross: MvxListView with Template error

I'm trying to use a template with an MvxListView but I get the following error:
mvx:Warning: 21.13 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:] mvx:Warning: 21.13 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
02-21 13:23:05.146 I/mono-stdout(30059): mvx:Warning: 21.13 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
An unhandled exception occured.
The ListView works fine without a template, showing the ToString for each list item.
I followed the link in the error and was worried about the Android 4.4 references as I'm running on a Nexus 4 with 4.4 so I downloaded and ran the KittenView source but that worked fine.
Here is the view
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
style="#style/Layout">
<include
android:id="#+id/header"
layout="#layout/PageHeader" />
<include
android:id="#+id/footer"
layout="#layout/CancelFooter" />
<LinearLayout
style="#style/Layout"
android:layout_below="#id/header"
android:layout_above="#id/footer">
<TextView
style="#style/Text.Title"
android:text="Add New Job" />
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemsSource JobTypes"
local:MvxItemTemplate="#layout/jobtype_item"
/>
</LinearLayout>
</RelativeLayout>
and the template
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="Text Description" />
</LinearLayout>
Any Ideas?
UPDATE
Looks like the inflate error was a red herring - I get that error as well when there is no template and no crash. Seems to be something to do with a missing layout_width.
Here is the full crash exception:
02-21 14:22:48.990 I/MonoDroid( 6664): UNHANDLED EXCEPTION: Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
02-21 14:22:48.990 I/MonoDroid( 6664): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:194
02-21 14:22:48.990 I/MonoDroid( 6664): at Android.Views.LayoutInflater.Inflate (int,Android.Views.ViewGroup,bool) [0x00043] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.Views.LayoutInflater.cs:609
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.CommonInflate (int,Android.Views.ViewGroup,Cirrious.MvvmCross.Binding.Droid.Binders.IMvxLayoutInfactorFactory,bool) <IL 0x00046, 0x00287>
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (int,Android.Views.ViewGroup,bool) <IL 0x00015, 0x00107>
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (int,Android.Views.ViewGroup) <IL 0x00004, 0x00063>
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.Views.MvxListItemView..ctor (Android.Content.Context,Cirrious.MvvmCross.Binding.Droid.Views.IMvxLayoutInflater,object,int) <IL 0x0001a, 0x000cf>
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.CreateBindableView (object,int) <IL 0x00013, 0x000bb>
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.GetBindableView (Android.Views.View,object,int) <IL 0x00027, 0x0027f>
In mgmain JNI_OnLoad
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.GetView (int,Android.Views.View,Android.Views.ViewGroup,int) <IL 0x00028, 0x0015f>
02-21 14:22:48.990 I/MonoDroid( 6664): at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.GetView (int,Android.Views.View,Android.Views.ViewGroup) <IL 0x0001d, 0x00143>
02-21 14:22:48.990 I/MonoDroid( 6664): at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (intptr,intptr,int,intptr,intptr) [0x0001a] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.Widget.BaseAdapter.cs:460
02-21 14:22:48.990 I/MonoDroid( 6664): at (wrapper dynamic-method) object.b848e0e4-b229-42ef-800c-15bdfcb46936 (intptr,intptr,int,intptr,intptr) <IL 0x00023, 0x0005f>
02-21 14:22:48.990 I/MonoDroid( 6664):
02-21 14:22:48.990 I/MonoDroid( 6664): --- End of managed exception stack trace ---
02-21 14:22:48.990 I/MonoDroid( 6664): java.lang.RuntimeException: Binary XML file line #1: You must supply a layout_width attribute.
02-21 14:22:48.990 I/MonoDroid( 6664): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:492)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5948)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6117)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:615)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:559)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:56)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.LayoutInflater.inflate(LayoutInflater.java:480)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-21 14:22:48.990 I/MonoDroid( 6664): at cirrious.mvvmcross.binding.droid.views.MvxAdapter.n_getView(Native Method)
02-21 14:22:48.990 I/MonoDroid( 6664): at cirrious.mvvmcross.binding.droid.views.MvxAdapter.getView(MvxAdapter.java:91)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.AbsListView.obtainView(AbsListView.java:2263)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.ListView.makeAndAddView(ListView.java:1790)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.ListView.fillDown(ListView.java:691)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.ListView.fillFromTop(ListView.java:752)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.ListView.layoutChildren(ListView.java:1616)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.AbsListView.onLayout(AbsListView.java:2091)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:48.990 I/MonoDroid( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:48.990 I/MonoDroid( 6664): at
02-21 14:22:49.130 W/dalvikvm( 6664): JNI WARNING: JNI function GetMethodID called with exception pending
02-21 14:22:49.130 W/dalvikvm( 6664): in Lcirrious/mvvmcross/binding/droid/views/MvxAdapter;.n_getView:(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View; (GetMethodID)
02-21 14:22:49.130 W/dalvikvm( 6664): Pending exception is:
02-21 14:22:49.130 I/dalvikvm( 6664): java.lang.RuntimeException: Binary XML file line #1: You must supply a layout_width attribute.
02-21 14:22:49.130 I/dalvikvm( 6664): (raw stack trace not found)
02-21 14:22:49.130 I/dalvikvm( 6664): "main" prio=5 tid=1 NATIVE
02-21 14:22:49.130 I/dalvikvm( 6664): | group="main" sCount=0 dsCount=0 obj=0x417b9ca8 self=0x417a83c8
02-21 14:22:49.130 I/dalvikvm( 6664): | sysTid=6664 nice=0 sched=0/0 cgrp=apps handle=1074610516
02-21 14:22:49.130 I/dalvikvm( 6664): | state=R schedstat=( 0 0 0 ) utm=337 stm=66 core=0
02-21 14:22:49.150 I/dalvikvm( 6664): #00 pc 0000132e /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
02-21 14:22:49.150 I/dalvikvm( 6664): #01 pc 00060652 /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+33)
02-21 14:22:49.150 I/dalvikvm( 6664): #02 pc 00054640 /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+395)
02-21 14:22:49.150 I/dalvikvm( 6664): #03 pc 000546ae /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
02-21 14:22:49.150 I/dalvikvm( 6664): #04 pc 00038804 /system/lib/libdvm.so
02-21 14:22:49.150 I/dalvikvm( 6664): #05 pc 00040c80 /system/lib/libdvm.so
02-21 14:22:49.150 I/dalvikvm( 6664): at cirrious.mvvmcross.binding.droid.views.MvxAdapter.n_getView(Native Method)
02-21 14:22:49.150 I/dalvikvm( 6664): at cirrious.mvvmcross.binding.droid.views.MvxAdapter.getView(MvxAdapter.java:91)
02-21 14:22:49.150 I/dalvikvm( 6664): at android.widget.AbsListView.obtainView(AbsListView.java:2263)
02-21 14:22:49.150 I/dalvikvm( 6664): at android.widget.ListView.makeAndAddView(ListView.java:1790)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.widget.ListView.fillDown(ListView.java:691)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.widget.ListView.fillFromTop(ListView.java:752)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.widget.ListView.layoutChildren(ListView.java:1616)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.widget.AbsListView.onLayout(AbsListView.java:2091)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
02-21 14:22:49.160 I/dalvikvm( 6664): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:49.170 I/dalvikvm( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.View.layout(View.java:14817)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.ViewGroup.layout(ViewGroup.java:4631)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
02-21 14:22:49.180 I/dalvikvm( 6664): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.view.Choreographer.doFrame(Choreographer.java:544)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.os.Handler.handleCallback(Handler.java:733)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.os.Handler.dispatchMessage(Handler.java:95)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.os.Looper.loop(Looper.java:136)
02-21 14:22:49.190 I/dalvikvm( 6664): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-21 14:22:49.190 I/dalvikvm( 6664): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 14:22:49.200 I/dalvikvm( 6664): at java.lang.reflect.Method.invoke(Method.java:515)
02-21 14:22:49.200 I/dalvikvm( 6664): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-21 14:22:49.200 I/dalvikvm( 6664): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-21 14:22:49.200 I/dalvikvm( 6664): at dalvik.system.NativeStart.main(Native Method)
02-21 14:22:49.200 I/dalvikvm( 6664):
02-21 14:22:49.200 E/dalvikvm( 6664): VM aborting
02-21 14:22:49.200 E/mono-rt ( 6664): Stacktrace:
02-21 14:22:49.200 E/mono-rt ( 6664):
02-21 14:22:49.200 E/mono-rt ( 6664): at <unknown> <0xffffffff>
02-21 14:22:49.200 E/mono-rt ( 6664): at (wrapper managed-to-native) object.wrapper_native_0x41551c59 (intptr,intptr,string,string) <IL 0x0004c, 0xffffffff>
02-21 14:22:49.210 E/mono-rt ( 6664): at (wrapper delegate-invoke) <Module>.invoke_intptr__this___intptr_intptr_string_string (intptr,intptr,string,string) <IL 0x00063, 0xffffffff>
02-21 14:22:49.210 E/mono-rt ( 6664): at Android.Runtime.JNIEnv.GetMethodID (intptr,string,string) [0x00042] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:157
02-21 14:22:49.210 E/mono-rt ( 6664): at Java.Lang.Throwable.get_Message () [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Java.Lang.Throwable.cs:231
02-21 14:22:49.210 E/mono-rt ( 6664): at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
02-21 14:22:49.210 E/mono-rt ( 6664): at <unknown> <0xffffffff>
02-21 14:22:49.210 E/mono-rt ( 6664): at (wrapper dynamic-method) object.b848e0e4-b229-42ef-800c-15bdfcb46936 (intptr,intptr,int,intptr,intptr) <IL 0x00041, 0x000ec>
02-21 14:22:49.210 E/mono-rt ( 6664): at (wrapper native-to-managed) object.b848e0e4-b229-42ef-800c-15bdfcb46936 (intptr,intptr,int,intptr,intptr) <IL 0x00028, 0xffffffff>
02-21 14:22:49.210 E/mono-rt ( 6664):
02-21 14:22:49.210 E/mono-rt ( 6664): =================================================================
02-21 14:22:49.210 E/mono-rt ( 6664): Got a SIGABRT while executing native code. This usually indicates
02-21 14:22:49.210 E/mono-rt ( 6664): a fatal error in the mono runtime or one of the native libraries
02-21 14:22:49.210 E/mono-rt ( 6664): used by your application.
02-21 14:22:49.210 E/mono-rt ( 6664): =================================================================
02-21 14:22:49.210 E/mono-rt ( 6664):

out of memory in android while opening a customized dialog view?

on click opening a dialog view it giving an out of memory? In dialog i have two images in it and 1 image button, even the size of image is 40 50kb.
04-15 10:11:07.085: E/dalvikvm-heap(29896): Out of memory on a 16384016-byte allocation.
04-15 10:11:07.085: I/dalvikvm(29896): "main" prio=5 tid=1 RUNNABLE
04-15 10:11:07.085: I/dalvikvm(29896): | group="main" sCount=0 dsCount=0 obj=0x40c51460 self=0x12938
04-15 10:11:07.085: I/dalvikvm(29896): | sysTid=29896 nice=0 sched=0/0 cgrp=default handle=1075008808
04-15 10:11:07.085: I/dalvikvm(29896): | schedstat=( 1269958584 831219251 1666 ) utm=105 stm=21 core=0
04-15 10:11:07.085: I/dalvikvm(29896): at android.graphics.Bitmap.nativeCreate(Native Method)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
04-15 10:11:07.090: I/dalvikvm(29896): at android.content.res.Resources.loadDrawable(Resources.java:1968)
04-15 10:11:07.090: I/dalvikvm(29896): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-15 10:11:07.095: I/dalvikvm(29896): at android.widget.ImageView.<init>(ImageView.java:119)
04-15 10:11:07.095: I/dalvikvm(29896): at android.widget.ImageView.<init>(ImageView.java:109)
04-15 10:11:07.095: I/dalvikvm(29896): at java.lang.reflect.Constructor.constructNative(Native Method)
04-15 10:11:07.095: I/dalvikvm(29896): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-15 10:11:07.095: I/dalvikvm(29896): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-15 10:11:07.100: I/dalvikvm(29896): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-15 10:11:07.100: I/dalvikvm(29896): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
04-15 10:11:07.100: I/dalvikvm(29896): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)

android.media.MediaExtractor. Anyone got this beast to work? "Failed to instantiate extractor" exception

Trying to run this (example code from developer.android.com)
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource("/sdcard/myvideo.mp4");
Getting "Failed to instantiate extractor" exception on the second line.
Tried to place the file in internal storage, tried to access via FileDescriptor, nothing helped.
Anyone??
I/MonoDroid( 6802): UNHANDLED EXCEPTION: Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
I/MonoDroid( 6802): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00023] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:368
I/MonoDroid( 6802): at Android.Media.MediaExtractor.SetDataSource (Java.IO.FileDescriptor) [0x0002d] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Android.Media.MediaExtractor.cs:206
I/MonoDroid( 6802): at AndroidApplication1.Activity1.ExtractVideo () [0x0001e] in c:\Users\pka\Documents\Visual Studio 2012\Projects\AndroidApplication1\AndroidApplication1\Activity1.cs:64
I/MonoDroid( 6802): at AndroidApplication1.Activity1.<OnCreate>b__2 (object,System.EventArgs) [0x00001] in c:\Users\pka\Documents\Visual Studio 2012\Projects\AndroidApplication1\AndroidApplication1\Activity1.cs:53
I/MonoDroid( 6802): at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) [0x0000b] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Android.Views.View.cs:1382
I/MonoDroid( 6802): at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Android.Views.View.cs:1353
I/MonoDroid( 6802): at (wrapper dynamic-method) object.0b69082c-1c66-4fd6-89c4-1d14273d4245 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
I/MonoDroid( 6802):
I/MonoDroid( 6802): --- End of managed exception stack trace ---
I/MonoDroid( 6802): java.io.IOException: Failed to instantiate extractor.
I/MonoDroid( 6802): at android.media.MediaExtractor.setDataSource(Native Method)
I/MonoDroid( 6802): at android.media.MediaExtractor.setDataSource(MediaExtractor.java:158)
I/MonoDroid( 6802): at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
I/MonoDroid( 6802): at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
I/MonoDroid( 6802): at android.view.View.performClick(View.java:4211)
I/MonoDroid( 6802): at android.view.View$PerformClick.run(View.java:17267)
I/MonoDroid( 6802): at android.os.Handler.handleCallback(Handler.java:615)
I/MonoDroid( 6802): at android.os.Handler.dispatchMessage(Handler.java:92)
I/MonoDroid( 6802): at android.os.Looper.loop(Looper.java:137)
I/MonoDroid( 6802): at android.app.ActivityThread.main(ActivityThread.java:4898)
I/MonoDroid( 6802): at java.lang.reflect.Method.invokeNative(Native Method)
I/MonoDroid( 6802): at java.lang.reflect.Method.invoke(Method.java:511)
I/MonoDroid( 6802): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
I/MonoDroid( 6802): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
I/MonoDroid( 6802): at dalvik.system.NativeStart.main(Native Method)
W/dalvikvm( 6802): JNI WARNING: JNI method called with exception pending
W/dalvikvm( 6802): in Lmono/android/view/View_OnClickListenerImplementor;.n_onClick:(Landroid/view/View;)V (CallObjectMethod)
W/dalvikvm( 6802): Pending exception is:
I/dalvikvm( 6802): java.io.IOException: Failed to instantiate extractor.
I/dalvikvm( 6802): (raw stack trace not found)
I/dalvikvm( 6802): "main" prio=5 tid=1 NATIVE
I/dalvikvm( 6802): | group="main" sCount=0 dsCount=0 obj=0x41094508 self=0x40e6f9a0
I/dalvikvm( 6802): | sysTid=6802 nice=0 sched=0/0 cgrp=apps handle=1074282288
I/dalvikvm( 6802): | schedstat=( 1587575495 261759711 782 ) utm=108 stm=50 core=3
I/dalvikvm( 6802): #00 pc 00001260 /system/lib/libcorkscrew.so (unwind_backtrace_thread+27)
I/dalvikvm( 6802): #01 pc 0005f904 /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+35)
I/dalvikvm( 6802): #02 pc 000537ac /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+303)
I/dalvikvm( 6802): #03 pc 00053846 /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
I/dalvikvm( 6802): #04 pc 00038e02 /system/lib/libdvm.so
I/dalvikvm( 6802): #05 pc 00040f60 /system/lib/libdvm.so
I/dalvikvm( 6802): at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
I/dalvikvm( 6802): at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
I/dalvikvm( 6802): at android.view.View.performClick(View.java:4211)
I/dalvikvm( 6802): at android.view.View$PerformClick.run(View.java:17267)
I/dalvikvm( 6802): at android.os.Handler.handleCallback(Handler.java:615)
I/dalvikvm( 6802): at android.os.Handler.dispatchMessage(Handler.java:92)
I/dalvikvm( 6802): at android.os.Looper.loop(Looper.java:137)
I/dalvikvm( 6802): at android.app.ActivityThread.main(ActivityThread.java:4898)
I/dalvikvm( 6802): at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm( 6802): at java.lang.reflect.Method.invoke(Method.java:511)
I/dalvikvm( 6802): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
I/dalvikvm( 6802): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
I/dalvikvm( 6802): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm( 6802):
E/dalvikvm( 6802): VM aborting
I/mono ( 6802): Stacktrace:
I/mono ( 6802):
I/mono ( 6802): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00000] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:129
I/mono ( 6802): at Java.Lang.Throwable.get_Message () [0x0003e] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Java.Lang.Throwable.cs:195
I/mono ( 6802): at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
E/mono ( 6802):
E/mono ( 6802): Unhandled Exception:
E/mono ( 6802): Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
E/mono ( 6802): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00023] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:368
E/mono ( 6802): at Android.Media.MediaExtractor.SetDataSource (Java.IO.FileDescriptor) [0x0002d] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Android.Media.MediaExtractor.cs:206
E/mono ( 6802): at AndroidApplication1.Activity1.ExtractVideo () [0x0001e] in c:\Users\pka\Documents\Visual Studio 2012\Projects\AndroidApplication1\AndroidApplication1\Activity1.cs:64
E/mono ( 6802): at AndroidApplication1.Activity1.<OnCreate>b__2 (object,System.EventArgs) [0x00001] in c:\Users\pka\Documents\Visual Studio 2012\Projects\AndroidApplication1\AndroidApplication1\Activity1.cs:53
E/mono ( 6802): at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View)
I/mono ( 6802): [ERROR] FATAL UNHANDLED EXCEPTION: Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
I/mono ( 6802): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00023] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:368
I/mono ( 6802): at Android.Media.MediaExtractor.SetDataSource (Java.IO.FileDescriptor) [0x0002d] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/c6e52015/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Android.Media.MediaExtractor.cs:206
I/mono ( 6802): at AndroidApplication1.Activity1.ExtractVideo () [0x0001e] in c:\Users\pka\Documents\Visual Studio 2012\Projects\AndroidApplication1\AndroidApplication1\Activity1.cs:64
I/mono ( 6802): at AndroidApplication1.Activity1.<OnCreate>b__2 (object,System.EventArgs) [0x00001] in c:\Users\pka\Documents\Visual Studio 2012\Projects\AndroidApplication1\AndroidApplication1\Activity1.cs:53
I/mono ( 6802): at Android.Views.View/IOnClickListenerImplementor.OnClick (Android
V/MediaPlayerService( 1901): Delete media recorder client
D/ISecCameraHardware( 1901): stopPreview E
W/ISecCameraHardware( 1901): stopPreview: warning, preview has been stopped
I/SurfaceFlinger( 1898): id=23 Removed TurfaceView idx=2 MapSz=3
D/ISecCameraHardware( 1901): cancelPicture EX
D/SecCameraHardware( 1901): release E
D/ISecCameraHardware( 1901): Camera.... release
W/InputDispatcher( 2253): channel ~ Consumer closed input channel or an error occurred. events=0x9
I am an idiot...I had another part of my program holding open the same file that the extractor was supposed to read off...
Quite bad error message from Android though.

Categories

Resources