Call Web Service in Android application - android

I want to call .net web service into Android application. For that I am using running web service available on net called
"www.w3schools.com/webservices/tempconvert.asmx"
It's running successfully with browser, but when I call it in my Android application it gives me error in my tab device. The log cat info is shown below:
06-08 17:27:16.351: E/dalvikvm(5767): Could not find class 'org.ksoap2.serialization.SoapObject', referenced from method com.example.wscallingapk.WS_MainActivity.onCreate
06-08 17:27:22.612: E/AndroidRuntime(5767): FATAL EXCEPTION: main
06-08 17:27:22.612: E/AndroidRuntime(5767): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
06-08 17:27:22.612: E/AndroidRuntime(5767): at com.example.wscallingapk.WS_MainActivity.onCreate(WS_MainActivity.java:37)
06-08 17:27:22.612: E/AndroidRuntime(5767): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-08 17:27:22.612: E/AndroidRuntime(5767): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-08 17:27:22.612: E/AndroidRuntime(5767): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-08 17:27:22.612: E/AndroidRuntime(5767): at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 17:27:22.612: E/AndroidRuntime(5767): at android.os.Looper.loop(Looper.java:123)
06-08 17:27:22.612: E/AndroidRuntime(5767): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-08 17:27:22.612: E/AndroidRuntime(5767): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 17:27:22.612: E/AndroidRuntime(5767): at java.lang.reflect.Method.invoke(Method.java:521)
06-08 17:27:22.612: E/AndroidRuntime(5767): at java.lang.reflect.Method.invoke(Method.java:521)
06-08 17:27:22.612: E/AndroidRuntime(5767): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
06-08 17:27:22.612: E/AndroidRuntime(5767): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
06-08 17:27:22.612: E/AndroidRuntime(5767): at dalvik.system.NativeStart.main(Native Method)

ksoap2-android-assembly-2.6.2-jar-with-dependencies.jar
Download this library from this Link
and put it into your lib folder of your project.

Related

How to resolve java.lang.VerifyError in android

