Cant import OpenCV module in android studio - android

I've been trying to import Open CV module to android studio exactly as many tutorials online told me to but it wont work. I googled the issue a bit and found a solution to choose the sdk folder as the directory and not java but even that dosent work.Im using Android Studio v4.0.1 and the latest version of OpenCV. Help.

First of all make sure your sdk folder in your downloaded opencv sdk contains a build.gradle file. If your downloaded sdk doesn't have build.gradle try another version of opencv sdk, Unless you have to select java folder in the opencv sdk and after that copy jni files into your project tree.
The easiest way to import OpenCV sdk into your project is as follow:
Create an Android Project
File -> New -> Import Module -> path to OpenCV/sdk/ -not java folder! (opencv 4+)
File -> Project Structure -> add OpenCV as 'Module Dependency' of 'app'
Clean Project
Done! no need to copy jni libs and other things.

Importing opencv to androidstudio
->First download opencv from https://opencv.org/releases/
for your current using android studio version,and extract it.
->open android studio create new project if project is already
exist follow the below.
->in android studio choose option in MENU->File->Import
Module here please select the your opencv-android directory
till sdk selection
eg:("E:\stardev\OpenCV-android-sdk\sdk") and
then finish, if your downloaded same version it's good to go
else change the build.gradle setting from opencv build.gradle
and sync.
->after this to add as a dependency in android studio
Choose
Menu->File->Project Structure->dependencies,
select app from tab and add(+ icon) from menu select module
dependency and select sdk from here.
->to test goto your project activity and
(import org.opencv.core.Core)

If you are using Arctic fox and still facing this issue, This Solution worked for me.
If your next and/or finish buttons is still not clickable after adding the right path
https://stackoverflow.com/a/68738767/12052997

Related

Adding a library to eclipse

