【问题标题】:Error:Execution failed for task ':app:compileDebugNdk'. > Error: Your project contains C++ files but it is not using a supported native build system错误:任务“:app:compileDebugNdk”执行失败。 > 错误:您的项目包含 C++ 文件,但未使用受支持的本机构建系统
【发布时间】:2018-02-16 07:42:22
【问题描述】:

我正在尝试将我的应用程序与 EPSON 热敏打印机 TM-T82 集成。 我的应用程序将领域用于本地数据库。 我尝试按照他们的文档来集成打印机,但我收到了这个错误。 我使用了 EPOS2.jar 文件和 libepos2.so 文件

错误:任务“:app:compileDebugNdk”执行失败。

错误:您的项目包含 C++ 文件,但未使用受支持的本机构建系统。 考虑使用 CMake 或 ndk-build 集成。欲了解更多信息,请访问: https://d.android.com/r/studio-ui/add-native-code.html 或者,您可以使用实验性插件: https://developer.android.com/r/tools/experimental-plugin.html

app:build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '26.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
    applicationId "com.swishpay.tab"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] } }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
    maven {
        url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    }
}
dataBinding {
    enabled = true
}
dexOptions {
    incremental true
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

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'
})
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:multidex:1.0.2'
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta5'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.uphyca:stetho_realm:2.0.0'
compile 'com.google.android.gms:play-services:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.pusher:pusher-java-client:1.5.0'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
testCompile 'junit:junit:4.12'
compile files('libs/Sam4sAndroidSDK.jar')
implementation 'com.github.bumptech.glide:glide:4.4.0'
compile(name: 'MswipeWseriesUniversalDRDSDKVer1.0.6v3.3.0', ext: 'aar')
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
implementation files('libs/simplyprintapi-android-1.3.0.jar')
compile 'com.github.freshdesk:freshchat-android:1.2.1'
implementation files('libs/ePOS2.jar')
}
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'

项目:build.gradle

// Top-level build file where you can add configuration options common to 
all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath "io.realm:realm-gradle-plugin:4.2.0"
    classpath 'com.google.gms:google-services:3.1.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    google()
    maven { url "https://jitpack.io" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

【问题讨论】:

  • CMake 优于实验性插件,Realm 不支持实验性插件。
  • 通过在所有 jniLibs 文件夹( armeabi、armeabi-v5a、armeabi-v7a、mips、x86)中添加 .so 文件并添加 ndk { abiFilters "armeabi-v5a", "armeabi- v7a", "x86", "armeabi", "mips" } 默认配置

标签: android android-studio realm realm-mobile-platform epson


【解决方案1】:

您必须添加 c++ 支持才能在项目中使用 c++ 文件。请确保您的项目有此支持。你可以通过这个链接Add C and C++ Code to Your Project 希望它有用。

【讨论】:

    【解决方案2】:
            ndk {
               abiFilters "armeabi-v5a", "armeabi-v7a", "x86", "armeabi", "mips"
            }
    

    将此添加到 gradle 默认配置中并在 jniLibs 中创建这些文件夹并将 *.so 文件粘贴到所有文件夹中。这将启用对多个 ndk 的支持

    【讨论】:

      猜你喜欢
      • 2017-02-25
      • 1970-01-01
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-09
      • 2015-12-30
      • 2017-10-19
      相关资源
      最近更新 更多