Android Question Package name of library

janderkan

Well-Known Member
Licensed User
Longtime User
Hi

I created class and code modules, compiled to library with no problems.
Next I created a service and have found that the package name of the library and the program where it is used must be the same.
No point of creating a module if it cant be used in different programs.
Maybee I am missing something?
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Does your library make any calls to the Main module that was in the IDE when you were developing it? Does it use any custom Types that were defined in the Main module?
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Yes, the library makes events.
I have attached two simple projects to show the problem.
TestLib is the library and Test is the program using the library.
Open Testlib and compile to library.
Open Test and run.
It works fine, both projects have package name 'b4a.example'
Change the package name of Test to something else and it will not compile.
 

Attachments

  • Test.zip
    492.4 KB · Views: 128
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
In your Common class, try changing Owner from a String to an Object. You'll note that the signatures of SubExists() and CallSubDelayed() both expect Owner to be an Object (for example, Main), not a String.
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
I have found the correct subject to search for: NoClassDefFoundError
I still have not found a solution.
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
I have read all posts about my problem, but the solutions only describe how to fix Eclipse.

I am compiling a library in B4A and reuse it in B4a.
I can only get it to Work if the package name is the same in the library and the consuming program.
I have uninstalled all Java, reinstalled Java6, Java 7 and Java8.
Tried to fix system variables.
I have rewritten my example to expose a class that starts a service.

Is it possible to have different package names in a program and a library ?
 

Attachments

  • Test.zip
    502 KB · Views: 129
Last edited:
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
SOLVED.
@Roycefer You showed me the way.

B4A can resolve a string to an object name.
It Works in the same program and if the program and library has the same package name.
When using a library you must use the object name and not a string.
 
Upvote 0
Top