Java Question create lib error

icefairy333

Active Member
Licensed User
Longtime User
I was create a lib with eclipse but it didn't work!I had watch the tutorial video on the youtube.here is the javacode
B4X:
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

@ShortName("mylibc")
@Version(1.0F)
 /**
  * 
  * @author Icefairy
  *
  */
public class mylibclass {
   /**
    * 
    * @param a 要操作的参数
    * @return 返回乘以3后的结果
    */
public int mycall(int a) {
   a=a*3;
   return a;
}
}
here is the b4a code for call it:
B4X:
'Activity module
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.
   Dim a As mylibc
End Sub

Sub Activity_Create(FirstTime As Boolean)
Log(a.mycall(13))

Activity.Finish
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
and this is the error of compile:
B4X:
Compiling code.                         0.00
Compiling layouts code.                 0.02
Generating R file.                      0.00
Compiling generated Java code.          Error
javac 1.7.0
src\ice\apk\main.java:205: 错误: 找不到符号
public mylibclass _a = null;
       ^
  符号:   类 mylibclass
  位置: 类 main
1 个错误
the xml file:
B4X:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <doclet-version-NOT-library-version>1.02</doclet-version-NOT-library-version>
    <class>
        <name>mylibclass</name>
        <shortname>mylibc</shortname>
        <owner>process</owner>
        <method>
            <name>mycall</name>
            <comment>
a: 要操作的参数
Return type: @return:返回乘以3后的结果</comment>
            <returntype>int</returntype>
            <parameter>
                <name>a</name>
                <type>int</type>
            </parameter>
        </method>
    </class>
    <version>1.0</version>
</root>
I had import the necessary jar:
attachment.php


where is my wrong please?
 

Attachments

  • a.jpg
    a.jpg
    28.8 KB · Views: 372

stefanobusetto

Active Member
Licensed User
Longtime User
this works on my device

public class mylibc {
public int mycall(int a) {
a=a*3;
return a;
}
}

Sub bt_test_click
Dim a As mylibc
Log(a.mycall(13))
End Sub

which android.jar version lib are you using?
 
Top