错误:任务':app:compileDebugNdk'执行失败。 >错误:您的项目包含C ++文件,但它未使用受支持的本机构建系统

时间:2018-02-16 07:42:22

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

我试图将我的应用程序与EPSON热敏打印机TM-T82集成。 我的应用程序使用realm用于本地数据库。 我按照他们的文档尝试集成打印机,并且我收到了这个错误。 我使用了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

应用:的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
}

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

interface Observable {
    fun register(observer: Observer)
}

class ObserverList : Observable {
    val observers = mutableListOf<Observer>()

    override fun register(observer: Observer) {
        observers.add(observer)
    }
}

class Impl : Parent(), Observable by ObserverList()

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