I've created an Android app that works perfectly on my device. I have sent over the APK to someone, and it worked on his device also.
At one point, he wanted to modify something in the app. So I sent him over the complete source code.
Now he is telling me that the source code does not work for him. It compiles fine, but when it runs it from within Eclipse it crashes.
I am 100% sure I have sent him the correct code, that works fine for me. Apparently there is no reason for the crash.
I asked him to send me the logcat errors and I don't seem to find the problem.
Here it is (part of it):
05-06 08:56:10.954: D/dalvikvm(266): GC_FOR_ALLOC freed 2720K, 13% free 27384K/31239K, paused 40ms, total 42ms
05-06 08:56:11.224: D/dalvikvm(266): GC_FOR_ALLOC freed 4048K, 21% free 24747K/31239K, paused 35ms, total 37ms
05-06 08:56:11.224: I/dalvikvm-heap(266): Forcing collection of SoftReferences for 3785616-byte allocation
05-06 08:56:11.284: D/dalvikvm(266): GC_BEFORE_OOM freed 31K, 21% free 24715K/31239K, paused 54ms, total 54ms
05-06 08:56:11.284: E/dalvikvm-heap(266): Out of memory on a 3785616-byte allocation.
05-06 08:56:11.284: I/dalvikvm(266): "main" prio=5 tid=1 RUNNABLE
05-06 08:56:11.284: I/dalvikvm(266): | group="main" sCount=0 dsCount=0 obj=0x2bc9b568 self=0x55569be0
05-06 08:56:11.284: I/dalvikvm(266): | sysTid=266 nice=0 sched=0/0 cgrp=apps handle=716000068
05-06 08:56:11.284: I/dalvikvm(266): | schedstat=( 4120000000 11950000000 1161 ) utm=335 stm=77 core=0
05-06 08:56:11.294: I/dalvikvm(266): at android.graphics.Bitmap.nativeCreate(Native Method)
05-06 08:56:11.294: I/dalvikvm(266): at android.graphics.Bitmap.createBitmap(Bitmap.java:640)
05-06 08:56:11.294: I/dalvikvm(266): at android.graphics.Bitmap.createBitmap(Bitmap.java:620)
05-06 08:56:11.294: I/dalvikvm(266): at com.android.launcher2.Cling.dispatchDraw(Cling.java:208)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.buildDrawingCache(View.java:12717)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13154)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13461)
05-06 08:56:11.294: I/dalvikvm(266): at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13342)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2806)
05-06 08:56:11.294: I/dalvikvm(266): at com.android.launcher2.DragLayer.dispatchDraw(DragLayer.java:743)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13461)
05-06 08:56:11.294: I/dalvikvm(266): at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13342)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13340)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13340)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.View.draw(View.java:13461)
05-06 08:56:11.294: I/dalvikvm(266): at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-06 08:56:11.294: I/dalvikvm(266): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2183)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2258)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2153)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2021)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1832)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.Choreographer.doFrame(Choreographer.java:525)
05-06 08:56:11.294: I/dalvikvm(266): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-06 08:56:11.294: I/dalvikvm(266): at android.os.Handler.handleCallback(Handler.java:615)
05-06 08:56:11.294: I/dalvikvm(266): at android.os.Handler.dispatchMessage(Handler.java:92)
05-06 08:56:11.294: I/dalvikvm(266): at android.os.Looper.loop(Looper.java:137)
05-06 08:56:11.294: I/dalvikvm(266): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-06 08:56:11.294: I/dalvikvm(266): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 08:56:11.294: I/dalvikvm(266): at java.lang.reflect.Method.invoke(Method.java:511)
05-06 08:56:11.294: I/dalvikvm(266): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-06 08:56:11.294: I/dalvikvm(266): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-06 08:56:11.294: I/dalvikvm(266): at dalvik.system.NativeStart.main(Native Method)
05-06 08:56:11.294: D/AndroidRuntime(266): Shutting down VM
05-06 08:56:11.294: W/dalvikvm(266): threadid=1: thread exiting with uncaught exception (group=0x2bc9a300)
05-06 08:56:11.334: E/AndroidRuntime(266): FATAL EXCEPTION: main
05-06 08:56:11.334: E/AndroidRuntime(266): java.lang.OutOfMemoryError
05-06 08:56:11.334: E/AndroidRuntime(266): at android.graphics.Bitmap.nativeCreate(Native Method)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.graphics.Bitmap.createBitmap(Bitmap.java:640)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.graphics.Bitmap.createBitmap(Bitmap.java:620)
05-06 08:56:11.334: E/AndroidRuntime(266): at com.android.launcher2.Cling.dispatchDraw(Cling.java:208)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.buildDrawingCache(View.java:12717)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13154)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13461)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13342)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2806)
05-06 08:56:11.334: E/AndroidRuntime(266): at com.android.launcher2.DragLayer.dispatchDraw(DragLayer.java:743)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13461)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13342)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13340)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13340)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.View.draw(View.java:13461)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.widget.FrameLayout.draw(FrameLayout.java:467)
05-06 08:56:11.334: E/AndroidRuntime(266): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2183)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2258)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2153)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2021)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1832)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.Choreographer.doFrame(Choreographer.java:525)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.os.Handler.handleCallback(Handler.java:615)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.os.Handler.dispatchMessage(Handler.java:92)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.os.Looper.loop(Looper.java:137)
05-06 08:56:11.334: E/AndroidRuntime(266): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-06 08:56:11.334: E/AndroidRuntime(266): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 08:56:11.334: E/AndroidRuntime(266): at java.lang.reflect.Method.invoke(Method.java:511)
05-06 08:56:11.334: E/AndroidRuntime(266): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-06 08:56:11.334: E/AndroidRuntime(266): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-06 08:56:11.334: E/AndroidRuntime(266): at dalvik.system.NativeStart.main(Native Method)
05-06 08:56:11.346: W/ActivityManager(152): Force finishing activity com.android.launcher/com.android.launcher2.Launcher
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: E/libEGL(36): called unimplemented OpenGL ES API
05-06 08:56:11.449: W/WindowManager(152): Failure taking screenshot for (266x425) to layer 21005
05-06 08:56:11.954: W/ActivityManager(152): Activity pause timeout for ActivityRecord{2c584740 com.android.launcher/com.android.launcher2.Launcher}
05-06 08:56:11.954: I/ActivityManager(152): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher u=0} from pid 0
05-06 08:56:22.035: W/ActivityManager(152): Activity idle timeout for ActivityRecord{2c57af08 com.android.launcher/com.android.launcher2.Launcher}
The problem you are having is a pretty usual one: your app is running out of memory when it's trying to allocate space for a Bitmap you're using.
There are some techniques you can look up at the Google documentation site for Android programmers. For instance Managing Bitmap Memory.
To avoid the error, this is a pretty good function (again, from Google docs):
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// Calculate ratios of height and width to requested height and width
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// Choose the smallest ratio as inSampleSize value, this will guarantee
// a final image with both dimensions larger than or equal to the
// requested height and width.
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
}
What is does is:
Verify the height and width of your Bitmap without actually loading it into memory
Adjust the sampling size so it fits into memory but keeps the required dimensions
Try to increase VM Heap memory in AVD as 64.
In menu select
Window => Android Virtual Device Manager => select avd which you use => click on edit button.
In old Version of ADT.
In new Version of ADT.
When you create new AVD it takes 24 VM Heap as default. but your application need to more memory so, you set it as 64.
Related
I am restarting the activity after updating some fields through api call, after 10-15 continuous updates it is giving an exception as below :
05-06 17:12:55.412: E/SurfaceFlinger(115): GraphicBufferAlloc::createGraphicBuffer(w=1232, h=800) failed (Out of memory), handle=0x0
05-06 17:12:55.412: E/BufferQueue(115): [com.ht.coremoney/com.ht.coremoney.cards.TransactionFullDetailActivity] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
05-06 17:12:55.420: E/libEGL(1350): eglMakeCurrent:534 error 3003 (EGL_BAD_ALLOC)
05-06 17:12:55.428: E/ViewRootImpl(1350): OutOfResourcesException initializing HW surface
05-06 17:12:55.428: E/ViewRootImpl(1350): android.view.Surface$OutOfResourcesException: eglMakeCurrent failed EGL_BAD_ALLOC
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.HardwareRenderer$GlRenderer.createEglSurface(HardwareRenderer.java:920)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:748)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1621)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4464)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.Choreographer.doFrame(Choreographer.java:525)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.os.Handler.handleCallback(Handler.java:615)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.os.Handler.dispatchMessage(Handler.java:92)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.os.Looper.loop(Looper.java:137)
05-06 17:12:55.428: E/ViewRootImpl(1350): at android.app.ActivityThread.main(ActivityThread.java:4895)
05-06 17:12:55.428: E/ViewRootImpl(1350): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 17:12:55.428: E/ViewRootImpl(1350): at java.lang.reflect.Method.invoke(Method.java:511)
05-06 17:12:55.428: E/ViewRootImpl(1350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
05-06 17:12:55.428: E/ViewRootImpl(1350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
05-06 17:12:55.428: E/ViewRootImpl(1350): at dalvik.system.NativeStart.main(Native Method)
05-06 17:12:55.428: E/android.os.Debug(1350): !#Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_surfaceoom
Kindly suggest me the solution.
Let's analyse what this says:
GraphicBufferAlloc::createGraphicBuffer(w=1232, h=800) failed (Out of memory)
You seem to allocate a native buffer, 985600 pixels. If they use a 32-bit color format, that's 3.94 MB of memory. Taking into account that you do this 10 to 15 times, you allocate up to 59.14 MB of memory, far too much for most devices.
My guess is that you forgot to actually free these buffers, therefore wasting lots of memory.
When using native code, your memory is only freed when your process is killed, not when the activity is restarted. Therefore, your code allocates a new buffer every time the activity is started. You should either free when the activity closes or reuse the already allocated buffer.
Let's understand Exception and Error in java.
In your situation you got an error by doing something wrong you can't handle or manage It like exception,
That's mean you need to analyze you memory management of your Application..
By the using the eclipse Memory Analyzer tools.
It's plugged in already with Android ADT.
Here are link for using memory
Analyzer.
http://www.vogella.com/tutorials/EclipseMemoryAnalyzer/article.html
http://android-developers.blogspot.in/2011/03/memory-analysis-for-android.html?m=1
I know it's not your direct solution but with the help of this tool you can analyze your all memory leakage and try to reuse your preallocated buffer ,
And android is also recommend that's do not use very complex layouting in a or heavy nested layouting in single layout, instead of all this you can break up all complex layout into sm fragments.
Hope this information help you.
I have this exception:
java.lang.NullPointerException
at android.webkit.WebViewClassic.requestFocus(WebViewClassic.java:10003)
at android.webkit.WebView.requestFocus(WebView.java:2133)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2382)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2338)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2382)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2338)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2382)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2341)
at android.view.View.requestFocus(View.java:6538)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1899)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1110)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4918)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
But it doesn't tell me what line it happened on or anything else. Any idea how to debug this?
Thanks,
Alex
I am using iText library for generate new pdf in my app. but my question is how can i use not embedded fonts in program? I'll try this code but its not working for me.
FONTS = "assets/Zapfino.ttf"
BaseFont bf = BaseFont.createFont(FONTS,"CP1251", BaseFont.EMBEDDED);
font = new Font(bf,18);
Paragraph pr = new Paragraph(p12,font);
document.add(pr);
and giv error this
05-06 10:08:31.740: W/System.err(1129): com.itextpdf.text.DocumentException: assets/Zapfino.ttf cannot be embedded due to licensing restrictions.
05-06 10:08:31.740: W/System.err(1129): at com.itextpdf.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:371)
05-06 10:08:31.740: W/System.err(1129): at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:699)
05-06 10:08:31.740: W/System.err(1129): at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:615)
05-06 10:08:31.740: W/System.err(1129): at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:450)
05-06 10:08:31.740: W/System.err(1129): at com.example.pdfformate.MainActivity.createPdf(MainActivity.java:108)
05-06 10:08:31.740: W/System.err(1129): at com.example.pdfformate.MainActivity.access$0(MainActivity.java:90)
05-06 10:08:31.750: W/System.err(1129): at com.example.pdfformate.MainActivity$1.onClick(MainActivity.java:74)
05-06 10:08:31.750: W/System.err(1129): at android.view.View.performClick(View.java:2485)
05-06 10:08:31.750: W/System.err(1129): at android.view.View$PerformClick.run(View.java:9080)
05-06 10:08:31.750: W/System.err(1129): at android.os.Handler.handleCallback(Handler.java:587)
05-06 10:08:31.750: W/System.err(1129): at android.os.Handler.dispatchMessage(Handler.java:92)
05-06 10:08:31.750: W/System.err(1129): at android.os.Looper.loop(Looper.java:123)
05-06 10:08:31.750: W/System.err(1129): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-06 10:08:31.750: W/System.err(1129): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 10:08:31.750: W/System.err(1129): at java.lang.reflect.Method.invoke(Method.java:507)
05-06 10:08:31.750: W/System.err(1129): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-06 10:08:31.750: W/System.err(1129): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-06 10:08:31.750: W/System.err(1129): at dalvik.system.NativeStart.main(Native Method)
Any help?
I am trying to generate a dynamic table problematically It's working properly above API > 11 but its showing some error like this
05-06 12:35:30.303: E/AndroidRuntime(386): FATAL EXCEPTION: main
05-06 12:35:30.303: E/AndroidRuntime(386): java.lang.NoClassDefFoundError: android.app.ActionBar$LayoutParams
05-06 12:35:30.303: E/AndroidRuntime(386): at com.ica.icacounselor.Follow_ups_list_third_level.populateTable(Follow_ups_list_third_level.java:105)
05-06 12:35:30.303: E/AndroidRuntime(386): at com.ica.icacounselor.Follow_ups_list_third_level.onCreate(Follow_ups_list_third_level.java:65)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.os.Looper.loop(Looper.java:123)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-06 12:35:30.303: E/AndroidRuntime(386): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 12:35:30.303: E/AndroidRuntime(386): at java.lang.reflect.Method.invoke(Method.java:507)
05-06 12:35:30.303: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-06 12:35:30.303: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-06 12:35:30.303: E/AndroidRuntime(386): at dalvik.system.NativeStart.main(Native Method)
My code follows
//--------------------------------------------------------------------------------------------------
// Creating Table Header
//--------------------------------------------------------------------------------------------------
TableRow followup_tr_head = new TableRow(this);
followup_tr_head.setId(10);
followup_tr_head.setBackgroundResource(R.drawable.list_header);
followup_tr_head.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
final TextView time_name_title = new TextView(this);
time_name_title.setId(20);
time_name_title.setText("Time");
time_name_title.setTextColor(Color.WHITE);
time_name_title.setPadding(5,5,5,5);
followup_tr_head.addView(time_name_title);// add the column to the table row here
time_name_title.setTextSize(12);
final TextView student_name_title = new TextView(this);
student_name_title.setId(20);
student_name_title.setText("Student Name");
student_name_title.setTextColor(Color.WHITE);
student_name_title.setPadding(5,5,5,5);
followup_tr_head.addView(student_name_title);// add the column to the table row here
student_name_title.setTextSize(12);
the ActionBar is presented in API 11. You can't use it in lower API levels.
Yes you can't use ActionBar below API level 11.
To use actionbar in lower api levels use ActionBarSherlock
I had imported import android.app.ActionBar.LayoutParams;
I should import android.widget.TableRow.LayoutParams;
Just received the below crash report on the Android dev console, however it doesn't hit my code and reports doesn't show Android version:
Checked source code for 4.1.x and 4.0.x, line 345 is this and length() is defined in an interface:
return getText().length();
How could this actually be missing? I'm assuming I've used a setText() on something and it's not ok, but do I investigate, while I've no clue where it's actually happening!?
java.lang.IncompatibleClassChangeError: interface not implemented
at android.text.BoringLayout.getLineStart(BoringLayout.java:345)
at android.text.Layout.drawText(Layout.java:229)
at android.text.Layout.draw(Layout.java:205)
at android.text.BoringLayout.draw(BoringLayout.java:400)
at android.widget.TextView.onDraw(TextView.java:4886)
at android.view.View.draw(View.java:13470)
at android.view.View.draw(View.java:13354)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13352)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13352)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13575)
at android.widget.FrameLayout.draw(FrameLayout.java:467)
at android.widget.ScrollView.draw(ScrollView.java:1569)
at android.view.View.draw(View.java:13354)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13352)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13352)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13352)
at android.view.ViewGroup.drawChild(ViewGroup.java:2929)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
at android.view.View.draw(View.java:13473)
at android.widget.FrameLayout.draw(FrameLayout.java:467)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2185)
at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2258)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2153)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2021)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1832)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4899)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
This could possibly be due to change in library that android.text.BoringLayout is a part of. May be the interfaces that class implements have changed it's method signature or have added new methods or have changed it's accessibility rights (public protected private).
The devices this might be happening on may be hosting custom roms developed by independent users with different definitions given to one of the interfaces implemented by BinaryLayout or one of it's superclasses.
A backward binary compatibility case