Sunday, April 29, 2012

[android-developers] Re: Strange force close on Froyo phone, works fine on ICS tablet

java.lang.NoSuchFieldError: android.graphics.PorterDuff$Mode.ADD

it is telling Mode.ADD is not exists in 2.2
On Sunday, April 29, 2012 12:45:34 PM UTC-4, Spooky wrote:
The following code (which works fine earlier in the app on both devices)
causes a force close (logcat below) on my Froyo phone (Motorola Bravo
MB520), and works fine on my ICS tablet (Acer Iconia A500):

---------------------------  CUT HERE  ---------------------------
Canvas canvas = new Canvas(saveme);
Paint paint = new Paint();

canvas = new Canvas(saveme);
paint = new Paint();
canvas.drawBitmap(image, 0, 0, paint);
// the following is line 1071...the source of the exception/error
paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.ADD));
canvas.drawBitmap(filter, 0, 0, paint);
---------------------------  CUT HERE  ---------------------------

And here's the error in logcat:

---------------------------  CUT HERE  ---------------------------
D/AndroidRuntime(3550): Shutting down VM
W/dalvikvm(3550): threadid=1: thread exiting with uncaught exception (group=0x400208b0)
E/AndroidRuntime(3550): FATAL EXCEPTION: main
E/AndroidRuntime(3550): java.lang.NoSuchFieldError: android.graphics.PorterDuff$Mode.ADD
E/AndroidRuntime(3550):    at com.jdgapps.UltraCamPro.UltraCamPro$1.onPictureTaken(UltraCamPro.java:1071)
E/AndroidRuntime(3550):    at android.hardware.Camera$EventHandler.handleMessage(Camera.java:330)
E/AndroidRuntime(3550):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(3550):    at android.os.Looper.loop(Looper.java:143)
E/AndroidRuntime(3550):    at android.app.ActivityThread.main(ActivityThread.java:4717)
E/AndroidRuntime(3550):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(3550):    at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(3550):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(3550):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(3550):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(1321):   Force finishing activity com.jdgapps.UltraCamPro/.UltraCamPro
 ---------------------------  CUT HERE  ---------------------------
 
On my tablet, it doesn't throw an error, and continues on to create the
final image, save it, and return to the camera preview.  Note that this
very same Porterduff code works fine earlier in the app (also blending
two bitmaps---different variable names...only difference), and also WAS
working at this point previously (before a name change, some unused
imports removed, two[1] that Eclipse said were unused replaced because
Eclipse complained when they weren't there after I removed them because
Eclipse said they weren't used).  Oh, one more change:  Target SDK
stepped up from Android 3.2.1 to Android 4.0.3, min SDK stayed at Android
2.2.1.  Tablet also changed from Android 3.2.1 to 4.0.3.

Can anyone help explain this mystery?

Thanks,
   --jim


[1] android.graphics.PorterDuff and android.graphics.PorterDuff.Mode

--
THE SCORE:  ME:  2  CANCER:  0
73 DE N5IAL (/4)        | Peter da Silva:  No, try "rm -rf /"
spooky130u@gmail.com    | Dave Aronson:    As your life flashes before
< Running FreeBSD 7.0 > |      your eyes, in the unit of time known as an
ICBM / Hurricane:       |      ohnosecond....     (alt.sysadmin.recovery)
   30.44406N 86.59909W  |

Android Apps Listing at http://www.jstrack.org/barcodes.html

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment