Java Question Create B4A Library

Create library Problem

  • yes

    Votes: 4 100.0%
  • yes

    Votes: 3 75.0%

  • Total voters
    4

Hakanunver

Member
Licensed User
Hello We Try Create B4A library for portsip sdk. This sdk link :
http://www.portsip.com/sites/downloads/sdk/AndroidSample_Eclipse.zip

We try eclipse and SLC , we get similar errors.

Where our mistake dont understand.. This Library very importand for as.

our simple test code:

B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName: 
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim portsip As PortSip

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    portsip.Initialize_Sip("333","zkr333","192.168.1.233",5222)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

And our Java code :
B4X:
package com.portsiplib;

import com.portsip.PortSipSdk;
import android.content.Context;
import anywheresoftware.b4a.BA.ShortName;
@ShortName("PortSip")
public class PortSip {
        static{
            System.loadLibrary("portsip_core");
            System.loadLibrary("portsip_media");
        }
    public String Initialize_Sip(String username,String password,String server,int port){
   
        PortSipSdk sdk = new PortSipSdk();
   
        return "RUN";
    }

}

Our Errors :



java.lang.RuntimeException: Unable to create service b4a.example.starter: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2373)
at android.app.ActivityThread.access$1600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at b4a.example.starter.onCreate(starter.java:37)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2363)
... 10 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at b4a.example.starter.onCreate(starter.java:35)
... 11 more
Caused by: java.lang.ExceptionInInitializerError
at b4a.example.main._process_globals(main.java:367)
at b4a.example.main.initializeProcessGlobals(main.java:357)
... 14 more
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load portsip_core: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.portsiplib.PortSip.<clinit>(PortSip.java:9)
... 16 more


And SLC logs :



Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
Loading source file C:\Users\hakanunver\Desktop\SimpleLibraryCompiler\PortSip\src\com\example\PortSip.java...
Constructing Javadoc information...
[-doclet, BADoclet]
[-docletpath, C:\Users\hakanunver\Desktop\SimpleLibraryCompiler]
[-doclet, BADoclet]
[-docletpath, C:\Users\hakanunver\Desktop\SimpleLibraryCompiler]
[-bootclasspath, C:\Users\hakanunver\AppData\Local\Android\sdk\platforms\android-23\android.jar]
[-classpath, C:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\B4AShared.jar;C:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\Core.jar;C:\Users\hakanunver\Desktop\SimpleLibraryCompiler\PortSip\libs\portsipvoipsdk.jar;]
[-sourcepath, src]
[-b4atarget, C:\Users\hakanunver\Desktop\aaaa\PortSip.xml]
[-b4aignore, org.com.android.com.portsip.com.portsip]
Ignoring: [org.com.android.com.portsip.com.portsip]
starting....
Working with class: com.portsiplib.PortSip
finish: C:\Users\hakanunver\Desktop\aaaa\PortSip.xml

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***

 

Hakanunver

Member
Licensed User
Hello Erel
this sdk one jar files..bin jar file have 2 jar files and 2 so library..

we try your post but same problem.. why we impossible create library. don understant... please help as.. for as very important..
 

Hakanunver

Member
Licensed User
Hello Erel
I attached file structure..
I try and try but same Errors. Please help..

B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName: 
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
Private dfg As PortSip
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim a As Int
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
a = dfg.initialize
Log (a)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Java Errors :



** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: com.portsip.PortSipSdk
at com.sipsdk.initalize.initialize(initalize.java:10)
at b4a.example.main._activity_create(main.java:377)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **


 

Attachments

  • eclipse.png
    107 KB · Views: 334

Hakanunver

Member
Licensed User
Hello Erel
I build With SLC..



[-classpath, C:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\B4AShared.jar;C:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\Core.jar;C:\Users\hakanunver\workspace\SipSdk\libs\android-support-v4.jar;C:\Users\hakanunver\workspace\SipSdk\libs\portsipvoipsdk.jar;]
[-sourcepath, src]
[-b4atarget, C:\Users\hakanunver\Desktop\aaaa\PortSip.xml]
starting....
Working with class: com.sipsdk.initalize
finish: C:\Users\hakanunver\Desktop\aaaa\PortSip.xml

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***


But same Errors.. I Open jar file fron SLC file structure is attached.

Errors:

java.lang.NoClassDefFoundError: com.portsip.PortSipSdk
 

Attachments

  • file1.png
    3.6 KB · Views: 342
  • file2.png
    9.1 KB · Views: 341
  • file3.png
    5.8 KB · Views: 333

DonManfred

Expert
Licensed User
Longtime User
import com.portsip.PortSipSdk;
you need to add an dependson for the jar you are refering to (which you use inside you pojects libs folder...

B4X:
@DependsOn(values={"portsipfilename"})
if it is portsipfilename.jar
 

deantangNYP

Active Member
Licensed User
Longtime User

Hi Hakanunver,
I wish to try PortSip too, can you share the library and an example in b4a? sadly, i am not a java user. Appreciate your help. Thanks.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…