I have create a react-native project, I want to do some image processing. I am quite familiar with OpenCV, so I want to use OpenCV library in my project.
I have searched for node module but I can't found it.
So, I tried to implement library with this method likn Android Studio.
1. I have this structure of project :
Project Structure
2. I create Native module from react-native tutorial
Native Module Project Structure
3. When I run :
react-native run-android
I get these errors :
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\MainApplication.java:15: error: cannot find symbol
import com.opencvproject2.opencvcamera;
^
symbol: class opencvcamera
location: package com.opencvproject2
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:14: error: package org.opencv.android does not exist
import org.opencv.android.BaseLoaderCallback;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:15: error: package org.opencv.android does not exist
import org.opencv.android.CameraBridgeViewBase;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:16: error: package org.opencv.android does not exist
import org.opencv.android.LoaderCallbackInterface;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:17: error: package org.opencv.android does not exist
import org.opencv.android.OpenCVLoader;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:18: error: package org.opencv.android.CameraBridgeViewBase does not exist
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:19: error: package org.opencv.android.CameraBridgeViewBase does not exist
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:20: error: package org.opencv.core does not exist
import org.opencv.core.Mat;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:21: error: package org.opencv.highgui does not exist
import org.opencv.highgui.Highgui;
^
C:\CETIC\OpencvProject2\android\app\src\main\java\com\opencvproject2\opencvcamera\OpenCVCameraModule.java:37: error: cannot find symbol
public Mat displayImage(String path){
^
symbol: class Mat
location: class OpenCVCameraModule
So my question is : Am I missing something to include OpenCV library to my React-Native project ?
Related
I have created my react native project using npx react-native init project_name
Then I have build the project and it was building successfully.
Next thing I wanted to add expo-local-authentication package to my project, so I have followed the instrunction given by the official documentation i.e, https://github.com/expo/expo/tree/main/packages/expo-local-authentication
For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.
So I have installed the expo module in my react native project using the automation installation i.e, npx install-expo-modules#latest
But after installing it is giving the below error.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainApplication.java:3: error: package expo.modules does not exist
import expo.modules.ApplicationLifecycleDispatcher;
^
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainApplication.java:4: error: package expo.modules does not exist
import expo.modules.ReactNativeHostWrapper;
^
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainActivity.java:2: error: package expo.modules does not exist
import expo.modules.ReactActivityDelegateWrapper;
^
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainApplication.java:22: error: cannot find symbol
new ReactNativeHostWrapper(this, new ReactNativeHost(this) {
^
symbol: class ReactNativeHostWrapper
location: class MainApplication
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainApplication.java:44: error: cannot find symbol
new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
^
symbol: class ReactNativeHostWrapper
location: class MainApplication
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainApplication.java:62: error: cannot find symbol
ApplicationLifecycleDispatcher.onApplicationCreate(this);
^
symbol: variable ApplicationLifecycleDispatcher
location: class MainApplication
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainApplication.java:99: error: cannot find symbol
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
^
symbol: variable ApplicationLifecycleDispatcher
location: class MainApplication
/Users/bhaveshkumar/Documents/AwesomeProject/android/app/src/main/java/com/awesomeproject/MainActivity.java:26: error: cannot find symbol
return new ReactActivityDelegateWrapper(this, new MainActivityDelegate(this, getMainComponentName()));
so this was building with no problem and then I was having problems with building ios so I removed the android platform and added it again. All the plugins and adding of the platform are being added correctly but when running the command $ ionic cordova build android I get a LOT of errors about not being able to find the symbol.
> Task :app:compileDebugJavaWithJavac FAILED
24 actionable tasks: 5 executed, 19 up-to-date
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic_Notifications.java:35: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
^
symbol: class NotificationManagerCompat
location: package android.support.v4.app
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic.java:57: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic_External_Storage.java:28: error: cannot find symbol
import android.support.v4.os.EnvironmentCompat;
^
symbol: class EnvironmentCompat
location: package android.support.v4.os
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/nl/xservices/plugins/FileProvider.java:4: error: package android.support.v4.content does not exist
public class FileProvider extends android.support.v4.content.FileProvider {
^
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:11: error: package android.support.annotation does not exist
import android.support.annotation.RequiresApi;
^
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:121: error: cannot find symbol
#RequiresApi(Build.VERSION_CODES.LOLLIPOP)
^
symbol: class RequiresApi
location: class IonicWebViewEngine.ServerClient
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic_Notifications.java:123: error: cannot find symbol
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this.cordova.getActivity().getApplicationContext());
^
symbol: class NotificationManagerCompat
location: class Diagnostic_Notifications
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic_Notifications.java:123: error: cannot find symbol
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this.cordova.getActivity().getApplicationContext());
^
symbol: variable NotificationManagerCompat
location: class Diagnostic_Notifications
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic.java:639: error: cannot find symbol
java.lang.reflect.Method method = ActivityCompat.class.getMethod("shouldShowRequestPermissionRationale", Activity.class, java.lang.String.class);
^
symbol: class ActivityCompat
location: class Diagnostic
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/cordova/plugins/Diagnostic_External_Storage.java:216: error: cannot find symbol
addPath = Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(file));
^
symbol: variable EnvironmentCompat
location: class Diagnostic_External_Storage
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/nl/xservices/plugins/SocialSharing.java:169: error: cannot find symbol
fileUri = FileProvider.getUriForFile(webView.getContext(), cordova.getActivity().getPackageName()+".sharing.provider", new File(fileUri.getPath()));
^
symbol: method getUriForFile(Context,String,File)
location: class FileProvider
/Users/c.francia/Desktop/application/app/platforms/android/app/src/main/java/nl/xservices/plugins/SocialSharing.java:285: error: cannot find symbol
fileUri = FileProvider.getUriForFile(webView.getContext(), cordova.getActivity().getPackageName()+".sharing.provider", new File(fileUri.getPath()));
^
symbol: method getUriForFile(Context,String,File)
location: class FileProvider
I have about 25 of those class errors. Never seen this error before and not a java programmer/used the android studio much.
I have found this SO post that looks like it might help? I just don't know how I go about updating the compiler tools through ionic or through the android studio?
I have also updated my SDK tools
Current version: Android Studio 3.5
Build number: AI-191.8026.42.35.5791312
Android SKD Tools: 26.1.1
Android Platform Version: API 29: Android 10.0 (Q) revision 3
$ java --version
$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Try adding the following code in config.xml under android platform
<preference name="ANDROID_SUPPORT_V4_VERSION" default="27.+"/>
<framework src="com.android.support:supportv4:$ANDROID_SUPPORT_V4_VERSION"/>
I have a qt quick application and it runs on windows without any problem. When I want to run it on android device it will build successfully but in deploy step it gives me the errors that is in below .(I can run other examples of qt on my android device without any problem like "gallery").
Invalid APK file: D:/Qt/Projects/build-Joor2 -Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_1_for_Android_armv7-Debug/android-build//bin/QtApp-debug.apk
Warning: QML import could not be resolved in any of the import paths: Jooya
Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils
Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Material.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Universal.impl
Installing to device failed!
17:07:30: The process "D:/Qt/Qt5.9.1/5.9.1/android_armv7/bin/androiddeployqt.exe" exited with code 16.
17:07:30: Pulling files necessary for debugging.
17:07:30: Package deploy: Running command "D:/programing/program/Android-Java/SDK/platform-tools/adb.exe -s 410066dfc826b151 pull /system/bin/app_process32 D:/Qt/Projects/build-JooyaLeitner2-Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_1_for_Android_armv7-Debug/app_process".
17:07:31: Package deploy: Running command "D:/programing/program/Android-Java/SDK/platform-tools/adb.exe -s 410066dfc826b151 pull /system/lib/libc.so D:/Qt/Projects/build-Joor2 -Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_1_for_Android_armv7-Debug/libc.so".
Error while building/deploying project Joor2 (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.9.1 for Android armv7))
When executing step "Deploy to Android device"
I integrated c++ with qml as below in main.cpp file
CoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setOrganizationName("Jooya");
QCoreApplication::setOrganizationDomain("jooyabash.ir");
QCoreApplication::setApplicationName("Jooya Leitner");
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<LoginManager>("Jooya",1,0,"LoginManager");
qmlRegisterType<MainPage>("Jooya",1,0,"MainPage");
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
and because of the code above I am getting:
Warning: QML import could not be resolved in any of the import paths: Jooya
I want to know how can I run my application on an android device?
Edit
In another qt quick controls 2 ,when i wanted to add splash to my app following the below link
https://falsinsoft.blogspot.com/2017/07/qml-show-android-native-splash-screen.html
after doing that it will above error ? does any one can help me?
I'm trying to compile the examples included in GStreamer. I'm following this tutorial
but I can't compile any of the included examples because ant debug give me this error:
-compile:
[javac] Compiling 4 source files to F:\Android\gstreamer\share\gst-sdk\tutorials\android-tutorial-1\bin\classes
[javac] F:\Android\gstreamer\share\gst-sdk\tutorials\android-tutorial-1\src\com\gst_sdk_tutorials\tutorial_1\Tutorial1.java:8: package com.gstreamer does not exist
[javac] import com.gstreamer.GStreamer;
[javac] ^
[javac] F:\Android\gstreamer\share\gst-sdk\tutorials\android-tutorial-1\src\com\gst_sdk_tutorials\tutorial_1\Tutorial1.java:20: cannot find symbol
[javac] symbol : variable GStreamer
[javac] location: class com.gst_sdk_tutorials.tutorial_1.Tutorial1
[javac] GStreamer.init(this);
[javac] ^
[javac] 2 errors
BUILD FAILED
F:\Android\android-sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
F:\Android\android-sdk\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.
Total time: 1 second
I have installed the latest version of android ndk and android sdk, I'm using API 19 and gstreamer 1.7.1 (gstreamer-1.0-android-arm-1.7.1.tar.bz2) downloaded from here; I'm using CygWin64 as required in the tutorial and ANT from Apache. I have also declared all the required local variables.
I can run the first command: android update project -p . -s --target 19
and also the second: ndk-build
If the compiling process is not possible with the command line, where can I get a working version of Eclipse with adt plugins?
I solved: since I'm using Gstreamer 1.7.1 the import line import com.gstreamer.GStreamer; must be changed into import org.freedesktop.gstreamer.GStreamer;.
I'm trying to create a script to automate the signed exportation of my android apps (to avoid manual work when I release an update to all my apps).
I've followed this tutorial: http://www.enterra-inc.com/techzone/using_ant_android_applications_building/
and others, very similar to this one.
I'm testing with 1 project by now, which includes mopub-sdk library, among others and I get a lot of errors, like this one (only with ANT build):
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdFetcherTest.java:62: error: static import only from classes and interfaces
[javac] import static org.mockito.Mockito.verify;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdFetcherTest.java:64: error: cannot find symbol
[javac] #RunWith(SdkTestRunner.class)
[javac] ^
[javac] symbol: class RunWith
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:41: error: package org.junit does not exist
[javac] import org.junit.Before;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:42: error: package org.junit does not exist
[javac] import org.junit.Test;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:43: error: package org.junit.runner does not exist
[javac] import org.junit.runner.RunWith;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:58: error: package org.fest.assertions.api does not exist
[javac] import static org.fest.assertions.api.Assertions.assertThat;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:58: error: static import only from classes and interfaces
When I compile with Eclipse, everything is fine.
I think I did everything OK, but there is only 1 thing that is bothering me.
For some reason, when I imported the mopub-sdk project, it showed src/main/java directory instead of just src like the rest of the projects.
So, my question is:
1) How can I solve these errors so I can finally build automatically all my apps.
2) It the folder structure of mopub-sdk is the cause of the problem: how can I solve it?
UPDATE:
While trying to reimport the mopub-sdk project, I'm getting this error.
I found the solution.
The problem was finally mopub-sdk library project and the problems at the import stage.
I fixed the nested directory issue within the src/ folder and the build was successful.
To fix our ANT build remove the 'test' folder under src and the compile errors in ANT went away.
Specifically the files in this part of the downloaded SDK:
https://github.com/mopub/mopub-android-sdk/tree/master/mopub-sdk/src/test