I had downloaded the Android Studio 4.0.1 and the same version for OpenCV Library.
I made a random Java project just to set the library, but when I select the library (the path is correct -"C:\opencv-4.0.1-android-sdk\OpenCV-android-sdk\sdk\java") they don't show it and let me finish this action (please see the image below).
Why I can't select the library? I am watching an Youtube video for this (beginner here) and the guy can see it totally different.
You don't need to select library. Add this module then do this steps:
Open Project Structure-> Dependencies-> app -> Add module dependency-> select opencv module.
You can access opencv classes right now.
For me the import project functionality also doesn't work, but what worked is to create a new empty project, clears its artifacts, and copy the OpenCV library artifacts from OpenCV-android-sdk\sdk\java\ folder. There are 6 steps:
copy AndroidManifest.xml to src/main
copy sources to src/main/java
copy res folder to src/main
copy libs folder from OpenCV-android-sdk\sdk\native\libs to src/main and rename it to jniLibs
create folder src\main\aidl and move file src\main\java\org\opencv\engine\OpenCVEngineInterface.aidl to folder src\main\aidl\org\opencv\engine\
in build.gradle set project as library by specifying plugins { id 'com.android.library'}
You can refer to the image in order to see the final project tree:
project structure image
Related
I am very new to Android development. I am not using gradle. I want to use the following library
Can you please let me know how to include in my project.
When I clone your project to eclipse(Mars) it is showing the following structure-
My project structure is given below.
Now shall I copy the "lib" folder (lib\src\main...) to my "src" folder?
Normally I add the library like the following way-
Just import the lib folder of the library instead of the whole library in Eclipse. And add it as a library to your project.
I downloaded a java/android library .zip file and extracted it. Then I used the command
$jar -cvf java-lib-name.jar topfile/
and it seemed to traverse the folder and create the jar. However, when I then move the .jar into the /libs/ folder, the icons for the packages in the jar are white instead of brown and I can't access them. When I went into Properties->Java Build Path, the .jar is in the Private Libararies section. Did I create the jar incorrectly? Is there another setting in Eclipse I need to use?
You need to compile java classes before creating jar.
Or another thing you can do for this project is to import the library as android library project to your current eclipse workspace and then use it on your android project.
Add the library project using File > Import > Existing Android Code Into Workspace. Make sure this project is marked as a library. Right click on your project, choose Properties, click on Android in left pane > Under library heading, add the library project
I want to create a GridView like GooglePlay.
I found this library on Github. I don't exactly know how to include it to my project. I tried to add it in "Build Path", but it doesn't work.
Is it possible to export it as a jar file?
You will have to import library directory as a project in your Eclipse just like #ssantos said in the answer. However you have to do one extra thing to make it work.
All the code is in a sub folder called "java". You have to right click on it and make it as source folder.
For more information you can look at the official guidlines https://github.com/gabrielemariotti/cardslib/blob/master/doc/BUILD.md
It seems you can find the library project here.-
https://github.com/gabrielemariotti/cardslib/tree/master/library/src/main
I'd try importing that as a project in your workspace (and mark it as Android library), and then including it in your project Android libraries (Project properties => Android => Library section)
If you're using Android Studio, just add the following to your build.gradle file.
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.3.0'
}
I am developing android library project.I don't want share my source code.I want to create something like jar file.But i can't create jar file as it includes xml layouts.so is there any way to build project without including source code?
I can give you an example of such library. Open Android SDK manager and download Google play services library.
This library contains 'libs' folder with google-play-services.jar which contains all the source code. Also there is 'res' folder and android manifest file to be able to add this library to every android project.
First thing is to have the full library-project ( example : FullProject).
Then I import the full library project (FullProject) in a new workspace and check “Copy Projects into workspace”. This new project must have the same name ( FullProject)
in the copy, i removed the source code.
in the app-project i added the source-less-library-project as android library
in the app-project i added the .jar file with all the binary classes from the full library-project ( right clic on directory “source” of the full library-project, export as jar and check « Add directory entry » ).
in the build path of the app project, in "order and export", check the .jar exported
update the manifest file of the app project with all views of the library project .
clean the app project
It’s all !
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? :(
steps
Copy the library file into libs folder
select jar file -> right click -> Build Path -> Add to Build Path
clean the project Project-> Clean -> select your project -> ok
Android Studio
For importing a Android library into Android Studio, use the following steps:
1) (Optional) I like having my main Android project contain everything it needs to compile correctly, so I move external libraries into the libs/ directory. Generally, you only need to keep the following directories:
res
src
AndroidManifest.xml
*.iml (This will typically be the name of the library you're importing.)
2) Go to your Project Properties.
3) Go to Modules.
4) Import a New Module (Command + N and then Import Module).
5) Navigate to the library directory you want to import.
6) Create module from existing sources.
7) Click Next three times to add the necessary files.
8) Click Finish to complete the module additional.
9) Click on your project in the module list and go to the Dependencies tab.
10) Click the + button at the bottom and click Module Dependency....
11) Make sure your library you're importing is selected and click OK.
12) Click OK in the Project Properties window.
And you should be good to go.
Copy that library file into libs folder
if u have the source code of the library you can import it in eclipse .
Right click on your project -> properties->android -> reference-> add
and add the library project which u have imported. This will include only .class files of the library in ur project