I have an android library project that builds lib.aar artefact and an app project that imports this lib.aar after it was built. lib.aar requires NDK 17 to be built since it has some C++ 17 code.
I manage to build .aar file successfully but the app fails to compile with this message:
A problem occurred starting process 'command '/Users/user/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-strip''.
This is caused by the fact that NDK 17 removed support for MIPS and I can't upgrade to a newer version of android studio that uses NDK 18beta
If I remove the content of '/Users/user/Library/Android/sdk/ndk-bundle' folder, deleting the NDK, then the app builds without errors and I can use lib.aar code inside the app.
So far I've tried this: How do I disable the NDK build in Android Studio 1.0.1 , this https://gist.github.com/ph0b/9e59058ac59cac104398 . Setting env variable ANDROID_NDK_HOME to a dummy folder works, the app builds, but it's kind of a hack.
Is there any way to programmatically disable NDK build for the app project without deleting NDK folder?
This is caused by the fact that NDK 17 removed support for MIPS and I can't upgrade to a newer version of android studio that uses NDK 18beta
r18 won't fix this problem either; it still doesn't have mips support. The fix to the problem is upgrading the gradle plugin version in your application to at least 3.1, which is the minimum required for NDK r17 (and, extremely unfortunately, is required for even having the NDK installed for some reason).
The other solution here would be to install NDK r16b somewhere and then point at it from the app's local.properties, letting the aar pick from the SDK. If you're just working on a local build this will work, but since local.properties shouldn't be checked in to version control it won't help others much.
Related
I am trying to build an old project and something has changed where the project tries to target mips64el-linux-android. I don't reference this build targets within in build variants and it's not the sdk build version I specify in the project properties panel. Even so, I do have the native sdk installed so it should build in this case.
Any ideas?
1.Donwload NDK package
2.Open the "toolchains" folder after unzipping
3.Compare with android-sdk->ndk-bundle->toolchains folder
4.Find the missing folder and copy it in the past
5.Recompile
Which NDK version are you using? Google has dropped mips support in NDK r17.
You need to download older NDK for older projects. I use NDK r10e and sometimes r14 for my older projects. If project is too old you can try with r10.
In your project build script you need to specify downloaded NDK's path. You need to download and manually extract NDK (I believe Android Studio will not download older version).
I am constantly getting this warning while building my android studio code using terminal command gradle clean assembleRelease:
Unable to strip library 'lib.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Please help me on how to get this warning resolved.
Note: I know this won't affect the behaviour of my app, but my APK is too bulky and this will surely help me reduce APK size. So I need this resolved.
The default installed NDK doesn't seem to have the tools required to strip binaries that have been built with ARMEABI support, so it ends up packaging the whole library, which increases the built file size substantially.
I've found that installing the "NDK (Side by side)" tool from Android Studio -> Tools -> SDK Manager -> SDK Tools takes care of this warning and also reduces the built APK size, especially for React Native projects.
Steps to install NDK (Side by side)
Open Android Studio
Click Configure/ Tools
Click SDK Manager
Click SDK Tools tab
Select below:
NDK (Side by side)
CMake
Android SDK Command-line Tools (latest)
Apply
NOTE: Android SDK Command-line Tools (latest) is not needed but I installed it so that I don't have to search for more solutions, today has been a lot of troubleshooting to run a new React Native app.
More info: https://developer.android.com/studio/projects/install-ndk
You can try using the following configuration in app/build.gradle.
android {
packagingOptions {
// exclude ARMEABI native so file, ARMEABI has been removed in NDK r17.
exclude "lib/armeabi/**"
}
}
Remove (or make optional) MIPS native library #3504
Android-ABIs
A possible solution specifically for React Native:
I got this problem when trying to build my React Native application from the command line by executing cd android/ && ./gradlew assembleDebug (without having Android Studio open).
I opened Android Studio, I built the app there and it automatically fixed the problem. Once I tried again by command line the problem was not happening anymore.
I'd like to combine all the existing answers and add some more explanation/details.
First of all, just like other people mentioned, check that you have Android NDK installed (NDK (Side by side) in Android Studio -> Tools -> SDK Manager -> SDK Tools). But it's still not enough to fix this warning.
There's a list of supported ABIs by Android NDK and it has a note saying that 'armeabi' is no longer supported:
Historically the NDK supported ARMv5 (armeabi), and 32-bit and 64-bit MIPS, but support for these ABIs was removed in NDK r17.
So, if your app needs to support ARMv5/6 devices (which is unlikely - those are pretty old), you should either:
Use older NDK <r17 that supports 'armeabi' ABI (choose another version in SDK Manager)
Ignore the warning. In this case, the library will still work on older devices even with newer NDK but will be packed in APK for every ABI, including the newer ones (which leads to increased APK size)
If there's no need in supporting ARMv5/6, you might still want to support ARMv7 ABI 'armeabi-v7a'. Once again, there are two options:
Recompile the shared library with a newer Android NDK that supports 'armeabi-v7a' ABI
(Not recommended) Rename 'armeabi' folder to 'armeabi-v7a' (I'm not sure whether libraries for these ABIs are compatible or not)
If the library doesn't belong to you, you should probably ask its maintainer to fix it.
But if there's no need in supporting even ARMv7, feel free just to exclude the libraries:
android {
packagingOptions {
exclude "lib/armeabi/**"
}
}
I updated Android Studio and now my project won't compile. The project uses Java and C++ (with JNI) and includes some .so libraries. The reason it wouldn't compile at first was because it said GCC is no longer supported. I updated it to Clang, but now it's saying that it can't find functions that exist in the .so libraries (undefined reference errors). From what I've been reading, Clang cannot link to libraries compiled in GCC. I'm not sure I'm in a position to attempt to recompile all the libraries in Clang.
What do I have to install/uninstall to get Android Studio back to supporting GCC? Or is it possible to make Clang work with GCC'd libraries?
According to the NDK Revision History, the last version that still allowed GCC was r17c (unsupported, but not removed). I downloaded this version from the NDK Archives, uninstalled the latest NDK using SDK Manager, and unzipped r17c's contents into the "./SDK/ndk-bundle" folder. I am now able to compile my project again, having reverted back to using GCC.
I downloaded the latest cocos2dx(3.10) and NDK(r11). I have the following error when I executed cocos compile -p android --android-studio.
Error:
~/AndroidDev/android-ndk-r11/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++: No such file or directory
Then I found in NDK Revision History here for r11 the following:
Removed GCC 4.8. All targets now use GCC 4.9.
Are there workarounds to switch cocos2dx settings to 4.9?
In your NDK directory create RELEASE.txt file and enter the version, e.g.
r11c (64-bit)
I also had the same problem and I solved it by downgrading my NDK to the 10 version. I think Cocos2d-X may not be compatible with the NDK 11, since the RELEASE.txt file is missing from it.
I started with NDK 11 which didn't work. Possible problem as you told is RELEASE.txt doesn't exist for that but then I downgraded to NDK 10e, still didn't work even though RELEASE.txt was present. Then I had to downgrade to NDK 9d which worked without any modifications.
I'm trying to build a project in Android Studio that targets API16 (Android version 4.1.2). Using the SDK manager I was able to download that SDK platform but an exception is raised at compile-time as it's trying to parse a compiled .jar file:
bad class file magic (cafebabe) or version (0034.0000)
My understanding of this issue is that I need the build tools to match the API version I'm targeting (since I currently only have the most recent version of the build tools). However, I am unable to install them because they're unavailable in both the SDK manager and on the Android website (http://developer.android.com/tools/revisions/build-tools.html). Is there another way to install this version of the build tools? (Alternatively, if installing that version of the build tools is unnecessary, how do I resolve this issue?)
This is a problem with the Java version (i.e. the version the jar, or rather the class files inside it, was compiled with). It actually has nothing to do with the Android version.
0x34 means the jar was compiled with Java 8 (see the list of possible values here). Android can only use jars compiled as Java 6.
If you have the sources for this library, you should recompile it again with the -target 1.6 flag.