Webview inside a TabView crashes when showing a dialog screen - android

I have a WebView in a TabView. The webView has a button. When the button is pressed a spinner is opened.
I am just loadng the webview with the URL. The action listener and spinner is triggered from the server side.
webview = (WebView) findViewById(R.id.webview);
....
....
webview.loadUrl(locationUrl);
My App is developed on Android 2.2. It is working fine in a device with OS 2.2 but crashing in 2.3.
Below is the log
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord#406e21e0 is not valid; is your activity running?
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.view.ViewRoot.setView(ViewRoot.java:527)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.app.Dialog.show(Dialog.java:241)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.webkit.WebView$InvokeListBox.run(WebView.java:7583)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.os.Handler.handleCallback(Handler.java:587)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.os.Looper.loop(Looper.java:130)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684):     at dalvik.system.NativeStart.main(Native Method)

Use getparent() to get the parent context. As this is a tab, everything is done in parent context.

Related

Getting different errors for different platforms using Renderscript Support Library

I'm having different troubles trying to implement some code written in Renderscript for Android.
First let me say that all my SDK packages are up-to-dated to the 22.3 version, including the Ecplise ADT and Build-Tools 19.0.0.
My purpose is to implement some high-computational image algorithms on a wide range of Android platforms, possibly starting from API 8. For this, I've set a reference to the renderscript-v8 library on my Ecplise project, while targeting the application to API 19.
I have two Android devices to test, the first is an Android 4.3 (API 18), the second comes with Android 2.2 (API 8). I'm experiencing different exceptions when running this piece of code, that calls ScriptIntrinsicYuvToRGB (code is partially taken from Executing ScriptIntrinsicYuvToRgb question):
/* --------------
global vars */
private RenderScript rs;
private ScriptIntrinsicYuvToRGB rs_YUVtoRGB;
private Allocation rs_YUVtoRGB_in;
private Allocation rs_YUVtoRGB_out;
/* --------------
in constructor... */
this.rs = RenderScript.create(this.getContext());
this.rs_YUVtoRGB = ScriptIntrinsicYuvToRGB.create(this.rs, Element.U8_4(rs));
Type.Builder tb_in = new Type.Builder(this.rs, Element.createPixel(this.rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
tb_in.setX(prevWidth);
tb_in.setY(prevHeight);
tb_in.setMipmaps(false);
tb_in.setYuvFormat(this.camera.getParameters().getPreviewFormat());
this.rs_YUVtoRGB_in = Allocation.createTyped(this.rs, tb_in.create(), Allocation.USAGE_SCRIPT);
Type.Builder tb_out = new Type.Builder(this.rs, Element.RGBA_8888(this.rs));
tb_out.setX(prevWidth);
tb_out.setY(prevHeight);
tb_out.setMipmaps(false);
this.rs_YUVtoRGB_out = Allocation.createTyped (this.rs, tb_out.create(), Allocation.USAGE_SCRIPT);
/* --------------
launching the script... */
// byte[] raw... // a YUV image
this.rs_YUVtoRGB_in.copyFrom(raw);
this.rs_YUVtoRGB.setInput(this.rs_YUVtoRGB_in);
this.rs_YUVtoRGB.forEach(this.rs_YUVtoRGB_out);
int[] framePixels = new int[previewSize.width * previewSize.height];
this.rs_YUVtoRGB_out.copyTo(framePixels); // final RGB converted image
Eclipse manages to compile it (it should mean that the library is well referenced), but...
Android 4.3 fails at : Type.Builder tb_in = new Type.Builder(this.rs, Element.createPixel(this.rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV)); with Unsupported DataKind
11-24 11:17:57.685: E/AndroidRuntime(2494): FATAL EXCEPTION: main
11-24 11:17:57.685: E/AndroidRuntime(2494): android.renderscript.RSIllegalArgumentException: Unsupported DataKind
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.renderscript.Element.createPixel(Element.java:911)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.support.v8.renderscript.ElementThunker.createPixel(ElementThunker.java:224)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.support.v8.renderscript.Element.createPixel(Element.java:832)
11-24 11:17:57.685: E/AndroidRuntime(2494): at com.lag.appprj.CameraPreview.setupCamera(CameraPreview.java:167)
11-24 11:17:57.685: E/AndroidRuntime(2494): at com.lag.appprj.CameraPreview.surfaceCreated(CameraPreview.java:86)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.SurfaceView.updateWindow(SurfaceView.java:571)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.SurfaceView.access$000(SurfaceView.java:86)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:833)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
11-24 11:17:57.685: E/AndroidRuntime(2494): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
While on Android 2.2 it fails in the init phase: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Library RSSupport not found
11-24 11:45:45.329: E/AndroidRuntime(2048): FATAL EXCEPTION: main
11-24 11:45:45.329: E/AndroidRuntime(2048): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lag.appprj/com.lag.appprj.CaptureActivity}: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Library RSSupport not found
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.os.Looper.loop(Looper.java:123)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-24 11:45:45.329: E/AndroidRuntime(2048): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 11:45:45.329: E/AndroidRuntime(2048): at java.lang.reflect.Method.invoke(Method.java:521)
11-24 11:45:45.329: E/AndroidRuntime(2048): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-24 11:45:45.329: E/AndroidRuntime(2048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-24 11:45:45.329: E/AndroidRuntime(2048): at dalvik.system.NativeStart.main(Native Method)
11-24 11:45:45.329: E/AndroidRuntime(2048): Caused by: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Library RSSupport not found
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.support.v8.renderscript.RenderScript.create(RenderScript.java:945)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.support.v8.renderscript.RenderScript.create(RenderScript.java:982)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.support.v8.renderscript.RenderScript.create(RenderScript.java:968)
11-24 11:45:45.329: E/AndroidRuntime(2048): at com.lag.appprj.CameraPreview.<init>(CameraPreview.java:80)
11-24 11:45:45.329: E/AndroidRuntime(2048): at com.lag.appprj.CaptureActivity.onCreate(CaptureActivity.java:34)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-24 11:45:45.329: E/AndroidRuntime(2048): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
Thanks for the help
The error with createPixel() is an actual bug in ElementThunker.java. It is missing a case for PIXEL_YUV, so it ends up returning null instead of the appropriate type. I will fix this in AOSP and for a future SDK release. (Patch is at https://android-review.googlesource.com/70810).
As far as the library load issue, I believe on your other SO question you noticed that your Application.mk file was not building for all architectures (and hence not bundling the appropriate shared libraries). The reason that it works on 4.3 is that 4.3 has a copy of libRSSupport.so automatically (although it really shouldn't). Older devices will obviously not have a default /system/lib/ copy of that .so, so they will always fail to load it unless your build actually packages it up with the apk.

Decompiled and imported into Eclipse and got instantiation error

I am a newbie to Android App programming. I decompiled an APK and imported into Eclipse. I ran it on an Android emulator and I got the message below on Logcat. Can someone give me an idea where to start looking. The app works on the Android phone. Thanks.
11-24 13:41:39.046: D/AndroidRuntime(363): Shutting down VM
11-24 13:41:39.046: W/dalvikvm(363): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-24 13:41:39.126: E/AndroidRuntime(363): FATAL EXCEPTION: main
11-24 13:41:39.126: E/AndroidRuntime(363): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.breakeven/com.breakeven.BreakEvenCalculatorActivity}: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.os.Looper.loop(Looper.java:123)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:41:39.126: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:41:39.126: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:41:39.126: E/AndroidRuntime(363): at dalvik.system.NativeStart.main(Native Method)
11-24 13:41:39.126: E/AndroidRuntime(363): Caused by: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:41:39.126: E/AndroidRuntime(363): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-24 13:41:39.126: E/AndroidRuntime(363): ... 11 more
11-24 13:43:41.106: I/Process(363): Sending signal. PID: 363 SIG: 9
11-24 13:44:17.136: D/AndroidRuntime(393): Shutting down VM
11-24 13:44:17.136: W/dalvikvm(393): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-24 13:44:17.206: E/AndroidRuntime(393): FATAL EXCEPTION: main
11-24 13:44:17.206: E/AndroidRuntime(393): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.breakeven/com.breakeven.BreakEvenCalculatorActivity}: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.os.Looper.loop(Looper.java:123)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:44:17.206: E/AndroidRuntime(393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:44:17.206: E/AndroidRuntime(393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:44:17.206: E/AndroidRuntime(393): at dalvik.system.NativeStart.main(Native Method)
11-24 13:44:17.206: E/AndroidRuntime(393): Caused by: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:44:17.206: E/AndroidRuntime(393): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-24 13:44:17.206: E/AndroidRuntime(393): ... 11 more
11-24 13:44:23.546: I/Process(393): Sending signal. PID: 393 SIG: 9
11-24 13:49:28.816: D/AndroidRuntime(403): Shutting down VM
11-24 13:49:28.816: W/dalvikvm(403): threadid=1: thread exiting with uncaught exception (group=0x40015560)

App crashes on selecting Spinner in a website openend in a WebView within the App

I have a WebView in one of the tabs in TabView. The webView loads a specific url which contains a spinner. The action listener and spinner is triggered from the server side embedded in the url.
webview = (WebView) findViewById(R.id.webview);
....
....
webview.loadUrl(locationUrl);
My App is developed on Android 2.2. It is working fine in a device with OS 2.2 but When I click the Spinner my app is crashing in a device with OS 2.3.
Below is the log
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord#406e21e0 is not valid; is your activity running?
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.ViewRoot.setView(ViewRoot.java:527)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.Window$LocalWindowManager.addView(Window.java:424)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.app.Dialog.show(Dialog.java:241)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.webkit.WebView$InvokeListBox.run(WebView.java:7583)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.os.Handler.handleCallback(Handler.java:587)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.os.Handler.dispatchMessage(Handler.java:92)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.os.Looper.loop(Looper.java:130)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at dalvik.system.NativeStart.main(Native Method)

Simulator Crashes with TextView and ImageView

I recently started programing and when I did a basic ImageView and TextView shown below.
<?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/texttry" />
</TextView>
<ImageView
android:id="#+id/joe"
android:src="#drawable/joe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
The simulator crashed and the logcat gave this error:
11-24 11:09:20.938: D/AndroidRuntime(713): Shutting down VM
11-24 11:09:20.938: W/dalvikvm(713): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
11-24 11:09:20.938: E/AndroidRuntime(713): Uncaught handler: thread main exiting due to uncaught exception
11-24 11:09:20.958: E/AndroidRuntime(713): java.lang.RuntimeException: Unable to start activity ComponentInfo{tristan.wuker.wrje/tristan.wuker.wrje.MrttestActivity}: java.lang.RuntimeException: Binary XML file line #10: You must supply a layout_width attribute.
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.os.Looper.loop(Looper.java:123)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.ActivityThread.main(ActivityThread.java:4203)
11-24 11:09:20.958: E/AndroidRuntime(713): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 11:09:20.958: E/AndroidRuntime(713): at java.lang.reflect.Method.invoke(Method.java:521)
11-24 11:09:20.958: E/AndroidRuntime(713): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
11-24 11:09:20.958: E/AndroidRuntime(713): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
11-24 11:09:20.958: E/AndroidRuntime(713): at dalvik.system.NativeStart.main(Native Method)
11-24 11:09:20.958: E/AndroidRuntime(713): Caused by: java.lang.RuntimeException: Binary XML file line #10: You must supply a layout_width attribute.
11-24 11:09:20.958: E/AndroidRuntime(713): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:438)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3433)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:3513)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1265)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1191)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:45)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-24 11:09:20.958: E/AndroidRuntime(713): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.Activity.setContentView(Activity.java:1620)
11-24 11:09:20.958: E/AndroidRuntime(713): at tristan.wuker.wrje.MrttestActivity.onCreate(MrttestActivity.java:11)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
11-24 11:09:20.958: E/AndroidRuntime(713): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
11-24 11:09:20.958: E/AndroidRuntime(713): ... 11 more
11-24 11:09:20.978: I/dalvikvm(713): threadid=7: reacting to signal 3
11-24 11:09:20.978: E/dalvikvm(713): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
I am also new to this website so I am sorry if I posted this wrong.
Also if it helps to know, when I take out ImageView the text works like a charm.
As I am sure you figured out in the end, the logs tell you where the problem is. Specifically this line (that I shortened so it fits):
11-24 11:09:20.958 .. Caused by.. #10: You must supply a layout_width attribute.
As you can see in the snippet below:
<TextView>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/texttry" />
</TextView>
You closed the <TextView\> element too early, before specifying any attributes. The one that log mentions is _layout_width_.
All you have to do to fix this 'issue' is remove the right shevron from the TextView element opening, like this:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/texttry" />
</TextView>
Boom, done :)
PS: One teeny tiny detail though fill_parent is depreciated, you should use match_parent instead:
<TextView>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/texttry" />
</TextView>
I tried your code just now and seems to work when I take out the closing </TextView> tag:
<?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/texttry" />
<ImageView
android:id="#+id/joe"
android:src="#drawable/joe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

