Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android import library

In my project, I need to use external library. That library consists of .class files. I have added folder with this library to my project using properties -> Java Build Path -> Libraries -> Add class folder. I can compile project without any problem, but when I run it, I get failed resolving xy and debugger stops on line where I create instance of class from imported files.

I guess the external library I use isnt linked to my .apk file. How can I fix this? I have tried to check this library on "Order and Export" tab assuming that, it will export the library with my application. But it didnt work.

How can I link this library to my project .apk? Do I need to somehow install this library on device first? Do I need to copy this library in application folder?

PS: I'm using Eclipse Juno, android SDK target 10.

Thank you


UPDATE

I have this library copied in libs folder. External library path is:

my_project/libs/sk/aicit/leg/libraries*.class

I have added ./libs folder in Libraries settings of project. I do not have .jar version of this library, only .class files.

I have also souce code of this library, but I didnt want to include its classes in my project, it has its own dependencies, I wanted to just "link" it like library. Its an external library I havent written.


UPDATE 2

I have copied all the source files from library to my projects "src/" dir. I have removed Library from Java build path. I can stil compile my project, but when I run it Iget

FATAL EXCEPTION:main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{
com.example/myvideorecord/com.example.myvideorecord.Robot}: java.langNullPointerException
...

What can I do, how to debug this error? :(

like image 744
Buksy Avatar asked Jul 22 '26 02:07

Buksy


1 Answers

steps

  1. Copy the library file into libs folder
  2. select jar file -> right click -> Build Path -> Add to Build Path
  3. clean the project Project-> Clean -> select your project -> ok
like image 105
Kirit Vaghela Avatar answered Jul 23 '26 16:07

Kirit Vaghela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!