Android Studio java.nio.file.AccessDeniedException on CMake ExternalProject_Add - android-ndk

I am using Android Studio to build an app with the ndk, it has no java code. The code is written in C++ using CMake to build it. CMake, in turn, includes several projects such as boost etc downloaded, compiled and linked automatically from GitHub via ExternalProject_Add.
This works in Linux but I am now trying to get it to compile in windows Android Studio and I get an error in the middle of the Gradle sync process.
This is the error message:
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':app:generateJsonModelDebug'.
java.nio.file.AccessDeniedException: C:\Users\chris\Documents\pangolin\PrimeMatter\Apps\Dygd\Android\app.cxx\cmake\debug\arm64-v8a_deps\actor_framework-src.git\modules\libcaf_python\third_party\pybind\modules\tools\clang\objects\pack\pack-9372b77cb08267912558dd56012fa92b1022b634.idx
Try:Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
It looks like the pack....idx file has been marked read-only and if I go to the properties of that file to uncheck the read-only property then the compilation can continue to another idx file with the same problem (eventually it starts again with the first file, in a loop).

Related

A problem occurred configuring project ':CordovaLib

When I try to compile using
ionic cordova build --release android
I get the following error message...What might be the reason..
BUILD FAILED in 0s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
* 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 0s
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
It depends on what version of the Android NDK you are using. The suppport for MIPS and MIPS64 abis was stopped in NDK r17 (see Android NDK official documentation). This is because MIPS-based Android devices are completely obsolete. You need to use NDK r16 or older for it to work. You can download older NDK releases here. Alternativeley, as suggested here, you can just copy the corresponding directories from the NDK r17 (or older) in the r18 ndk-bundle/toolchains. The ones in the r17 are actually empty with a little notice that says that the directories were left there for compatibility. This last option is what I have done and it worked for me.
Its the problem with NDK tool chains file missing in NDK bundle, to resolve this issue make sure you properly install the NDK bundle, still if you cant fine try to download externally and place in the right path.
If your not using NDK tools for your app you can remove the entire folder of NDk and it will work fine with a warning message that NDK tools files missed

Gradle works with Android Studio but cmd script fails

I freshly installed Android Studio and created a HelloWorld project. It works fine. But when I tried to build it via commandline gradlew script found in the project directory it first gave me the error that java is not installed.
After installing the java its now giving me the error:
FAILURE: Build failed with an exception.
What went wrong: Could not determine java version from '11.0.1'.
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
Following image shows the java version and the command I executed:
Note: I am running it on a Mac with MacOS High Sierra (10.13.6)
This had something to do with my gradle version. I set the version to the latest by going to Project Structure selecting Project from side menu and set the Gradle version to 4.10.2.

Android Build Failing with Command, but not in Android Studio

I'm learning React Native and all of sudden my Android build has started to fail. When I type the command 'react-native run-android' the build fails with following error
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':app'.
java.lang.NullPointerException (no error message)
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 1s Could not install the app on the device, read the
error above for details. Make sure you have an Android emulator
running or a device connected and have set up your Android development
environment:
https://facebook.github.io/react-native/docs/getting-started.html
I have closed and re-opened the terminal, emulator, and Android Studio and made sure that the emulator is running before typing the command. But the build still fails. However if I go into Android Studio and click the 'Play' button (Run App), and the build succeeds and my App is displayed on the Android emulator.
I have also tried copying my project to another folder and all of the same errors still occur. Not a pressing issue, more just of an annoyance so if you have any suggestions that'd be great :)
Same error occurs for me when i change gradle version in build.gradle file.
This error of NullPointerException occurs when the version in build.gradle does not match the version installed in your project root folder.
Then change to the same version resolved the error.

WSL gradle pre-pending current directory to Android SDK path

I have set the terminal on Android Studio to use WSL, specifically the Ubuntu one. Running builds from the IDE provided buttons works fine for my project. I decided to start using the terminal more and would prefer to run the builds from there, so I tried running
./gradlew tasks
at the root of the project to test out the Gradle I had installed with sdkman in WSL, but I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/mnt/c/Users/Henry-PC/Desktop/DJ-Cloud/C:\Users\Henry-PC\AppData\Local\Android\Sdk' does not exist.
* 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 0s
Any ideas as to what is wrong with?
Just had this issue myself, I had a local.properties file that specified an incorrect directory.
After removing it entirely gradle is able to locate the Android SDK using the exported ANDROID_HOME environment variable

java.security.NoSuchAlgorithmException while building a simple android app using Android Studio

I downloaded the Android Studio and trying to build a simple Login Activity. But the Make Project fails with this error.
Environment: Windows 7 64 bit
Gradle:
trouble writing output: java.security.NoSuchAlgorithmException: SHA-1 MessageDigest not available
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':MyApp:dexDebug'.
Running C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat failed. See output
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I have made sure the Gradle zip was downloaded and installed properly
Any hints what else should I check for?
I was using IBM JDK. Switching to Sun/Oracle JDK fixed the problem.

Resources