androidNdkOut and androidNdkLibsOut auto detection for library not working

Viewed 3606

Newest Fabric documentation says

If using the Android plugin for Gradle version 2.2.0+ with the externalNativeBuild DSL, you should remove the androidNdkOut and androidNdkLibsOut properties, as these paths will automatically be detected by the Fabric plugin. But it's not working for me because my native code located in library module I guess. I have native code in library module and enabled Crashlytics in app module. How can I make it work?

I am using com.android.tools.build:gradle:2.3.3 and io.fabric.tools:gradle:1.23.0.

Error:

com.crashlytics.tools.android.project.codemapping.CodeMappingException: Crashlytics could not find NDK output directory '[my app module path]/obj'. Is the -androidNdkOut setting configured correctly?

UPDATE. I moved Crashlytics configuration to my library module:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath('com.android.tools.build:gradle:2.3.3') {
            force = true
        }
        classpath 'io.fabric.tools:gradle:1.23.0'
    }
}

repositories {
    jcenter()
}

apply plugin: 'com.android.library'
apply plugin: 'io.fabric'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    publishNonDefault true

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"

        ndk {
            moduleName "core"
        }

        externalNativeBuild {
            ndkBuild {
                abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64", "mips", "mips64"
            }
        }
    }

    lintOptions {
        abortOnError false
    }

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

    externalNativeBuild {
        ndkBuild {
            path 'jni/Android.mk'
        }
    }
}

crashlytics {
    enableNdk true
    baseManifestPath '../app/src/main/AndroidManifest.xml'
}

dependencies {
    compile "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
    compile "com.google.android.gms:play-services-maps:${rootProject.ext.playServicesVersion}"
    compile "com.google.android.gms:play-services-location:${rootProject.ext.playServicesVersion}"
}

My app module now contains only dependencies:

dependencies {    
    // Crashlytics Kit
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true
    }
    // NDK Kit
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
        transitive = true
    }
}

But now I getting error

Could not find method baseManifestPath() for arguments [path to my Manifest] on object of type com.crashlytics.tools.gradle.CrashlyticsExtension.

2 Answers

I faced with same issue. I have main application module 'app' and 'library' module contains ndk sources.

Update June 2019

Last month I've been gotten an error while performing 'crashlyticsUploadSymbolsRelease' command with gradle. Seems location of libs files changed.

The following code allows me to see NDK crashes with line numbers:

crashlytics {
    enableNdk true
    androidNdkOut '../library/build/intermediates/cmake/release/obj'
    androidNdkLibsOut '../library/build/intermediates/stripped_native_libs/release/out/lib'
}

Hope it helps.

Related