[Android Studio] NDK not configured when cocos plugin is used

I’ve managed to compile new cocos 3.7 project under Android Studio (not easy though).
When I add Facebook plugin in the project then this compilation error occurs:

Skipping task ':libcocos2dx:compileDebugAidl' as it is up-to-date (took 0.008 secs).
:libPluginProtocol:compileReleaseNdk UP-TO-DATE
:libcocos2dx:compileDebugAidl (Thread[Task worker Thread 3,5,main]) completed. Took 0.011 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libPluginProtocol:compileReleaseNdk'.
> NDK not configured.
  Download the NDK from http://developer.android.com/tools/sdk/ndk/.Then add ndk.dir=path/to/ndk in local.properties.
  (On Windows, make sure you escape backslashes, e.g. C:\\ndk rather than C:\ndk)

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

I’ve added the plugin in the projects with “Import Module” and then selecting the corresponding proj.android folder.

What I’ve tried:

  1. setting the same compile/target/min sdk/tools versions for all modules (copying the values from previously working module)
  2. Adding ndk.dir to my project local.properties
  3. Adding ndk.dir to libPluginProtocol local.properties

I’m compiling from the command line: cocos compile -p android --android-studio

Environment: cocos-js 3.7, ndk=r10c

answer is to set system variable ANDROID_NDK_HOME.
In my case: export ANDROID_NDK_HOME=$NDK_ROOT.

Can you list the steps you took to compile and run 3.7 with Android Studio ? I’ve been struggling to get it working. While compilation seems to succeed without problems, when I try to run on a device, I get a message saying “Unfortunately libcocos2dx has stopped working”. It seems to keep trying to launch libcocos2dx as the app instead of the actual app.

did you compile it like this?

cocos compile -p android --android-studio

See more here: How to use v3.7 pro.android-studio?

@pepeek Yes I did it like that.