Building a c++ application with gradle on host linux aarch64 - android

My host is a linux aarch64 machine on Android Galaxy Tab S4 with Termux installed as my development environment.
Installed in Termux is NDK v22, Clang 12.0.2, Gradle 7.1.1, android-sdk (30.0.3) and kotlin 1.5.21.
I init'ed a new c++ application project with gradle and the default template project-files and directories were initialized.
When I try to build now the project, I got following errors:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugCpp'.
> Error while evaluating property 'compilerVersion' of task ':app:compileDebugCpp'
> No tool chain is available to build C++ for host operating system 'Linux' architecture 'aarch64':
- Tool chain 'visualCpp' (Visual Studio):
- Visual Studio is not available on this operating system.
- Tool chain 'gcc' (GNU GCC):
- Don't know how to build for host operating system 'Linux' architecture 'aarch64'.
- Tool chain 'clang' (Clang):
- Don't know how to build for host operating system 'Linux' architecture 'aarch64'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
1 actionable task: 1 executed
My use-cases will be, to build c++ libraries, later using kotlin/native and integrating as last task everything into an apk with the help of gradle/kotlin/ndk etc.
What does this error mean?
Is there really no support for linux aarch64 hosts or do I need to change some configuration settings in the build.gradle file?
I searched the gradle documents, internet and kotlin/native manual but cannot found a solution.
Thanks in advance for your help.

Is Clang found if you try to call it directly without gradle?
Please make sure that you can compile anything with Clang from command line.
Then you may need to fine tune your native tool chain for Gradle as described in https://docs.gradle.org/current/userguide/native_software.html#native_binaries:tool_chain

Related

Cordova Cli - No usable Android build tools found

I'm trying to build an hybrid app using the cordova cli using command
cordova build android
But it fails with error (complete log) :
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: /usr/lib/android-sdk
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* Where:
Script '/home/iam/Projects/lave/platforms/android/CordovaLib/cordova.gradle' line: 75
* What went wrong:
A problem occurred evaluating script.
> No usable Android build tools found. Highest 30.x installed version is 27.0.1; Recommended version is 30.0.3.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
I have followed this step thinking it would solve the issue but problem remain and I get same error even after installing the packages.
Actual image from my Android SDK Settings :
It's worth mentioning that I have installed Android-SDK using apt and afterwards I have set up environment path with this command :
export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
After installing the packages in Android-SDK,I restarted Ubuntu thinking it would fix the problem. But still receives same error message when trying to build. Am I missing something?
From the error logs I think it cannot find your ANDROID_SDK_ROOT, please check if it is set like this in your environment variables:
export ANDROID_SDK_ROOT=/Users/[USERNAME]/Library/Android/sdk
export PATH=$ANDROID_SDK_ROOT/tools:$PATH
I believe you should also set the path to your build- and platform tools like so (for your versions/paths of course):
export PATH=${PATH}:/Users/[USERNAME]/Library/Android/sdk/build-tools/33.0.0uild-tools/30.0.3
export PATH=${PATH}:/Users/[USERNAME]/Library/Android/sdk/platform-tools
Can you check that you have set al of these, or something similar? Also be aware that you may have to fix something in your build tools (this is the case for several versions, I don't know of the top of my head which ones, so it's worth to check): Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"
I want to offer the solution that worked for me for Ubuntu. I suddenly remembered I had written a tutorial for mac here on SO. Remembering this made me realize I forgot to set the JAVA_HOME which Cordova looks for while Checking Java JDK and Android SDK versions. Also, ANDROID_HOME is completely obsolete and deprecated. Set the same path for ANDROID_HOME to ANDROID_SDK_ROOT (same thing).
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=/home/iam/Android/Sdk
export JAVA_HOME=/opt/android-studio-2021.3.1/android-studio/jre
Create a bash profile and paste the above codes then save
sudo gedit ~/.bash_profile
Run this
source ~/.bash_profile
Now when running
cordova build android --prod
Gradle should be able to configure for the first time and do the necessary tasks and then boom
BUILD SUCCESSFUL in 7m 4s
48 actionable tasks: 48 executed

Flutter debugging fails

