Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android cmake arguments method not found [duplicate]

I am trying to add arguments to cmake in order to follow the Android NDK instructions for using the address sanitiser. In the build.gradle file for the native module I therefore have the following:

externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
            arguments "-DANDROID_ARM_MODE=arm", "-DANDROID_STL=c++_shared"
            cppFlags "-fsanitize=address -fno-omit-frame-pointer"
        }
    }

When I try to sync my project (Android Studio v. 3.4.2, Win10) I get the error message:

ERROR: Gradle DSL method not found: 'arguments()'

I've searched the web but can't find any other mention of this problem with the 'arguments' method. I'm using gradle 3.4.2.

What am I missing?

like image 596
Timmy K Avatar asked Aug 05 '19 14:08

Timmy K


1 Answers

There are two different Gradle DSL objects both named externalNativeBuild, but with different properties. See this and this.

So you need to set the appropriate properties on the appropriate object:

android {
    defaultConfig {
        externalNativeBuild {
            cmake {
                arguments "-DANDROID_ARM_MODE=arm", "-DANDROID_STL=c++_shared"
                cppFlags "-fsanitize=address -fno-omit-frame-pointer"
            }
        }
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}
like image 146
Michael Avatar answered Oct 10 '22 04:10

Michael