Gradle无法编译NDK文件

时间:2019-01-26 19:31:35

标签: android android-ndk

我从github上获得了一个项目(一个Android应用程序)的源代码,并且正在尝试启动它,该项目称为“ RtkGps +”,这是一个Anroid应用程序,它使用名为Rtklib的C ++库与GPS和Raw一起玩测量。

我的Android环境配置如下,

Gradle version : 3.1.3
NDK revision : 19.0.5232133

我无法编译项目,但出现以下错误:

Errors Screen Capture

如截图所示,我想列举很多错误,

  • 第一个是这个错误,其中NDK_PROJECT_PATH = null
SIMPLE: Error while executing process C:\Users\Yazid\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\jni\Android.mk NDK_APPLICATION_MK=C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\jni\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-21 NDK_OUT=C:/Users/Yazid/Documents/Dev/Android/RtkGps-master/RtkGps-master/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\build\intermediates\ndkBuild\release\lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}

  • 第二个说法是不支持Android.mk文件
SIMPLE: Android NDK: WARNING: Unsupported source file extensions in C:\Users\Yazid\Documents\Dev\Android\RtkGps-master\RtkGps-master\jni\Android.mk for module rtklib    

我尝试从此答案中添加gradle代码:https://stackoverflow.com/a/50707270/6306138

项目的Gradle文件。

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    jcenter()
    google()
}

dependencies {
    implementation  group: 'cz.msebera.android' , name: 'httpclient' , version: '4.4.+'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.google.gms:google-services:3.2.1'
    implementation 'com.google.android.gms:play-services-gcm:11.0.4'
    implementation 'com.google.code.findbugs:jsr305:3.0.2'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.jakewharton:butterknife:8.8.1'
    implementation 'com.karumi:dexter:5.0.0'
    implementation 'ch.acra:acra:4.5.0'
    implementation 'commons-net:commons-net:3.6'
    implementation 'org.slf4j:slf4j-api:1.7.25'
    implementation 'com.infstory:proguard-annotations:1.0.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}

android {
    sourceSets.main.res.filter.exclude '**/proj4/jniwrap/org/**'

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "gpsplus.rtkgps"
        minSdkVersion 21
        targetSdkVersion 26
        multiDexEnabled true
        ndk {
            abiFilters = []
            abiFilters.add('armeabi-v7a')
            abiFilters.add('x86')
            abiFilters.add('x86_64')
            abiFilters.add('arm64-v8a')
        }
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDir 'libs'
        }

           //    instrumentTest.setRoot('tests')
    }
    externalNativeBuild {
        ndkBuild {
            path 'jni/Android.mk'
        }
    }
    packagingOptions{
        doNotStrip '*/mips/*.so'
        doNotStrip '*/mips64/*.so'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        debug {
            debuggable true
            jniDebuggable false
            renderscriptDebuggable false

        }

    }
    productFlavors {
    }
}


1 个答案:

答案 0 :(得分:0)

提到的“错误”都不是错误。 NDK_PROJECT_PATH=null是Studio的正常行为,第二个只是警告。

没有看到您的Android.mk或完整的错误消息(包含的错误之后的行会告诉您出了什么问题),我无法告诉您如何解决该警告,但是就像警告中说的那样,源文件具有无法识别的扩展名,因此ndk-build不知道如何构建它。