I am new to Eclipse and I could not solve this problem.
How could I import this library to Eclipse using the default builder (not using Gradle)?
Without using Gradle/Maven and using Eclipse you need to manually add the library.
The library is in the jcenter repository, which means there is a jar file available. This jar file can be found here (I'm pretty sure you need the -sources.jar)
Download this library and save it in a logical place. Go to Eclipse, highlight the project and press Alt+Enter. Go to the Java Build Path page and click Add External JARs under the Libraries tab. Select the JAR file and it should be fine.
Keep in mind that the Eclipse ADT plugin is not the way Google wants you to do it. If you have no reason to use Eclipse other than that it's what you have set up now, you should probably move to Android Studio.
Create a new project and add github version project files to newly created project else download the entire project from github and add this project to your current project.
right click(current project) -> Build path -> Configure build path -> Java build path -> Projects (tab) -> click add
Just add this project there and build your project.

Compile errors in new Android project in Eclipse

I'm using Eclipse for build an Android project. when I try to open bellow item :
file --> new --> Android Application Project
Then when the project is built a series errors displayed :
I am a beginner in this regard and thank you for your help.
Open AppCompactv7 and add as library on your project
The problem is with your appcompat_v7 project. Delete the existing project one in the workspace and re-import it from
\sdk\extras\android\support\v7\appcompat
After that try cleaning the project.
Project -> select Clean -> select the project.
1 - Make sure library project(appcompat_v7) is open & is proper referenced (added as library) in your application project.To do this follow this steps: right click in your project -> "Properties - Android - Add"
2 - Delete android-support-v4.jar from your project's libs folder(if jar is present).
3 - Appcompat_v7 must have android-support-v4.jar & android-support-v7-appcompat.jar inside it's libs folder. (If jars are not present copy them from /sdk/extras/android/support/v7/appcompat/libs folder of your installed android sdk location)
4- Check whether ActionBarActivity is properly imported. (In your case this is right)
import android.support.v7.app.ActionBarActivity;
Here is a good example of how to create a project in Eclipse using v7 Support Library
Finally because you are a beginner I'll recommend you to use Android Studio as it is the official environment for developing for Android. Configuring the SDK can be quite a pain in Eclipse. You can also take advantage of the Gradle dependency system and simply specify which libraries you would like to use and Android Studio will automatically fetch the jars from online remotes as required. I think its the future of Android Application Development.

Importing an app-compat v7 library eclipse project to android studio

I have an Android application created in Eclipse, now I want to import it to Android studio, when I import project I get the following error
Project FinalProject Integrate:/home/vishal/Android_Workspace/FinalProject Integrate/project.properties:
Library reference ../android-support-v7-appcompat could not be found
Path is /home/vishal/Android_Workspace/FinalProject Integrate/../android-support-v7-appcompat which resolves to /home/vishal/Android_Workspace/android-support-v7-appcompat
and it is an unrecoverable error.
Here's what I did: In the the project.properties file I deleted all dependencies, and while importing project in Android studio I simply followed the instructions (making sure the check box are ticked, especially the one that says add any dependency). And it worked.
Edit your build.gradle, remove the dependency of project appcompat-v7
In Android studio, Go to main menu, File -> Project structure -> Dependencies, click add icon on the right side, and add appcompat-v7 as a library dependency.
Try this: Go down to the folder where the workspace and there copy the project to another folder, then open the Android studio as administrator and try again.

Run Facebook SDK sample apps in Android Studio

Novice question.
What is the recommended way to run the sample apps, included in the Facebook SDK, in Android Studio (0.8.6)?
The ideal answer would include step-by-step instructions.
I'm using Android Studio version 0.8.0, and Facebook SDK 3.18.
When I tried to open a sample as a separate project, it can't find Gradle and wasn't able to run it. However, when I imported /samples folder as a root, all sample projects were imported and was able to run each samples.
File > Import Project > Select FACEBOOK_SDK_PATH/samples > OK > Create project from existing sources
and then, click next/ok as Android Studio's default setting.
Hope it helps!
Suposing you already downloaded and unzipped the SDK.
Create your android project. Gradle based.
File -> Import Module. Navigate to the unzipped folder and select the unzipped folder.
Add the library dependency in your main module (the one created with your project) adding this line in your build.gradle:
Synchonize project.
If you want to continue creating your own app, you might add the dependency module build.gradle file:
android {
dependencies {
compile project (':facebook')
}
}

Importing gradle project to eclipse

I have problem with importing this library into eclipse. Things I did:
run gradlew.bat (inside project) that downloaded and installed it
run CMD
set my SDK with command "set ANDROID_HOME=C:\dev\android-sdk-windows"
run command gradlew build
after successful build image I tried to import project into my eclipse but it's incomplete (without any classes)
It's first time I'm using gradlew, could you tell me what I'm doing wrong?
This library is built with Android Studio or Intellj.
These steps with Gradle are referred to Android Studio or IntellJ.
I don't know this lib, but if you are using Eclipse, you should do:
clone a copy of this repository, or download it (outside eclipse workspace)
import the code in your workspace starting from library/Donation-lib folder
mark java(*) folder as source (click on folder -> Build-Path -> use as source folder). You can also remove the src folder, from the project.
mark aidl(*) folder as source
add support library v4 rel.XX ( click -> Android Tools -> Add support library , or just copy android-support-v4.jar in libs folder)
mark your project as Android Library (Properties -> Android -> Is library)
(*) Eclipse uses src and res as source folders.
Android Studio instead uses src/main/java , src/main/res and src/main/aidl as source folders.
Open file build.gradle and add this line on top:
apply plugin: 'eclipse'
In project directory invoke command
gradlew.bat eclipse
Open project in Eclipse (import) like normal eclipse project
More info: Eclipse Plugin
Alternatively use dedicated Eclipse plugin Gradle Integration for Eclipse 3.4.0.RELEASE
There is a simplest and quick way to import a Gradle project into Eclipse. Just download the Gradle plugin for Eclipse from here.
https://marketplace.eclipse.org/content/gradle-integration-eclipse-0
And then from import select Gradle and your project would be imported. Then you have to click on Build Model to run it.
EDIT
Above link for Gradle plugin is no more valid. You can use the following link.
https://marketplace.eclipse.org/content/buildship-gradle-integration

Categories

Resources