Phimp.me 项目的外部本机构建问题

External Native Build Issue with Phimp.me project

我正在尝试导入一个 Android 项目。构建项目时显示以下错误:

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)

我已经安装了 NDKOpenCVPhotoView。我已经尝试了所有 Whosebugexternal native build 相关的帖子。我无法摆脱这个错误。

Build.gradle(应用程序)

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'

这里的关键问题是你的主机上没有安装OpenCV SDK,或者错误地引用了项目中的SDK。步骤如下:

  • Android Studio 中导入 project 后,导航至应用程序的 build.gradle 文件以检查 [=26] 的版本=]OpenCV项目中使用的是2.4.13.3;
  • 现在转到 OpenCV's download page 并下载 2.4.13.3 存档。下载后解压;
  • 导航到project/app/src/main/jni/Android.mk并指定OpenCV sdk的路径,安装方式如下:

    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
    
  • 构建项目并按照 Android Studio 的提示进行操作。

我已按照 README.md 文件中提到的这些步骤进行操作 - 并且能够成功构建项目 -

下载此 OpenCV-android-sdk zip 文件并解压缩。

 - Copy all the files from *"OpenCV-android-sdk/sdk/native/3rdparty"* to *"phimpme-android/app/src/main/3rdparty"* (create directory if it doesn't exist)
 - Copy all the files from *"OpenCV-android-sdk/sdk/native/libs"* to *"phimpme-android/app/src/main/jniLibs"* (create directory if it doesn't exist)
 - Copy all the files from *"OpenCV-android-sdk/sdk/native/jni/include"* to *"phimpme-android/app/src/main/jni/include"* (create directory if it doesn't exist)
 - Copy all the files from *"OpenCV-android-sdk/sdk/native/staticlibs"* to *"phimpme-android/app/src/main/staticlibs"* (create directory if it doesn't exist)
 - Now build your project. If your build fails then try deleting these build directories *"phimpme-android/app/.externalNativeBuild"* and *"phimpme-android/app/build"*, if they exist and run the build again.