NDK is missing a "platforms" directory. while trying to build
Asked Answered
A

7

16

Executing tasks: [clean]

Configuration on demand is an incubating feature. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/ishandutta2007/Library/Android/sdk/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

    java.lang.NullPointerException (no error message)

  • Try: Run with --info or --debug option to get more log output.

  • Exception is: org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'. at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:87) at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:82) at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:69) at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:33) at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:103) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:49) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:651) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:133) at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35) at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62) at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:100) at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:81) at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42) at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:44) at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48) at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25) at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54) at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44) at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48) at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25) at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54) at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47) at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48) at org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:36) at org.gradle.initialization.DefaultGradleLauncher$CalculateTaskGraph.run(DefaultGradleLauncher.java:265) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.initialization.DefaultGradleLauncher.constructTaskGraph(DefaultGradleLauncher.java:173) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:128) at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:107) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75) at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152) at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100) at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75) at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40) at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:45) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29) at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39) at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:71) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45) at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51) at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32) at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36) at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25) at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43) at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29) at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64) at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29) at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55) at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42) at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:58) at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:33) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:782) at com.android.build.gradle.internal.ndk.NdkHandler.getPlatformVersion(NdkHandler.java:158) at com.android.build.gradle.internal.ndk.NdkHandler.supports64Bits(NdkHandler.java:331) at com.android.build.gradle.internal.ndk.NdkHandler.getSupportedAbis(NdkHandler.java:397) at com.android.build.gradle.tasks.ExternalNativeJsonGenerator.create(ExternalNativeJsonGenerator.java:609) at com.android.build.gradle.internal.TaskManager.createExternalNativeBuildJsonGenerators(TaskManager.java:1532) at com.android.build.gradle.internal.ApplicationTaskManager.lambda$createTasksForVariantScope$10(ApplicationTaskManager.java:205) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81) at com.android.build.gradle.internal.ApplicationTaskManager.createTasksForVariantScope(ApplicationTaskManager.java:200) at com.android.build.gradle.internal.VariantManager.createTasksForVariantData(VariantManager.java:523) at com.android.build.gradle.internal.VariantManager.lambda$createAndroidTasks$1(VariantManager.java:338) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81) at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:334) at com.android.build.gradle.BasePlugin.lambda$createAndroidTasks$5(BasePlugin.java:627) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81) at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:622) at com.android.build.gradle.BasePlugin.lambda$null$3(BasePlugin.java:549) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81) at com.android.build.gradle.BasePlugin.lambda$createTasks$4(BasePlugin.java:545) at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91) at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80) at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42) at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230) at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149) at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58) at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324) at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234) at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140) at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy23.afterEvaluate(Unknown Source) at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:75) ... 95 more

  • Get more help at https://help.gradle.org

BUILD FAILED in 3s

build.gradle(project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId 'org.tensorflow.demo'
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName '1.0'

        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
        ndk {
            abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
        }
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    compile 'org.tensorflow:tensorflow-android:1.3.0'
}

Android Studio: 2.3.3

Amyloid answered 14/10, 2017 at 6:18 Comment(4)
Possible duplicate of How to fix android studios 2.3 NDK bug?Amyloid
Try to set compileSdkVersion "android-26"Attainture
didn't get you,it's already 26.Amyloid
Not to use a number, but literal string. And make to use latest NDK.Attainture
T
23

This probably happens because Android Studio will automatically download the latest version of NDK which doesn't have a platforms directory (No idea why! Would be awesome if someone can clarify that).

This is what worked for me. Using the SDK manager. That is the icon in the top right corner of Android Studio that looks like this SDK Manager icon. Go to SDK Tools tab. In the right bottom corner, enable Show Package Details and install NDK version 20.0.5594570 (You can remove the newer version that was installed automatically by Android Studio to save space).

SDK Manager

Note that the NDK will be installed in the location shown in Android SDK Location. For me that is set to /home/<username>/.local/android-sdk. Which means I can find the NDK at /home/<username>/.local/android-sdk/ndk/20.0.5594570/

Hit apply and when it's done go to file called local.properties and add this.

ndk.dir=/home/<username>/.local/android-sdk/ndk/20.0.5594570

