简体   繁体   English

Gradle无法编译NDK文件

[英]Gradle unable to compile NDK files

I got the source of a project (An android application) from github and I am trying to launch it, the project is called "RtkGps+" it's an Anroid application to that use a C++ libary called Rtklib to play with GPS and Raw measurements. 我从github上获得了一个项目(一个Android应用程序)的源代码,并且正在尝试启动它,该项目称为“ RtkGps +”,它是一个Anroid应用程序,它使用一个名为Rtklib的C ++库来处理GPS和Raw测量。

My Android environment configuration is bellow, 我的Android环境配置如下

Gradle version : 3.1.3
NDK revision : 19.0.5232133

I'm unable to compile the project, I got the errors bellow : 我无法编译该项目,但出现以下错误:

错误屏幕截图

As shown in the the capture there are many errors, that I want to enumate them, 如图中的截图所示,我想列举很多错误,

  • So the first one is this error where the NDK_PROJECT_PATH=null 所以第一个是这个错误,其中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}

  • The second one is saying that the Android.mk file is not supported 第二个是说不支持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    

I tried adding gradle code from this answer : https://stackoverflow.com/a/50707270/6306138 我试图从此答案中添加gradle代码: https ://stackoverflow.com/a/50707270/6306138

The Gradle file of the project. 项目的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 {
    }
}


Neither of the "errors" mentioned are errors. 提到的“错误”都不是错误。 NDK_PROJECT_PATH=null is normal behavior for Studio, and the second is just a warning. NDK_PROJECT_PATH=null是Studio的正常行为,第二个只是警告。

Without seeing your Android.mk or the full error message (the line immediately after the one you included tells you what went wrong) I can't tell you how to fix the warning, but like the warning says, one of your source files has an unrecognized extension so ndk-build didn't know how to build it. 没有看到您的Android.mk或完整的错误消息(包含的错误消息之后的那一行会告诉您出了什么问题),我无法告诉您如何解决该警告,但是就像警告说的那样,您的一个源文件包含无法识别的扩展名,因此ndk-build不知道如何构建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM