Alexandru Costin
Alexandru Costin

Reputation: 31

Could not find method path() for arguments

Please someone help me, I'm stuck here.

apply plugin: 'com.android.application'

android{

compileSdkVersion 26
buildToolsVersion "28.0.3"

defaultConfig {
    applicationId "com.glitchrun.sapphire"
    minSdkVersion 14
    targetSdkVersion 26

    externalNativeBuild {
        ndkBuild {
            path "$projectDir/jni/Android.mk"
        }
    }

    externalNativeBuild {
        ndkBuild {
            arguments "NDK_APPLICATION_MK:=$projectDir/jni/Application.mk"
            abiFilters "armeabi-v7a", "armeabi", "arm64-v8a", "x86"
            cppFlags "-frtti -fexceptions"
        }
    }

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

dependencies {
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile files('libs/support-v4-19.0.1.jar')
}

This is my error and I don't know what to do.

Could not find method path() for arguments [C:\Users\costy\AndroidStudioProjects\android\app/jni/Android.mk] on object of type com.android.build.gradle.internal.dsl.ExternalNativeNdkBuildOptions.

I'm trying to export a .apk file and I was stuck with the Deprecated NDK problem. Now I'm stuck with this problem.

Upvotes: 3

Views: 2851

Answers (1)

Michael
Michael

Reputation: 58467

The externalNativeBuild block that specifies the makefile path should not be part of defaultConfig, but of its android parent:

android {
    compileSdkVersion 26
    // etc...

    defaultConfig {
        applicationId "com.glitchrun.sapphire"
        // etc...

        externalNativeBuild {
            ndkBuild {
                arguments "NDK_APPLICATION_MK:=$projectDir/jni/Application.mk"
                abiFilters "armeabi-v7a", "armeabi", "arm64-v8a", "x86"
                cppFlags "-frtti -fexceptions"
            }
        }
    }

    // etc...

    externalNativeBuild {
        ndkBuild {
            path "$projectDir/jni/Android.mk"
        }
    }
}

The inner one is used to modify ExternalNativeBuildNdkOptions, while the outer one is used to modify NdkBuildOptions.

[Edit by @grebulon] There seem to be a mistake in the links. See: ExternalNativeBuild and ExternalNativeBuildFlags

Upvotes: 3

Related Questions