I am getting VerifyError for method calling of paticular class Utility ,first it was working properly and suddenly its started giving run time error, it is working fine with API lollipop and higher API , Here is my error logs.
06-08 12:25:07.655: E/AndroidRuntime(18117): FATAL EXCEPTION: main
06-08 12:25:07.655: E/AndroidRuntime(18117): java.lang.VerifyError: com/package/projectname/utility/Utility
06-08 12:25:07.655: E/AndroidRuntime(18117): at com.package.projectname.AppDelegate.onCreate(AppDelegate.java:36)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1017)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4575)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.app.ActivityThread.access$1400(ActivityThread.java:153)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.os.Looper.loop(Looper.java:176)
06-08 12:25:07.655: E/AndroidRuntime(18117): at android.app.ActivityThread.main(ActivityThread.java:5302)
06-08 12:25:07.655: E/AndroidRuntime(18117): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 12:25:07.655: E/AndroidRuntime(18117): at java.lang.reflect.Method.invoke(Method.java:511)
06-08 12:25:07.655: E/AndroidRuntime(18117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
06-08 12:25:07.655: E/AndroidRuntime(18117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
06-08 12:25:07.655: E/AndroidRuntime(18117): at dalvik.system.NativeStart.main(Native Method)
I solved this error by placing gms library separately:
Before I have used :
compile 'com.google.android.gms:play-services:8.1.0'
That above one line will take care of GCM and all google related libaries.But this one line cause a verifier error.On top of the verifier error you can see some gms related log.
After that I have added separately like this to fix this issue :
compile 'com.google.android.gms:play-services-location:8.1.0'
compile 'com.google.android.gms:play-services-base:8.1.0'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile "com.google.android.gms:play-services-gcm:8.1.0' // for gcm push notification
and also Check this

How to solve "Out of memory" during image processing on Imagine SDK android [duplicate]

This question already has answers here:
Strange OutOfMemory issue while loading an image to a Bitmap object
(44 answers)
Closed 7 years ago.
as i am implementing both OCR and Imagine SDK for our app, i need your help to solve this problem.
i have a method like below.
public void ImageProcessing(View v) {
try {
MIContext _miContext = MIContext.getInstance();
_miContext.clearAll();
Uri _imageUri = Uri.fromFile(GetImageFile("form.jpg")); // GetImageFile() will return a file
ImageOperation _imageOperation = ImageOperation.AUTO_ENHANCE;
OperationController _operationController = _imageOperation.getController();
_miContext.loadSourceImage( _imageUri, this );
final FineOperation fineOperation = _operationController.createOperation();
_miContext.run( fineOperation );
} catch (Exception e) {
Log.v("mango", e.getMessage());
}
}
when i execute it. it returns "Out of memory: Heap Size=7943KB, Allocated=4113KB, Bitmap Size=24888KB, Limit=32768KB"
below is my logcat output.
06-08 12:24:44.561: V/mango(16037): onCreate()
06-08 12:24:44.561: V/mango(16037): starting......
06-08 12:24:44.561: D/dalvikvm(16037): Trying to load lib /data/data/com.abbyy.sample/lib/libMobileImagingEngine.so 0x4051bfd8
06-08 12:24:44.881: D/dalvikvm(16037): Added shared lib /data/data/com.abbyy.sample/lib/libMobileImagingEngine.so 0x4051bfd8
06-08 12:24:44.881: V/mango(16037): MILicenser.getVersionInfo(): 1.2.1.15
06-08 12:24:44.951: V/mango(16037): MILicenser.setLicense() succeeded. Current state:
06-08 12:24:44.951: V/mango(16037): License: Infinite.
06-08 12:24:44.951: V/mango(16037): General availability: Enabled with results scrambling.
06-08 12:24:44.951: V/mango(16037): Allowed platforms: All.
06-08 12:24:44.951: V/mango(16037): Common processing available: Yes.
06-08 12:24:44.951: V/mango(16037): Defect detecting available: Yes.
06-08 12:24:44.951: V/mango(16037): Server side processing available: No.??
06-08 12:24:45.401: D/dalvikvm(16037): Trying to load lib /data/data/com.abbyy.sample/lib/libMobileOcrEngine.so 0x4051bfd8
06-08 12:24:45.892: D/dalvikvm(16037): Added shared lib /data/data/com.abbyy.sample/lib/libMobileOcrEngine.so 0x4051bfd8
06-08 12:24:46.032: D/dalvikvm(16037): GC_CONCURRENT freed 173K, 45% free 3109K/5639K, external 0K/0K, paused 4ms+13ms
06-08 12:24:46.392: D/ATRecorder(16037): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader#40582d68
06-08 12:24:46.402: D/WindowManagerImpl(16037): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView#4055b6e8
06-08 12:26:46.029: D/View(16037): onTouchEvent: viewFlags: 0x18004001
06-08 12:26:46.029: D/View(16037): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
06-08 12:26:57.210: D/dalvikvm(16037): GC_EXTERNAL_ALLOC freed 184K, 44% free 3248K/5767K, external 0K/0K, paused 31ms
06-08 12:26:58.071: D/ATRecorder(16037): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader#4059fd80
06-08 12:26:58.071: D/WindowManagerImpl(16037): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView#4059cad0
06-08 12:26:58.311: D/WindowManagerImpl(16037): finishRemoveViewLocked, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView#4055b6e8
06-08 12:26:59.632: D/View(16037): onTouchEvent: viewFlags: 0x18004001
06-08 12:26:59.632: D/View(16037): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
06-08 12:26:59.672: D/dalvikvm(16037): GC_EXPLICIT freed 103K, 45% free 3189K/5767K, external 24888K/26936K, paused 27ms
06-08 12:26:59.763: I/dalvikvm-heap(16037): Clamp target GC heap from 32.598MB to 32.000MB
06-08 12:26:59.763: D/dalvikvm(16037): GC_FOR_MALLOC freed 552K, 44% free 4145K/7367K, external 24888K/26936K, paused 17ms
06-08 12:26:59.763: I/dalvikvm-heap(16037): Forcing collection of SoftReferences for 1966096-byte allocation
06-08 12:26:59.773: I/dalvikvm-heap(16037): Clamp target GC heap from 32.566MB to 32.000MB
06-08 12:26:59.773: D/dalvikvm(16037): GC_FOR_MALLOC freed 32K, 45% free 4113K/7367K, external 24888K/26936K, paused 18ms
06-08 12:26:59.783: E/dalvikvm-heap(16037): Out of memory on a 1966096-byte allocation.
06-08 12:26:59.783: I/dalvikvm(16037): "main" prio=5 tid=1 RUNNABLE
06-08 12:26:59.783: I/dalvikvm(16037): | group="main" sCount=0 dsCount=0 obj=0x400275d8 self=0xd050
06-08 12:26:59.783: I/dalvikvm(16037): | sysTid=16037 nice=0 sched=0/0 cgrp=default handle=-1345002112
06-08 12:26:59.783: I/dalvikvm(16037): | schedstat=( 1244079605 798675516 1219 )
06-08 12:26:59.783: I/dalvikvm(16037): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:~91)
06-08 12:26:59.783: I/dalvikvm(16037): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:216)
06-08 12:26:59.783: I/dalvikvm(16037): at com.abbyy.mobile.imaging.MIExporter.importJPEG(MIExporter.java:102)
06-08 12:26:59.783: I/dalvikvm(16037): at com.abbyy.sample.MIContext.loadSourceImage(MIContext.java:114)
06-08 12:26:59.783: I/dalvikvm(16037): at com.abbyy.sample.ScanTheForm.ImageProcessing(ScanTheForm.java:71)
06-08 12:26:59.783: I/dalvikvm(16037): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 12:26:59.783: I/dalvikvm(16037): at java.lang.reflect.Method.invoke(Method.java:507)
06-08 12:26:59.783: I/dalvikvm(16037): at android.view.View$1.onClick(View.java:2187)
06-08 12:26:59.793: I/dalvikvm(16037): at android.view.View.performClick(View.java:2533)
06-08 12:26:59.793: I/dalvikvm(16037): at android.view.View$PerformClick.run(View.java:9320)
06-08 12:26:59.793: I/dalvikvm(16037): at android.os.Handler.handleCallback(Handler.java:587)
06-08 12:26:59.793: I/dalvikvm(16037): at android.os.Handler.dispatchMessage(Handler.java:92)
06-08 12:26:59.793: I/dalvikvm(16037): at android.os.Looper.loop(Looper.java:150)
06-08 12:26:59.793: I/dalvikvm(16037): at android.app.ActivityThread.main(ActivityThread.java:4385)
06-08 12:26:59.793: I/dalvikvm(16037): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 12:26:59.793: I/dalvikvm(16037): at java.lang.reflect.Method.invoke(Method.java:507)
06-08 12:26:59.793: I/dalvikvm(16037): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
06-08 12:26:59.793: I/dalvikvm(16037): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
06-08 12:26:59.793: I/dalvikvm(16037): at dalvik.system.NativeStart.main(Native Method)
06-08 12:26:59.793: E/dalvikvm(16037): Out of memory: Heap Size=7943KB, Allocated=4113KB, Bitmap Size=24888KB, Limit=32768KB
06-08 12:26:59.793: E/dalvikvm(16037): Extra info: Footprint=7367KB, Allowed Footprint=7943KB, Trimmed=480KB
06-08 12:26:59.793: D/AndroidRuntime(16037): Shutting down VM
06-08 12:26:59.793: W/dalvikvm(16037): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
06-08 12:26:59.803: E/AndroidRuntime(16037): FATAL EXCEPTION: main
06-08 12:26:59.803: E/AndroidRuntime(16037): java.lang.IllegalStateException: Could not execute method of the activity
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.view.View$1.onClick(View.java:2192)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.view.View.performClick(View.java:2533)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.view.View$PerformClick.run(View.java:9320)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.os.Handler.handleCallback(Handler.java:587)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.os.Handler.dispatchMessage(Handler.java:92)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.os.Looper.loop(Looper.java:150)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.app.ActivityThread.main(ActivityThread.java:4385)
06-08 12:26:59.803: E/AndroidRuntime(16037): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 12:26:59.803: E/AndroidRuntime(16037): at java.lang.reflect.Method.invoke(Method.java:507)
06-08 12:26:59.803: E/AndroidRuntime(16037): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
06-08 12:26:59.803: E/AndroidRuntime(16037): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
06-08 12:26:59.803: E/AndroidRuntime(16037): at dalvik.system.NativeStart.main(Native Method)
06-08 12:26:59.803: E/AndroidRuntime(16037): Caused by: java.lang.reflect.InvocationTargetException
06-08 12:26:59.803: E/AndroidRuntime(16037): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 12:26:59.803: E/AndroidRuntime(16037): at java.lang.reflect.Method.invoke(Method.java:507)
06-08 12:26:59.803: E/AndroidRuntime(16037): at android.view.View$1.onClick(View.java:2187)
06-08 12:26:59.803: E/AndroidRuntime(16037): ... 11 more
06-08 12:26:59.803: E/AndroidRuntime(16037): Caused by: java.lang.OutOfMemoryError: (Heap Size=7943KB, Allocated=4113KB, Bitmap Size=24888KB)
06-08 12:26:59.803: E/AndroidRuntime(16037): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
06-08 12:26:59.803: E/AndroidRuntime(16037): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:216)
06-08 12:26:59.803: E/AndroidRuntime(16037): at com.abbyy.mobile.imaging.MIExporter.importJPEG(MIExporter.java:102)
06-08 12:26:59.803: E/AndroidRuntime(16037): at com.abbyy.sample.MIContext.loadSourceImage(MIContext.java:114)
06-08 12:26:59.803: E/AndroidRuntime(16037): at com.abbyy.sample.ScanTheForm.ImageProcessing(ScanTheForm.java:71)
06-08 12:26:59.803: E/AndroidRuntime(16037): ... 14 more
am i doing something wrong ? Hemp help me guys
You can try increasing the allocated memory to your application. In android Every application gets a chunk of memory allocated. but in case of image processing application it is most likely to fall short of that memory.
Also try manually cleaning up the memory in your app. The android garbage collector usually have bitmap image memory leakages.
you can get a good read up on this via following link
bitmap memory managment
Use this in your application tag of Manifest file ..
android:largeHeap="true"

