Java Question B4A java compiler error with custom wrap

MarcelloCSI

Active Member
Licensed User
Hello there,

I'm trying to write a wrapper for a library that allow users to access NVR video data.
My java level is very very basic but the SLC compiled the library without errors.

B4A give me the following java error when i click compile:
B4X:
javac 1.8.0_111
src\com\csi\tvtWrapper\main.java:373: error: cannot find symbol
public static DvrSdkHelper _tvt = null;
              ^
  symbol:   class DvrSdkHelper
  location: class main
Note: src\com\csi\tvtWrapper\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
Do i have to write a contructor in the Java code?
This is my java wrapper class:
B4X:
import java.io.IOException;
import com.sdk.interfance.*;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;

@Version(1.0f)
@ShortName("DvrSdkHelper")
//@ActivityObject
//
public class DvrSdkHelper {
  
   public nvrsdk SdkInterface;
  
   private String _Username;
   private String _Password;
   private String _IP;
   private Short _Port;
   private String _sn;
   private int _UserID;
  
   private NET_SDK_DEVICEINFO _DeviceInfo;
   private int _ConnectType;
  
   private byte RetBytes[];
  
   public void Initialize(BA ba){
       /*_Username = username;
       _Password = password;
       _IP = ip;
       _Port = port;*/
       _sn = " ";
       _ConnectType = NET_SDK_CONNECT_TYPE.NET_SDK_CONNECT_TCP;
       _UserID = -1;
   }
  
  
//Properties
   public String getIP() {
       return _IP;
   }
   public void setIP(String value) {
       _IP = value;
   }
   public Short getPort() {
       return _Port;
   }
   public void setPort(Short value) {
       _Port = value;
   }
   public String getUsername() {
       return _Username;
   }
   public void setUsername(String value) {
       _Username = value;
   }
   public String getPassword() {
       return _Password;
   }
   public void setPassword(String value) {
       _Password = value;
   }
   public int getConnectType() {
       return _ConnectType;
   }
   public void setConnectType(int value) {
       _ConnectType = value;
   }
   //DeviceInfo Structure
   public NET_SDK_DEVICEINFO getDeviceInfo() {
       return _DeviceInfo;      
   }
  
//----------
  
   public boolean ConnectToNvr(BA ba) throws IOException {
      
       byte RetBytes[] = SdkInterface.LoginEx(_IP, _Port, _Username, _Password, _ConnectType, _sn, _UserID);
       //
       if(RetBytes == null)
       {
           //int errNo = SdkInterface.GetLastError();
           //Raise event with error number
           //RaiseError(ba, errNo);          
           return false;
       }
       else
       {
           _DeviceInfo = NET_SDK_DEVICEINFO.deserialize(RetBytes, 0);
           return true;
       }
   }
  
   public int GetLastError(BA ba)
   {
       return SdkInterface.GetLastError();
   }
  
   /*public void RaiseError(BA ba, int errorNumber)
   {
      
   }*/
  
   public byte[] getLoginResponse(BA ba) {
       return RetBytes;
   }
  
}
Android SDK is Android-28
JAVA is jdk1.8.0_111
 

MarcelloCSI

Active Member
Licensed User
After some changes i'm here, again, to ask your help. The library that i'm trying to wrap needs a link to many .so files that i have in the same directory of the jar file. B4A running app is telling me of a UnsatisfiedLinkError and i can't continue with anything. I read something about Gradle (that i don't know what exactly is) and about ReLinker (imported without success).

I'm using Eclipse to do this job and the following image is the project structure:
javaStructure.JPG


the file that is giving me the error is libH264Decode.so

This is the portion of code where i load the library:
B4X:
public void Initialize(BA ba){
        //Read H264Decode.so file
        System.loadLibrary("H264Decode");
        
        SdkInterface = nvrsdk.getInstance(SdkApp);
        SDKApplication.getInstance().setNvrSdk(SdkInterface);
        
        _sn = " ";
        _ConnectType = NET_SDK_CONNECT_TYPE.NET_SDK_CONNECT_TCP;
        _UserID = new Integer(-1);
        
    }
 

DonManfred

Expert
Licensed User
The library that i'm trying to wrap needs a link to many .so files that i have in the same directory of the jar file.
this is the wrong place.

The screenshot btw does show the correct path of the .so files... lib/arm64-v8a and lib/armeabi-v7a

Away from that i think you should NOT use a System.loadLibrary in your code. This should be already inside one of the jar files you are referencing.

Edit to add: NO, the path is wrong.

beside your src folder and lib folder you should have a folder additional and HERE the lib folder and subfolders should be.
 
Last edited:

MarcelloCSI

Active Member
Licensed User
this is the wrong place.

The screenshot btw does show the correct path of the .so files... lib/arm64-v8a and lib/armeabi-v7a

Away from that i think you should NOT use a System.loadLibrary in your code. This should be already inside one of the jar files you are referencing.

Edit to add: NO, the path is wrong.

beside your src folder and lib folder you should have a folder additional and HERE the lib folder and subfolders should be.
I'm becoming really mad with this job. Which folder whould be added?
Do you think that the .SO files is not copied into the APK or the path is wrong?
 

MarcelloCSI

Active Member
Licensed User
additional and all subfolders. lib

both
This is the error that continue to come up
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.csi.tvtWrapper-ITEghc71-vdJPPgOrrSInA==/base.apk"],nativeLibraryDirectories=[/data/app/com.csi.tvtWrapper-ITEghc71-vdJPPgOrrSInA==/lib/arm64, /system/lib64, /product/lib64]]] couldn't find "libH264Decode.so"

Really, i don't know where place the .so files to include them into the SimpleLibraryCompiler
 
Top