3

This is for an Android project using JNI with the NDK. I'm building the project with Android Studio 3.0.1. I recently updated my NDK from version 16 to version 17 in the hopes of making more compiler optimizations available. After the update, I'm getting the following errors:

CMake Error at C:/Users/John/AppData/Local/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake:312 (message): Invalid Android ABI: armeabi. (armeabi is no longer supported. Use armeabi-v7a.) Call Stack (most recent call first): C:/Users/John/AppData/Local/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98 (include) CMakeLists.txt CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

I'm getting this error for each of the deprecated ABIs armeabi, mips, and mips64. I understand that I should remove these ABIs from the build, but I can't find instructions on how to do that. I'm not using an Application.mk and I don't see the ABIs being specified anywhere; how can I remove these unused ABIs from my Android Studio project, or better yet, how can I set my project to just use the current non-deprecated ABIs? Thank you.

Gunnar
  • 225
  • 3
  • 13

1 Answers1

5

It should be enough to upgrade your gradle plugin to 3.1.2 or higher, in root (project) build.gradle script. Using the latest plugin is recommended not only to be compliant with latest NDK:

buildscript {
  dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
  }
}

You also must change gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip v.4.4

If you cannot afford such change, you may try to skip the deprecated ABIs for build and packaging:

android {
  defaultConfig {
    ndk {
      abiFilters 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
    }
  }

  packagingOptions {
    doNotStrip '*/mips/*.so'
    doNotStrip '*/mips64/*.so'
  }
}
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Thank you Alex. I'm getting "Could not find com.android.tools.build:gradle:3.1.2." I have a notice that says "Platform and Plugin Updates\nAndroid Studio is ready to update" - should I go ahead and try that? – Gunnar Jun 20 '18 at 16:55
  • Or there's another link that says "Add Google Maven repository and sync project" - I guess that's my better option? – Gunnar Jun 20 '18 at 16:58
  • Alright, after spending a big chunk of time updating everything and googling other errors that come up, I'm able to build again - and of course, the new compiler still doesn't support -march=native. Sigh. Anyway, your advice helped so I'm marking yours as the correct answer, thank you. – Gunnar Jun 20 '18 at 17:44
  • I believe that NDK takes care of choosing the optimization options quite well for each ABI and platform, so `-march=native` is probably not necessary here. – Alex Cohn Jun 20 '18 at 20:06