While running COCOS2D for Android FATAL EXCEPTION: main

I am newbie in COCOS2D for Android, While trying to run the sample project(HelloWorld) provided from cocos2d I got " FATAL EXCEPTION: main" and in detail that arrived in LogCat
05-31 19:11:46.920: E/AndroidRuntime(7719): FATAL EXCEPTION: main
05-31 19:11:46.920: E/AndroidRuntime(7719): java.lang.ExceptionInInitializerError
05-31 19:11:46.920: E/AndroidRuntime(7719): at java.lang.Class.newInstanceImpl(Native Method)
05-31 19:11:46.920: E/AndroidRuntime(7719): at java.lang.Class.newInstance(Class.java:1429)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.os.Looper.loop(Looper.java:123)
05-31 19:11:46.920: E/AndroidRuntime(7719): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-31 19:11:46.920: E/AndroidRuntime(7719): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 19:11:46.920: E/AndroidRuntime(7719): at java.lang.reflect.Method.invoke(Method.java:521)
05-31 19:11:46.920: E/AndroidRuntime(7719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-31 19:11:46.920: E/AndroidRuntime(7719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-31 19:11:46.920: E/AndroidRuntime(7719): at dalvik.system.NativeStart.main(Native Method)
05-31 19:11:46.920: E/AndroidRuntime(7719): Caused by: java.lang.UnsatisfiedLinkError: Library helloworld not found
05-31 19:11:46.920: E/AndroidRuntime(7719): at java.lang.Runtime.loadLibrary(Runtime.java:461)
05-31 19:11:46.920: E/AndroidRuntime(7719): at java.lang.System.loadLibrary(System.java:557)
05-31 19:11:46.920: E/AndroidRuntime(7719): at org.cocos2dx.application.ApplicationDemo.<clinit>(ApplicationDemo.java:81)
05-31 19:11:46.920: E/AndroidRuntime(7719): ... 15 more
So can anyone please help with some idea/solution.
Again i followed reference from "http://www.multigesture.net/articles/how-to-setup-cocos2d-x-windows-and-android/"
Thanks a lot.
I recomend you to change libraries to cocos2d-x, because cocos2d for android won't be updated anymore.
Cocos2d-x works in C++, and uses JNI (Java native interface) to work. Here is all the info you will need to start using it.

Android Fragments with compatible library

I can't make it work.
I found many similar question here, examples. But nothing help and nothing work.
Does anyone have a working Fragments in Android 2.2 with android.support.v4 library? (If you are please upload it somewhere.)
I'm almost crying because I can't find what's wrong!
The error is the same as many of people have:
05-15 18:20:20.583: W/dalvikvm(1521): Unable to resolve superclass of Lmy/fragment/test/FragmentTestActivity; (8)
05-15 18:20:20.583: W/dalvikvm(1521): Link of class 'Lmy/fragment/test/FragmentTestActivity;' failed
05-15 18:20:20.593: D/AndroidRuntime(1521): Shutting down VM
05-15 18:20:20.593: W/dalvikvm(1521): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-15 18:20:20.703: E/AndroidRuntime(1521): FATAL EXCEPTION: main
05-15 18:20:20.703: E/AndroidRuntime(1521): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.fragment.test/my.fragment.test.FragmentTestActivity}: java.lang.ClassNotFoundException: my.fragment.test.FragmentTestActivity in loader dalvik.system.PathClassLoader[/data/app/my.fragment.test-1.apk]
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.os.Looper.loop(Looper.java:123)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-15 18:20:20.703: E/AndroidRuntime(1521): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 18:20:20.703: E/AndroidRuntime(1521): at java.lang.reflect.Method.invoke(Method.java:521)
05-15 18:20:20.703: E/AndroidRuntime(1521): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-15 18:20:20.703: E/AndroidRuntime(1521): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-15 18:20:20.703: E/AndroidRuntime(1521): at dalvik.system.NativeStart.main(Native Method)
05-15 18:20:20.703: E/AndroidRuntime(1521): Caused by: java.lang.ClassNotFoundException: my.fragment.test.FragmentTestActivity in loader dalvik.system.PathClassLoader[/data/app/my.fragment.test-1.apk]
05-15 18:20:20.703: E/AndroidRuntime(1521): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-15 18:20:20.703: E/AndroidRuntime(1521): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-15 18:20:20.703: E/AndroidRuntime(1521): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-15 18:20:20.703: E/AndroidRuntime(1521): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-15 18:20:20.703: E/AndroidRuntime(1521): ... 11 more
05-15 18:20:23.423: I/Process(1521): Sending signal. PID: 1521 SIG: 9
SOLVED!!!! Who have this warnings before error:
05-16 10:08:00.033: W/dalvikvm(1695): Unable to resolve superclass of Lmy/fragment/test/FragmentTestActivity; (7)
05-16 10:08:00.076: W/dalvikvm(1695): Link of class 'Lmy/fragment/test/FragmentTestActivity;' failed
Should export android-support-v4 to right to your app:
Configure Java Build Path -> Order And Export tab -> set checkbox android-support-v4.jar
(Maybe need to remove existing one firstly)
it will moves this library to your apk (as I understand it)
You should have 1 FragmentActivity with fragments inside. What you are doing is trying to put activities (fragmentactivity) inside xml. That wont work. Try to only have 1 top level fragmentactivity and then make the other into fragments and then put those fragments inside your xml.
Since you are obviously just learning about this I'll expand on Warpzit's answer to try and help you out (you should accept his answer so he gets credit, since it is the correct one and he answered first).
This:
public class DetailsActivity extends FragmentActivity
Needs to be this:
public class DetailsActivity extends Fragment
As do any other tabs you want to display as part of that first activity.
There should only be one FragmentActivity unless you are going to start a second activity (and leave the first) that will also have fragments, then the same applies.
why do you have two activities named FragmentTestActivity? or is just writing error?
have you declared it in manifest?
Try to replace android:name="classpath" with class=""classpath.

Cannot run Android "Camera Preview" sample

The sample I'm referring to is: CameraPreview.
The program simply force closes upon start up. I've also tried other camera demos that have the same problem.
I'm trying to run the samples on my Nexus One and the emulator with the same problem on both. I'm not even sure if the emulator should be able to run them or not.
Based on LogCat, the error is:
06-08 16:39:10.483: ERROR/AndroidRuntime(6726): Uncaught handler: thread main exiting due to uncaught exception
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): java.lang.RuntimeException: Fail to connect to camera service
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.hardware.Camera.native_setup(Native Method)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.hardware.Camera.<init>(Camera.java:110)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.hardware.Camera.open(Camera.java:90)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.example.android.apis.graphics.Preview.surfaceCreated(CameraPreview.java:69)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.SurfaceView.updateWindow(SurfaceView.java:454)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.SurfaceView.dispatchDraw(SurfaceView.java:287)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.View.draw(View.java:6557)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.widget.FrameLayout.draw(FrameLayout.java:352)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.View.draw(View.java:6557)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.widget.FrameLayout.draw(FrameLayout.java:352)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewRoot.draw(ViewRoot.java:1349)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.os.Looper.loop(Looper.java:123)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at android.app.ActivityThread.main(ActivityThread.java:4363)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at java.lang.reflect.Method.invokeNative(Native Method)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at java.lang.reflect.Method.invoke(Method.java:521)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-08 16:39:10.494: ERROR/AndroidRuntime(6726): at dalvik.system.NativeStart.main(Native Method)
All I did to try out the sample was create a new Android 2.1update1 Project, named everything according to the supplied Java file, copied the Java file from the URL to the CameraPreview.java file, then run it. Am I supposed to do anything else?
Any help would be appreciated. Thanks in advance.
Add the following to your manifest, as children of the <manifest> element:
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />

Categories

Resources