5

I have multiple projects I'm working on, and some require NDK to be installed. When I do that in the SDK manager, all my non-NDK projects fail to generate the APK unless I removed NDK on the SDK manager. I tried specifying and removing the NDK path, in my local.properties, nothing does it, I need to completely remove it from Android Studio to be able to generate the APK, then re-download it and enable it for my NDK projects, which is pretty absurd. Any way around this??

Hey'Youssef
  • 285
  • 4
  • 15
  • have you check this https://stackoverflow.com/questions/46136225/how-does-one-disable-c-c-support-for-a-project-in-android-studio – AskNilesh Jun 19 '18 at 12:44
  • 1
    What kind of "fail to generate the APK" do you experience? Please post the relevant error message (maybe, it's hidden in the log file). OTOH, you can download NDK to a non-standard directory (i.e. not to `Android/sdk/ndk-bundle`, and set it in **local.properties** manually only for relevant projects. – Alex Cohn Jun 19 '18 at 13:38
  • @NileshRathod yes I have checked that and nothing worked. – Hey'Youssef Jun 19 '18 at 15:14
  • @AlexCohn Sure Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command '\AppData\Local\Android\Sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip'' . it happened when trying to transform the native libs for some reason: :app:transformNativeLibsWithStripDebugSymbolForAppRelease'. I have no c++ code, and no reference to it or NDK, if I remove NDK the APK is generated just fine, I don't know why it adds this extra step on its own. – Hey'Youssef Jun 19 '18 at 15:18

1 Answers1

8

cannot run mips64el-linux-android-strip

This is a known problem, which happens when you have the latest NDK r.17 and don't 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

The workarounds include using NDK r.16 or excluding the mips strips *)

packagingOptions {
    doNotStrip '*/mips/*.so'
    doNotStrip '*/mips64/*.so'
}

*) as @Forgen correctly updated, packagingOptions was not available for Android gradle plugin earlier than v.2.3. But if you are still using such version, you have problems much more serious than mips64, and should upgrade ASAP.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • That makes sense to me, because it only happens on one select project that uses an old gradle plugin, thanks Alex. – Hey'Youssef Jul 04 '18 at 12:49
  • 1
    Also couldn't build due to NDK mismatch. Didn't follow the exact steps here, but upgrading the gradle plugin to latest worked. – reden Aug 06 '21 at 07:44