Android NDK:make:***没有规则可以制作目标。停止

时间:2017-07-06 10:41:02

标签: android c++ android-ndk libusb libusb-1.0

我正在尝试使用NDK构建libusb。这是我的Android.mkApplication.mk我已经检查了这个帖子Android NDK: No rule to make target,但它对我没用。

Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE    := libusb
LOCAL_SRC_FILES := libusb/core.c libusb/descriptor.c libusb/io.c libusb/sync.c libusb/os/linux_usbfs.c

LOCAL_LDLIBS    := -llog
include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_ABI:= all
APP_LDFLAGS:= -llog
APP_STL:= stlport_shared
APP_CPP_FEATURES:= exceptions
APP_PLATFORM:= android-21
APP_CFLAGS:= -g

的build.gradle

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'
        }
    }
}

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'
}

local.properties

ndk.dir=C\:\\android-ndk-r15

项目结构如下所示:

enter image description here

当我跑步ndk-build时,我得到了

ndk-build
Android NDK: WARNING: APP_PLATFORM android-21 is higher than android:minSdkVersion 1 in D:/williams/android/libusbpoc/app/src/main/AndroidManifest.xml. NDK binaries will *not* be comptible with devices older than android-21. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
make: *** No rule to make target `C:/android-ndk-r15/build//../sources/cxx-stl/stlport/libusb/core.c', needed by `D:/williams/android/libusbpoc/app/src/main/obj/local/arm64-v8a/objs/usb/libusb/core.o'.  Stop.

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:1)

您似乎忘了设置LOCAL_PATH,即在您应该拥有的Android.mk中:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#  ..etc as before..