Android Studio - OpenCV project wont build - android

I followed the instructions to import OpenCV to Android Studio here https://github.com/quickbirdstudios/opencv-android, after Android Studio wouldn't let me use the File > New > Import Module feature. After following the instructions, I get these build errors:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: H:\AndroidProjects\WyzeCloud\Rev1\IPCloud\app\build\intermediates\navigation_json\debug\navigation.json (The system cannot find the file specified)
============================================================================
2: Task failed with an exception.
What went wrong:
Execution failed for task ':app:compressDebugAssets'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CompressAssetsWorkAction
H:\AndroidProjects\WyzeCloud\Rev1\IPCloud\app\build\intermediates\merged_assets\debug\out
============================================================================
BUILD FAILED in 18s
Anyone know what these errors mean, or have a possible solution to importing OpenCV to an Android Studio project?

I faced this problem before and my solution:
Download the Android sdk of Open-CV from this link: https://opencv.org/releases/
Add the java and jni library files into your project. Java functions of this library is works with jni files (.so).

Related

Execution failed for task ':app:packageDebug' ... Too many zip entries 236220 (MAX=65535)

I'm executing cordova build -d but keep getting this error at 94% complete:
Here's a screenshot of the MacOs terminal error
Here's a partial transcription of the screenshot:
* What went wrong:
Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> Too many zip entries 236220 (MAX=65535)
I haven't been able to find any info about this online. Does anyone have any ideas how to resolve?
I tried gradle clean then gradle build, increasing org.gradle.jvmargs size, and updating from gradle 7.6 to 8.

Build failed because of react native reanimated 2

I install react native reanimated 2 according to its installation doc. But when I run project for android build, I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'lib/x86_64/libreactnativejni.so' from inputs:
- D:\ReactBootCamp_RASAHR\Bootcamp Main Projects\ReactNative\SecondVersion\Fooductor\node_modules\react-native-reanimated\android\build\.transforms\1ebd6d22f25011a79a18acd12f297fc9\transformed\jetified-react-native-reanimated-65-hermes\jni
- C:\Users\Kavosh\.gradle\caches\transforms-3\156e8e6ad84734ffd5fbff137e92dae0\transformed\jetified-react-native-0.65.1\jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
How can I solve this?

Path to cmake in Android

When building my Android project in AndroidStudio 3.6.1 I'm getting an error message:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:externalNativeBuildCleanDebug'.
> A problem occurred starting process 'command 'C:\Users\myusername\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe''
cmake is correctly installed but myusername does not exists. Instead, it should be a different folder.
Where can I change the path?

Flutter returns Execution failed for task ':app:transformClassesWithDexBuilderForDebug' as soon as I add packages

I want to make an Android app with Flutter that uses the firebase ml kit to perform text recognition on images. I have successfully added firebase to my flutter project, but as soon as I add the packages image_picker: 0.6.1+4 and firebase_ml_vision: 0.9.2+1 I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\mathi\.gradle\caches\transforms-1\files-1.1\firebase-analytics-impl-11.4.2.aar\266afe38e9d564b66b359ca5823523b4\jars\classes.ja
The error also occures when I add only one of the two packages.
Update build.gradle to com.android.tools.build:gradle:3.6.0 and do flutter run -v in your build in editor terminal. Because maybe you have to update your gradle-wrapper.properties too in your android folder.

Dex error when trying to build ionic Android app

I'm trying to build an ionic app for Android but when I run
ionic cordova run android
I get
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
Trying to run ./gradlew clean gets me
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type FileHasher using BuildSessionScopeServices.createFileSnapshotter().
I had the same issue but it was resolved. Thanks to information from #notlose at this link https://github.com/oney/react-native-gcm-android/issues/32
Solution:
just remove both 'build' folder in /android and /android/app
and build again with
'react-native run-android' for react-native
'ionic cordova run android' for ionic

Categories

Resources