Android Studio "Current NDK support is deprecated"
Asked Answered
R

4

25

As of Jan 2015 the NDK support for Android studio is still unusable. A cryptic message says: "Alternative will be provided in the future."

I'd like to know what's gradle/google direction on this is since it's impossible to plan a proper development plan at the moment.

Version 0.7+: They suggested to still use ndk-build / ant Version 0.8+: They've introduced a minimal NDK support Version 1.0.0: It looked like NDK support was going to be official Version 1.0.2: It now looks like NDK support is deprecated.

My questions are:

  • Is everyone reverting to ndk-build and hand made android.mk files?

  • Is anyone using the currently deprecated method on 1.0.0+ (gradle ndk support) on a serious size project?

  • What sort of direction the "Alternative will be provided in the future" would go? Is is possible for any insider to answer that without breaking any company rules?

Edit: it's not a duplicate because it was referring to the evolution of Android Studio and NDK, the other question refers to a very ancient version of Android Studio as I've detailed in my post the NDK support has changed drastically from version to version without a clear direction, up to now with the release of 1.3

Reid answered 27/1, 2015 at 16:10 Comment(8)
ph0b.com/android-studio-gradle-and-ndk-integrationLozano
Thanks I've seen that link already but it didn't answer any of my questions unfortunately.Reid
"NDK support for Android studio is still unusable" it is just a warning, are you having other problems that make it unusable?Bria
Here's a bit of 'official' word about gradle+ndk: code.google.com/p/android/issues/detail?id=82187Ormuz
Android Studio 1.3 at Canary channel fully supports NDK now. Reference: tools.android.com/download/studio/canary/latestBeeler
possible duplicate of Android studio, gradle and NDKDhoti
June 18th, 2015: Android Studio 1.3 Beta is now available in the beta channel! Sorry, this build does not yet contain the C/C++ support; source: tools.android.com/recent/androidstudio13betaavailableJequirity
related #28175393Platus
M
12

Update from Google I/O 2015

Android Studio v1.3 Preview - We are releasing a new version of Android Studio. Most notable is a much requested feature from our Android NDK & game developers: code editing and debugging for C/C++ code. Based on JetBrains Clion platform, the Android Studio NDK plugin provides features such as refactoring and code completion for C/C++ code alongside your Java code. Java and C/C++ code support is integrated into one development experience free of charge for Android app developers. Update to Android Studio v1.3 via the Canary channel and let us know what you think.

Source from android developers blog here.


New Update 30/7/2015 -> Android Studio v1.3 Released

As a part of the Android 1.3 stable release, we included an Early Access Preview of the C++ editor & debugger support paired with an experimental build plugin. See the Android C++ Preview page for information on how to get started. Support for more complex projects and build configurations is in development. enter image description here

Quoted from android developers blog here.

Added Features:

  • Code completion
  • Code navigation (go to declaration, jump between header and implementation, etc)
  • Quick fixes
  • Intentions
  • Refactoring
  • Source format
  • Debugging
  • ...

For steps on how to use it, look here.

Mraz answered 4/6, 2015 at 10:36 Comment(0)
B
8

I invoke the command line, not sure where I got this from, it's basically your first option, reverting to ndk-build with hand made android.mk. Fine if you don't want to control ndk abiFilters by product flavour.

apply plugin: 'com.android.library'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion

        ndk {
            moduleName "glues"
        }
    }

    sourceSets.main {
        jniLibs.srcDir 'src/main/libs' //set .so files location to libs
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
        def ndkDir = android.ndkDirectory
        commandLine "$ndkDir/ndk-build",
                '-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
                '-j', Runtime.runtime.availableProcessors(),
                'all',
                'NDK_DEBUG=1'
    }

    task cleanNative(type: Exec, description: 'Clean JNI object files') {
        def ndkDir = android.ndkDirectory
        commandLine "$ndkDir/ndk-build",
                '-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
                'clean'
    }

    clean.dependsOn 'cleanNative'

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn buildNative
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
}

I only see those warnings if I setup abiFilter on the productFlavors:

productFlavors {
    x86 {
        ndk {
            abiFilter "x86"
        }
    }
    mips {
        ndk {
            abiFilter "mips"
        }
    }
    armv7 {
        ndk {
            abiFilter "armeabi-v7a"
        }
    }
    arm {
        ndk {
            abiFilter "armeabi"
        }
    }
    fat
}

Note, older gradle plugin versions used android.plugin.ndkFolder rather than android.ndkDirectory. For more info, see: http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0

Bria answered 17/2, 2015 at 16:36 Comment(2)
Thanks @JoeBowbeer for edit suggestion. It got rejected by others, but I put comment at bottom and as soon as I can verify myself I'll incorporate edit myself.Bria
So I've just seen you work for google @JoeBowbeer and mainly answer android questions. I think I'll apply your edit first and verify later! ThanksBria
H
4

NDK will be fully supported since Android Studio 1.3, including native debugging.

Honghonied answered 29/5, 2015 at 3:31 Comment(2)
Yes, I also got this yesterday from Google I/O 2015. Great!Darlington
@bmaupin, sorry, my bad. The original link I've got the news from is this: "Today, Google has announced Android Studio 1.3, a new version of the IDE with built-in support for the NDK. Google says the plugin is based on the JetBrains CLion platform and that it will be available free of charge to all Android developers." (arstechnica.com/gadgets/2015/05/…)Amero
S
0
android.useDeprecatedNdk=true

in your gradle.properties

Swag answered 4/11, 2015 at 5:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.