Adapt the path to where you have your NDK installed.

Tgroup answered 29/12, 2020 at 13:1 Comment(2)
i had try this solution before.but it still have the same proble...And i even try open the project structure dialog,and choose the path as you give above, then alert "NDK does not cotainers any platform"....still this.Assertive
the 'platforms' dir for me was just outside the default 'ndk-bundle' folder, instead of inside it, so i simply copied it in, and it worked.... yeah 'no idea why!'... but thank you so much for the help!Madalena
F
13

Very strange, for me ndk version 22.0.7026061 indeed did not have a platforms directory. On my disk ndk version 21.1.6352462 had a platforms directory and setting

ndk.dir=/home/username/Android/Sdk/ndk/21.1.6352462

on local.properties solved the problems.

Fishhook answered 9/1, 2021 at 19:1 Comment(2)
Indeed. Neither does 22.1.7171670Convexity
I was looking for this answer for 2 days. Thank you for helping me.Alfalfa
R
3

I know this is old but just ran into this and the File -> Project Structure -> SDK Location - Android NDK Location setting was missing. Once I filled it in to the "Recommended" one it gradle sync'd fine

Rinse answered 14/2, 2020 at 17:46 Comment(0)
A
1

I finally found out the core reason, and the solution is:

  1. upgrade Gradle and AGP, and set the right NDK configuration.
  2. set ndk.dir in local.properties for lower AGP version.

Different AGP(Android Gradle Plugin) versions have different NDK configuration. And most AGP auto download higher NDK version when NDK is not configured, while higher NDK has no platforms dir, which cause an AGP error as shown in --stacktrace.

For lower AGP version, like 3.4.x, the only way is set local.properties or set NDK location in Android Studio project structure, which is also set NDK location by writing it to local.properties, too.

See docs in Android Develop for more details.

https://developer.android.com/studio/projects/configure-agp-ndk?language=agp3-5#agp-version

https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

AGP 3.4.x NDK configuration only local.properties. enter image description here

AGP 3.5.x NDK configuration support build.gradle.

enter image description here

Andesine answered 22/6, 2021 at 2:47 Comment(0)
S
0

I got the same issue, but the logs are somewhat different, from the logs I could find that it is related to NDK.

Error message that I encountered:

Caused by: java.lang.NullPointerException at com.android.build.gradle.internal.ndk.NdkHandler.getPlatformVersion(NdkHandler.java:121) 

Below are the things to check,

  1. Check if the NDK is downloaded and configured properly.

Cntrl + Alt + Shift + S, if it configured properly, you should see the location auto populated in the field.

enter image description here

If not, download update the path in local.properties file.

enter image description here

  1. Check if the gradle build tools are updated.

Open Project gradle file and make sure the dependency that you have downloaded and the dependency in the gradle file are matching.

(Hint: Create a new app, copy and past the version that is generated when you create the app.)

enter image description here

  1. When the above steps are proper, make sure to update gradle-wrapper.properties file with the proper version of gradle distribution,

Hint: If the above 2 steps are properly configured, Android Studio should suggest you to update this url as well.

enter image description here

Post this, app should build properly, without any issues.

Good Luck...!

Synthiasyntonic answered 11/1, 2022 at 9:47 Comment(1)
setting the ndkVersion from 22.xxxxx to 21.xxxxxx resolved my similar NDKHandler issue ..Amourpropre
C
-2

Configuration on demand is an incubating feature. NDK is missing a "platforms" directory.

If you are using NDK, verify the ndk.dir is set to a valid NDK directory.

It is currently set to C:\Users\MSI\AppData\Local\Android\Sdk\ndk-bundle.

If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Coverup answered 22/1, 2018 at 11:29 Comment(1)
this is by no means an answer, it is even a part of the question!Gong
H
-3

( android 5.3)We can solve it by removing android NDK plugin from your project. Go to setting ->plugin->android ndk support disable, click apply, click ok

Hargett answered 22/1, 2020 at 8:18 Comment(2)
Please consider adding some explanation and details to your answer.Oblast
Yeah, let's just disable something required for building the project...Unconnected

© 2022 - 2024 — McMap. All rights reserved.