Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External Native Build Issue with Phimp.me project

I am trying to import an Android project. When building the project following errors are shown:

Error: Caused by: org.gradle.api.GradleException: executing external native build for ndkBuild
/mnt/FE78E94378E8FAF3/AndroidProject/phimpme-android/app/src/main/jni/Android.mk
at com.android.build.gradle.internal.ExtraModelInfo.handleIssue(ExtraModelInfo.java:114)
at com.android.builder.core.ErrorReporter.handleSyncError(ErrorReporter.java:80)

enter image description here

I have installed NDK, OpenCV, PhotoView as mentioned. I have tried all the StackOverflow posts related to external native build. I am not able to get rid of this error.

Build.gradle(app)

apply plugin: 'com.android.application'
apply plugin: 'jacoco-android'
apply plugin: 'realm-android'

def keystorePropertiesFile = rootProject.file("sample_keystore.properties")

def keystoreProperties = new Properties()

keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "org.fossasia.phimpme"
        minSdkVersion 17
        targetSdkVersion 25
        multiDexEnabled true
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
        vectorDrawables.useSupportLibrary = true
        resConfigs "en"
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
    }

    sourceSets {
        main {
            jni.srcDirs = ['src/main/jni']
            jniLibs.srcDirs = ['src/main/jni/libs']
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


        }
        debug {
            testCoverageEnabled false

        }
    }

    packagingOptions {
        exclude 'META-INF/maven/org.apache.maven/maven-artifact/pom.xml'
        exclude 'licenses/javolution.license.TXT'
        exclude 'META-INF/maven/org.apache.maven.wagon/wagon-http-shared/pom.properties'
        exclude 'META-INF/maven/*'
        exclude 'org/codehaus/classworlds/uberjar/boot/Bootstrapper.class'
    }

    configurations {
        compile.exclude group: 'org.jetbrains', module: 'annotations'
        all*.exclude group: 'com.android.volley'
    }

    lintOptions {
        abortOnError false
        disable "Instantiatable"
    }

    tasks.withType(JavaCompile) {
        configure(options) {
            // TODO
            compilerArgs << "-Xlint:unchecked"
            compilerArgs << "-Xlint:-rawtypes"
        }
    }

    dexOptions {
        jumboMode = true
    }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
}

repositories {
    maven {
        url "https://dl.bintray.com/dasar/maven"
    }
    mavenCentral()
    maven {
        url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    }
    maven { url "https://jitpack.io" }

    maven { url 'https://maven.fabric.io/public' }

    maven { url "https://mvnrepository.com/artifact/com.box/box-android-sdk" }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    //google and support
    compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:design:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
    compile "com.android.support:palette-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:customtabs:$rootProject.supportLibraryVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    //exoplayer
    compile 'com.google.android.exoplayer:exoplayer:r1.5.7'

    //utils
    compile 'com.github.deano2390:MaterialShowcaseView:1.1.0'
    compile "com.jakewharton:butterknife:$rootProject.butterknifeVersion"
    annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterknifeVersion"
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.yalantis:ucrop:1.5.0'
    compile 'de.psdev.licensesdialog:licensesdialog:1.8.0'
    /*compile('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
        transitive = true;
    }*/
    compile 'com.daksh:loglr:1.2.1'
    compile 'com.koushikdutta.ion:ion:2.1.7'
    compile 'org.jetbrains:annotations-java5:15.0'
    compile 'com.android.support:multidex:1.0.1'
    compile group: 'com.box', name: 'box-android-sdk', version: '4.0.8'

    //icons
    compile 'com.mikepenz:iconics-core:2.8.4@aar'
    compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    compile 'com.mikepenz:community-material-typeface:1.5.54.2@aar'
    compile 'com.mikepenz:fontawesome-typeface:4.6.0.1@aar'
    compile 'com.mikepenz:ionicons-typeface:+@aar'

    //ui
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'uz.shift:colorpicker:0.5@aar'
    compile 'com.turingtechnologies.materialscrollbar:lib:10.0.3'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
    compile 'com.github.shchurov:horizontalwheelview:0.9.5'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'

    //twitter
    compile "com.twitter.sdk.android:twitter:$rootProject.twitterVersion"
    compile files('libs/twitter4j-core-3.0.5.jar')
    compile files('libs/twitter4j-media-support-3.0.5.jar')

    //cloud rail
    compile 'com.cloudrail:cloudrail-si-android:2.20.1'

    //next cloud
    compile "com.github.nextcloud:android-library:$rootProject.nextCloudVersion"

    //leak canary
    debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'

    //flickr
    compile files('libs/flickrj-android-2.1.0.jar')

    //tumblr
    compile('com.tumblr:jumblr:0.0.11') {
        exclude module: 'scribe'
    }

    //realm
    compile 'com.uphyca:stetho_realm:2.0.0'

    //metadataextractor
    compile 'com.drewnoakes:metadata-extractor:2.9.1'

    //tests
    testCompile "junit:junit:$rootProject.junitVersion"
    androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'

    //opencv
    compile project(':openCVLibrary24133')

    //pdk
    compile project(':pdk')

    //photoview
    compile project(':photoview')

    //compressor
    compile 'id.zelory:compressor:2.1.0'

}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'jacoco-android'
like image 448
Anubhav Gupta Avatar asked Sep 09 '18 17:09

Anubhav Gupta


1 Answers

The key problem here is that you either don't have OpenCV SDK installed on your host machine or wrongly refer to the SDK in the project. The steps are as follows:

  • once you got the project imported in Android Studio navigate to the app's build.gradle file to check the version of OpenCV used in the project which is 2.4.13.3;
  • now go to the OpenCV's download page and download the 2.4.13.3 archive. Unpack it once downloaded;
  • navigate to project/app/src/main/jni/Android.mk and specify the path to the OpenCV sdk installed in the following way:

    LOCAL_PATH := $(call my-dir)
    OPENCV_SDK_PATH := anubhav_gupta_s_path_to/OpenCV-android-sdk/sdk/native/jni
    ....
    include $(OPENCV_SDK_PATH)/OpenCV.mk
    
  • build the project and follow the Android Studio's prompts.

enter image description here

like image 106
Onik Avatar answered Nov 07 '22 15:11

Onik