I want to run a flutter application that I wrote on Visual Studio Code on the device. However, when I do this, I always get the following error. Normally this wouldn't happen, it's just starting to happen. I'm not entirely sure what I should do.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/oracle-java8-jre-amd64' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUİLD FAILED in 45s
Exception: Gradle task assembleDebug failed with exit code 1
OS : Ubuntu
Mobile Device : Samsung J500F
Android Version : 6.0.1
You need to have installed a JDK. Depending on which version of Ubuntu you should just be able to do sudo apt install openjdk-8-jre-headless
That said, I would target a higher Java version, if I were you, maybe 11?
Either way, if you look at the path your JRE is in, it's '/usr/lib/jvm/oracle-java8-jre-amd64'
You don't want to be using the regular JRE to build/run your application. You want to build and run with openjdk. That's why your error message says,
"Make sure Gradle is running on a JDK, not JRE."
The message Execution failed for task ':app:compileDebugKotlin' and the Gradle issue indicate that your problem is not about Flutter but about Android, and more precisely about the lack of JDK (which allows to execute Java and Kotlin code).
To solve this problem, it is necessary to review the configuration of your project.
I advise you if possible to use Android Studio, an IDE recommended by Android developers and that will make things much easier with Android and Flutter.
This article from the official Android documentation and this one from JetBrains should help you solve your problem.
You can install Android Studio from snap store or zip

How can I use Cordova without installing Android Studio?

I use an old computer for development, and my current specs doesn't meet Android Studio's System requirements.
I am a newbie, and only know some JS/HTML5. And I'm trying to enable oAuth for Firebase Auth services for Android.
I downloaded the Commandline Tools from https://developer.android.com/studio/ (far at the bottom of the page) and tried to use sdkmanager.bat, but I can't make it accept commands. I added its Path to the Environment variable "path", and then tried using Windows PowerShell. But writing any command will just make it start over again. (maybe it was something foolish of me)
Then I downloaded and installed Gradle.
After that when I write cordova requirements I get the following result:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
No android targets (SDKs) installed!
Gradle: installed C:\Users\Sparsha\Desktop\gradle-6.5-all\gradle-6.5\bin\gradle
Some of requirements check failed
I am not sure how Android SDK installed became true, but Android target is not installed (Don't know how to install).
Also, using cordova build gives me the following results:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Sparsha\Desktop\commandlinetools-win-6514223_latest (DEPRECATED)
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.5/userguide/gradle_daemon.html
Process command line: C:\Program Files\Java\jdk1.8.0_251\bin\java.exe -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=IN -Duser.
language=en -Duser.variant -cp C:\Users\Sparsha\Desktop\gradle-6.5-all\gradle-6.5\lib\gradle-launcher-6.5.jar org.gradle.launcher.daem
on.bootstrap.GradleDaemon 6.5
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get
full insights.
* Get more help at https://help.gradle.org
C:\Users\Sparsha\Desktop\gradle-6.5-all\gradle-6.5\bin\gradle: Command failed with exit code 1
Thanks...
Whatever you downloaded from that URL is not needed. That is probably the SDK for Android Studio.
To setup your Cordova tools to develop Cordova apps with either Visual Studio or your favorite text editor like Notepad++, follow this detailed guide which I created earlier.
Let me know if you have any questions.

How can we Integrate CMake or ndk-build into Android Studio 3.0.1? Gradle version is 4.1, android plugin version 3.0.1

I am trying to integrate openCV 2.4.9 into my android project, integration was successfully done, but when i build the project to check the integration the this error comes
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugNdk'.
Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration. For more information, go to:
https://d.android.com/r/studio-ui/add-native-code.html
Alternatively, you can use the experimental plugin:
https://developer.android.com/r/tools/experimental-plugin.html
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 5s
so how could i solve this problem
Note::
when i integrate OpenCV 3.0.1 into my android project then there was no error of this kind then why this error comes when i integrate openCV249?
please I am new to android development so give me detailed answer.
Even if you use the sources of this old version of OpenCV, you still need to comply with the modern gradle build environment. The best route would be to take the build.gradle files from ver. 3.0.1 and apply them to 2.4.9 (try to make as few changes as possible).
This version of OpenCV was frozen at the time when NDK release was r9d. This is quite outdated, and it has many problems when building the app for modern devices. I would recommend to upgrade to Android NDK r14b (again, if your build fails, the minimal necessary patch is expected to be quite small). If you have courage to upgrade further - to current Latest Stable Version (r16b), you should follow the NDK documents that explain how the new Unified headers change the ndk-build configuration (Android.mk) files.

Why can't I run my Cordova Project in Android?

I am trying to run my Cordova Project in a Android platform on a Mac.
I downloaded Android Studio.
However, whenever I try to run the following command line in terminal
cordova run android
it ends in the following error:
BUILD FAILED
Total time: 1.391 secs
Error: /Users/karel/Cordova Projects/demo/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 25].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Am I missing something?
It works for
cordova run ios
cordova run osx
cordova run browser
How can I accept these terms the message is talking about? I recall accepting to certain terms, at least, when downloading Android Studio.
I am wondering whether I have to install Android SDK separately from Android Studio or something. (I have no experience with Android).
Thanks for your time. Your help would mean a lot.

Categories

Resources