其他分享
首页 > 其他分享> > android – 在OS独立路径’lib / x86 / libusb.so’中找到了多个文件

android – 在OS独立路径’lib / x86 / libusb.so’中找到了多个文件

作者:互联网

我在我的Android应用程序中使用libusb.当我尝试构建libusb本机库时,我得到以下错误消息,* .so文件生成.

Error:Execution failed for task ‘:app:transformNativeLibsWithMergeJniLibsForDebug’.
More than one file was found with OS independent path ‘lib/x86/libusb.so’

enter image description here

的build.gradle

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.williams.libusbpoc"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }

    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    // call regular ndk-build(.cmd) script from app directory
    task ndkBuild(type: Exec) {
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
        } else {
            commandLine 'ndk-build', '-C', file('src/main').absolutePath
        }
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation ('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"
}

我在Windows机器上.有谁知道可能是什么问题?

解决方法:

我删除了sourceSets.main块中的jniLibs.srcDir’src / main / libs代码.它创建了两次* .so文件.

sourceSets.main {
    jniLibs.srcDir 'src/main/libs'
    jni.srcDirs = [] //disable automatic ndk-build call
}

标签:libusb,android,c,android-ndk,libusb-1-0
来源: https://codeday.me/bug/20191007/1868661.html