Android Studio 2.2 and Ndk Builds: Setting build-script and compile flags

656 views
Skip to first unread message

Streets Of Boston

unread,
May 24, 2016, 9:59:32 AM5/24/16
to android-ndk
Hi,

I have a project that currently uses a custom task to execute an NDK-build. I upgraded to A.S. 2.2 and I can now remove that custom task and my sources build.
However, there are some issues


I build again API-level 23, use the latest gradle-plugin version and have these snippets in my build.gradle (it is a library-module):

defaultConfig {
    ...
    
    ndk {
moduleName "MCInterface"
cFlags "-D_____default_config_ndk_____"
}

ndkBuild {
cFlags "-D_____default_config_ndkBuild_____"
cppFlags "-D_____default_config_ndkBuild_____"
}

    ...
}


externalNativeBuild {
ndkBuild {
path file("src/main/jni/Android.mk")
cFlags += "-D__WITH_DTLS__ -D_____externalNativeBuild_____"
cppFlags "-D_____externalNativeBuild_____"
}
}

  • When running the build, the value of the 'path' property doesn't matter; it is not used at all.
    It seems the NDK_PROJECT_PATH is always "<module-root>/src/main/jni/Android.mk" and disregards the value as configured in the build.gradle.
    Leaving out the 'path' property however, will give an error.
  • 'cFlags' and 'cppFlags' properties are not used at all. They always default to some default set of values when running ndk-build.
    I tried setting them at various levels in the build.gradle, but to no avail.
  • There is no way to make the ndk-build use an Application.mk file at all. It is ignored.
How can I use a specific Android.mk and/or Application.mk file? 
If the Application.mk file is ignored, how can I tell the ndk-build to use or override certain compile and link flags/options app-wide?

Thanks,
--- Anton.
(sorry for cross-posting... i haven't gotten much feedback on the adt-dev group; this group seems a bit more active :-))

Dan Albert

unread,
Jun 1, 2016, 4:32:29 PM6/1/16
to android-ndk, Raymond Chiu
+chiur

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/587472cd-9f76-404f-93df-fb690eaeee57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raymond Chiu

unread,
Jun 1, 2016, 7:08:02 PM6/1/16
to android-ndk, ch...@google.com
I believe I answered this in adt-dev already, but just in case anyone else see this, this is a known issue and will be fixed in the next release.

nosaiba darwish

unread,
Jun 6, 2016, 3:42:34 PM6/6/16
to android-ndk, ch...@google.com
is there any estimation when the fix will come ?

Alex Cohn

unread,
Jun 13, 2016, 10:30:30 AM6/13/16
to android-ndk
With external Android.mk, it's not clear why you need explicit cFlags etc.

Alex Cohn

unread,
Jun 13, 2016, 10:30:32 AM6/13/16
to android-ndk, ch...@google.com
See http://stackoverflow.com/a/37765067/192373.

Android Studio 2.3 Preview 3 (June 10, 2016) supports 

defaultConfig {
  ndkBuild {
    arguments "NDK_APPLICATION_MK:=Application.mk"
  } 
}

… and other niceties.

BR,
Alex

nosaiba darwish

unread,
Jul 22, 2016, 10:26:15 AM7/22/16
to android-ndk
thats great thx is there anyway to enable jni debugging with this ?
Reply all
Reply to author
Forward
0 new messages