Android webdav Java Sardine

im trying Sardine to make a webdav client in android, im trying this code:
This works perfect on JAVA aplicacion, but crashes in android :(
HttpClient client = new DefaultHttpClient();
SardineImpl sardine = new SardineImpl((AbstractHttpClient) client,"testuser","test");
List<DavResource> resources = sardine.getResources("http://demo.sabredav.org/");
for (int i = 1; i < resources.size(); i++) {
System.out.println(resources.get(i));
}
Replacing System.out.println by Toast i get this
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): java.lang.NoSuchMethodError: org.apache.http.impl.client.AbstractHttpClient.setRedirectStrategy
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at com.googlecode.sardine.impl.SardineImpl.init(SardineImpl.java:188)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at com.googlecode.sardine.impl.SardineImpl.<init>(SardineImpl.java:182)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at es.sardine.sardine.onCreate(sardine.java:39)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.os.Looper.loop(Looper.java:143)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at android.app.ActivityThread.main(ActivityThread.java:4914)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at java.lang.reflect.Method.invoke(Method.java:521)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-24 16:05:34.602: ERROR/AndroidRuntime(19362): at dalvik.system.NativeStart.main(Native Method)
I had the same trouble trying to use Sardine and including Apache HttpClient which would conflict with the version embedded in Android. So I decided to replace it with OkHttp and I have much less trouble.
Here is the fork I created: https://github.com/thegrizzlylabs/sardine-android
Did you see this q: Using webdav on Android ? It essentially says that Sardine needs newer HttpClient version than packages with Android, and provides a lick to patched HttpClient 4.1 linkable into Android apps.
For you only iterating through the elements on the server this code worked for me:
try{
Sardine sardine = SardineFactory.begin("username", "password");
List<DavResource> resources = sardine.list("webdav/server/directory/");
buffer = new StringBuilder();
for (DavResource res : resources)
{
//for example
buffer.append(res.toString());
}
}catch(Exception e){
Log.e("VIEWER" , e.getMessage());
}
I used the Sardine-Android Project Library in combination with the simpleframework.xml.

Categories

Resources