Closed Tamada4a closed 1 year ago
Please follow the instructions here: https://github.com/bytedeco/gradle-javacpp#the-platform-plugin
@saudet maybe i'm stupid, but I added the plugin to the top-level build.gradle
, then added it to app/build.gradle
, added dependencies there, but still doesn't see some packages.
my settings.gradle
:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io'} //for MultiImageView
}
}
rootProject.name = "FindYourselfInThePhoto"
include ':app'
include ':OpenCVLibrary'
my top-level build.gradle
:
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.bytedeco.gradle-javacpp-platform' version '1.5.8'
}
ext {
javacppPlatform = 'android-arm,android-x86' // defaults to Loader.getPlatform()
}
app/build.gradle
:
plugins {
id 'com.android.application'
id 'org.bytedeco.gradle-javacpp-platform'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.findyourselfinthephoto"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
//coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/native-image/**/**.json'
exclude 'META-INF/native-image/*.json'
exclude 'META-INF/native-image/**'
//pickFirst 'nd4j-native.properties'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.martipello:MultiImageView:1.0.8.2' //MultiImageView(PhotoCollage)
implementation 'com.squareup.okhttp3:okhttp:4.10.0' //get-requests
implementation 'com.sezinkarli:random-user-agent-generator:1.3' //random user-agent
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':OpenCVLibrary')
implementation 'com.github.onimur:handle-path-oz:1.0.7' //handle real path
api 'org.bytedeco:javacv-platform:1.5.8'
api 'org.bytedeco:opencv-platform-gpu:4.6.0-1.5.8'
api 'org.bytedeco:ffmpeg-platform-gpl:5.1.2-1.5.8'
}
You'll need to say which packages are missing so that we may add them.
I tried to made face recognition app and trying to import packages from this example. It is not possible to import the following packages here:
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.javacpp.DoublePointer;
import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_face.*;
import static org.bytedeco.opencv.global.opencv_imgcodecs.*;
I also tried to import packages from this example to check if I connected the dependencies correctly, but the following packages were not found:
import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_imgproc.*;
import static org.bytedeco.opencv.global.opencv_calib3d.*;
import static org.bytedeco.opencv.global.opencv_objdetect.*;
Maybe I connected something wrong, since I don't have most of the packages from the example?
my top-level
build.gradle
:
Adding dependencies there won't add them to your Android project. You'll need to add them to app/build.gradle as per the instructions here: https://github.com/bytedeco/gradle-javacpp#the-platform-plugin
I have them in app/build.gradle
already
When you say "not possible to import", what kind of error do you get? For example, you won't be able to use it with another build of OpenCV, so you'll have to remove those lines:
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':OpenCVLibrary')
Also, it's possible ProGuard is doing something you're not expecting it to do, so you should remove these lines as well:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
I have created a new project, but the imports still don't work
When you say "not possible to import", what kind of error do you get?
I mean, I don't have the packages I need - they are not imported
my app/build.gradle
:
plugins {
id 'com.android.application'
id 'org.bytedeco.gradle-javacpp-platform'
}
android {
namespace 'com.example.myapplication'
compileSdk 32
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
/*buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}*/
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/native-image/**/**.json'
exclude 'META-INF/native-image/*.json'
exclude 'META-INF/native-image/**'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation group: 'org.bytedeco', name: 'javacv-platform', version: '1.5.8'
implementation group: 'org.bytedeco', name: 'opencv-platform', version: '4.6.0-1.5.8'
implementation group: 'org.bytedeco', name: 'ffmpeg-platform', version: '5.1.2-1.5.8'
}
settings.gradle
:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "My Application"
include ':app'
build.gradle
:
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.bytedeco.gradle-javacpp-platform' version '1.5.8'
}
That sounds like a problem either with your IDE or with your installation of Gradle. If clearing caches and what not doesn't fix this, I'd say to try and reinstall everything from scratch. This doesn't look like an issue with JavaCV.
Does this mean that my app/build.gradle
, settings.gradle
and build.gradle
is correct? And implementations is correct too? And i connect plugin correctly?
That looks fine, but IntelliJ and Gradle are quite buggy, so sometimes we need to reinstall them.
Okey, i'll clear cache and reinstall Gradle and IDE if needed
Still nothing((( Maybe you have fresh example of Android project that implements JavaCV with other modules and its work fine? Because i dont know what is going wrong: i have cleared cache, reinstall gradle and IDE, trying different examples. But nothing works...
If you're having problems with other libraries, you'll need to specify what they are to get a meaningful answer.
No. Problems only with JavaCV (
So what do you mean by "other modules"?
No. Problems only with JavaCV ( Here I mean that I have such problems only with bytedeco libraries (JavaCV, javacpp, javacpp-presets)
"other modules" I mean that, for example, in
import org.bytedeco.opencv.
i cant importglobal
package and i get following problem:Cannot resolve symbol 'global'
. With the rest of the same problem
Like this
This sample project has been working fine for everyone that I'm aware of: https://github.com/bytedeco/sample-projects/tree/master/JavaCV-android-example
I do not know how, but this example did not work for me before. Thanks!
Hi! I'm trying to make an app with face recognition. At first I tried to use javacv 1.5.x, but nothing worked
my implementations here:
then I copied all the implementation from the example, but I still can't import
my gradle:
Im using the last version of Android Studio and last version of Gradle