Android Question Problem with CropImageView V1.0

Yayou49

Active Member
Licensed User
Hi,

I'm trying to use this library to rotate a picture.

As describe in example, I declare my crop:

B4X:
Dim civ As CropImageView
Dim b As Bitmap
b.Initialize(File.DirRootExternal,"1.jpg")
civ.ImageBitmap = b

But on line "civ.ImageBitmap" system tell me:

B4X:
java.lang.RuntimeException: Object should first be initialized (CropImageView).

I've tried with:

B4X:
Dim civ As CropImageView
   civ.Initialize("Photo")
   Dim b As Bitmap
   b.Initialize(File.DirRootExternal,"1.jpg")
   civ.ImageBitmap = b

But still an error:

B4X:
android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.Resources.getValue(Resources.java:1351)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2774)
    at android.content.res.Resources.getLayout(Resources.java:1165)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
    at com.edmodo.cropper.CropImageView.init(CropImageView.java:473)
    at com.edmodo.cropper.CropImageView.<init>(CropImageView.java:78)
    at de.donmanfred.CropImageViewWrapper._initialize(CropImageViewWrapper.java:56)
    at de.donmanfred.CropImageViewWrapper.Initialize(CropImageViewWrapper.java:49)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:747)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:839)
    at ANOVO.V1.cameraexclass._camera_picturetaken(cameraexclass.java:213)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA$1.run(BA.java:293)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Any idea ????
Thanks in advance.
 

mangojack

Well-Known Member
Licensed User
Longtime User
These are two separate error's ..

has the CIV been added with designer ? Have you loaded the Layout containing the CIV ? (As per CIV Example)
You only need to initialize the view if you have added it to the Activity manually .. (again as per the comments in the example)
 
Upvote 0

Yayou49

Active Member
Licensed User

Hi Mango,
You are right !
I thought civ was an object an not a view ......
So I've added a view into my layout but I'm facing a new problem while trying to load Layout:
(Activity.LoadLayout("Photo"))

B4X:
Error occurred on line: 30 (Photo)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:208)
    at ANOVO.V1.photo._activity_create(photo.java:368)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at ANOVO.V1.photo.afterFirstLayout(photo.java:102)
    at ANOVO.V1.photo.access$000(photo.java:17)
    at ANOVO.V1.photo$WaitForLayout.run(photo.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 18 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.Resources.getValue(Resources.java:1351)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2774)
    at android.content.res.Resources.getLayout(Resources.java:1165)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
    at com.edmodo.cropper.CropImageView.init(CropImageView.java:473)
    at com.edmodo.cropper.CropImageView.<init>(CropImageView.java:78)
    at de.donmanfred.CropImageViewWrapper._initialize(CropImageViewWrapper.java:56)
    ... 21 more
** Activity (photo) Resume **

Reflection libray is already loaded in my project.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Firstly .. What are you trying to ? Rotate a bitmap / image ? ... Did you see @Erel 's comment at post #3 ?

Also it should be .. Activity.LoadLayout("Photo") is 'Photo' the name of your layout & Activity?

I do not understand the error message .. Where does Reflection lib come in to play ?

Maybe it might be better to describe exactly what you are trying to do .. And upload your project sample .. IDE >File>Export as Zip

- (If It is more than just rotate a bitmap and @Erel 's suggestion does not work for you.)
 
Upvote 0

Yayou49

Active Member
Licensed User
I will try Erel's solution
I've just bought the last B4A version.
Unfortunately, I have a bug with this new version....
I keep in touch with Erel to know what's happen.

Anyway, thanks for your help and care.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…