Java Question Trying to alter and recompile the Camera2 library

CyberDroidWare

Member
Licensed User
What? He posted the link to the real source and than reverse engineered the library?

Ohh, too bad... Based on #1 i thought he was using erels source from github :-(
No, not at all - I downloaded Erel's source and simply tried to compile it again. I am using Erel's source from github!
 

agraham

Expert
Licensed User
Longtime User
Ohh, too bad... Based on #1 i thought he was using erels source from github :-(
He is but the problem (assuming that I am right of course) is in the transpiled B4A code caused by the contents of the newly generated xml file and is nohing to do with the library source - which being Erel's is of course without peer :)
 

CyberDroidWare

Member
Licensed User
He is but the problem (assuming that I am right of course) is in the transpiled B4A code caused by the contents of the newly generated xml file and is nohing to do with the library source - which being Erel's is of course without peer :)
So I'm trying your suggestion and using JDK 8.
 

CyberDroidWare

Member
Licensed User
To help, I thought I would add on here the exact files as compiled. Changing to jdk8 made no difference. Yes, in the manifest it does incorrectly say:

<parameter>
<name>Surface</name>
<type>TextureView</type>
</parameter>

I just don't get it, I have used LibraryCompiler to compile the exact Camera2.java file on Github.

The source .java file, and the SimpleLibraryCompiler output files are attached. I expected I would be able to just override Camera2.jar and Camera2.xml in the B4A libraries folder, but the VideoRecordExample will not compile with these files, giving the error about the TextureView.
 

Attachments

  • Camera2.jar
    11.5 KB · Views: 263
  • Camera2.xml
    8.4 KB · Views: 288
  • Camera2.java
    15.5 KB · Views: 277

agraham

Expert
Licensed User
Longtime User
Changing to jdk8 made no difference.
Camera2.java compiles fine for me under jdk8 with the correct full type in the resulting xml. How have you changed to jdk8? How have you overridden the existing Camera2 files? I just compiled to a new library, Camera2x.
 

CyberDroidWare

Member
Licensed User
Camera2.java compiles fine for me under jdk8 with the correct full type in the resulting xml. How have you changed to jdk8? How have you overridden the existing Camera2 files? I just compiled to a new library, Camera2x.
Really, I wish that would work for me. Here is exactly what I did.

1. Download the Camera2.java file from the link in post #1 provided by Erel.

2. Create on my desktop a folder structure called ..\c2\src\

3. Place the Camera2.java in that directory.

4. Go to library compiler and set the first 3 text fields to:

a) C:\users\myusername\Desktop\c2
b) Camera2
c) (I keep this the default -b4aignore)

5. I then made sure I downloaded the jdk-8u261-windows-x64.exe and ran it.

6. In B4A, in Configure Paths, in the javac.exe box, I enter the new C:\Program Files\Java\jdk1.8.0_261\bin\javac.exe

7. Note, when I compile using LibraryCompiler, I receive the message in my previous post about 50 warnings, yet it compiles and places the new Camera2.jar and Camera2.xml file in the Additional Libraries path I have set in B4A.

8. These are the exact attached files in my previous post.

9. I know it used jdk 8, because when I compiled it, on first time, windows firewall prompted me to allow the new compiler.

10. I then copy the 2 files as created and posted in my previous post, and Override the Camera2.jar and Camera2.xml in the c:\program files (x86)\anywhere software\basic4android\libraries folder.

11. I refresh the libraries, and check, uncheck and recheck the Camera2 library in the Video Recorder sample that is available here: https://www.b4x.com/android/forum/threads/camera2-new-camera-library.83855/

12. I get the errors as per previous post on trying to compile.

a) could you kindly send me your 2 files for your camera2x library so I can test it out?

b) can you kindly advise me what I might be doing wrong as above?

c) I have a feeling I should be placing the .java file in a proper src path, but what should I use, /src/b4a/com/camera2/ ??

d) do you get the sample camera app erroring when you use my 2 files outputted from library compiler in my previous post?

Really appreciate your help!
S
 

agraham

Expert
Licensed User
Longtime User
10. I then copy the 2 files as created and posted in my previous post, and Override the Camera2.jar and Camera2.xml in the c:\program files (x86)\anywhere software\basic4android\libraries folder.
This means nothing to me. As I asked before. " How have you overridden the existing Camera2 files? ".

This is how I compile libraries, just double click CompileCamera2x.bat.
 

Attachments

  • Libraries.zip
    140.2 KB · Views: 256
  • Camera2x.xml
    8.4 KB · Views: 283
  • Camera2x.jar
    11.5 KB · Views: 266

CyberDroidWare

Member
Licensed User
Perhaps you mean "overwrite""?
It is not necessary or desirable to overwrite standard libraries. Give the library a different name and let SLC put it in your additional libraries folder.
Spot on, overwrite. Yes, of course I will change the name, I just wanted to change as little as possible. I made backups of the standard libraries. Why it didn't work, is a bit of a mystery. Thanks heaps.
 

agraham

Expert
Licensed User
Longtime User
@Erel
If you have been following this B4ADoclet is still broken with Java 11 as per our email interchange of 19 June 2019. Any plans to fix it?
My own notes on using Java 11 at that time included
"The XML gnerated by BADoclet was twice the size it should be, included stuff that shouldn't be there, omitted Enum return type declarations and shortened type names."
 
Last edited:
Top