[Android-development] JNI problem with nested classes
dant3
blinov.vyacheslav at gmail.com
Mon Dec 2 20:37:39 CET 2013
On Пн., 2013-12-02 at 13:17 +0000, Stromme Christian wrote:
> On 02 Dec 2013, at 08:19 , Denis Kormalev <kormalev.denis at gmail.com> wrote:
>
> > Hi all,
> >
> > I'm looking now at camera at android and found crash there when I try to set
> > custom focus area. Small research showed me that it crashes with message
> > dvmFindClassByName rejecting 'android/hardware/Camera$Area'
> >
>
> That seems strange, this indicates that the class name is wrong or that the class name is
> not converted to the correct format. It might be related to your android version, in which case we need
> to add some changes to the classLoader code. I have created a bug report[1] could you add
> information about your android version and device there? (Alternatively just replay here and
> I’ll update the bug report :)
>
>
> > It occures in static function areaToRect() in jcamera.cpp. What is more
> > interesting - there is another JNI call, but to normal class, not nested one
> > (android.graphics.Rect) which is before call to android.hardware.Camera.Area.
> >
>
> The signature of the rect field is wrong, so that might be the core issue of the crash.
>
> > I've tried to do next stuff:
> > 1. Add class resolving to initJNI() method and use jclass instead of string
> > 2. Get jclass instance just before this call in areaToRect() function and pass
> > it instead of string
> >
> > Both solutions worked, but I'm sure they are not correct ones (they looks more
> > like workaround than like robust solutions).
> >
> > As I understand - problem is in getCachedClass() function in qjni.cpp which
> > uses classLoader instead of FindClass() jni function (I believe it was done
> > for special purpose but looks like it can be a cause for this problem).
> >
> > Any ideas or comments? Or I just do something wrong?
> >
>
> I don’t think your doing anything wrong, but I suspect that there is an issue with the the class name resolution, this should not
> be fatal as there are fallback paths, but I need to look into it.
>
> > --
> > Regards,
> > Denis Kormalev
> >
> > _______________________________________________
> > Android-development mailing list
> > Android-development at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/android-development
>
>
> [1] https://bugreports.qt-project.org/browse/QTBUG-35298
>
> —
> Christian
> _______________________________________________
> Android-development mailing list
> Android-development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/android-development
I confirm Cristian's version.
android.hardware.Camera.Area inner class exists only on API Level 14+
(that is Android 4.+), so trying to load it on the earlier Android
versions will lead to exception for sure.
More information about the Android-development
mailing list