简体   繁体   English

Android NDK中止停止,无法创建NDK构建

[英]Android NDK Aborting Stop, Failed to create NDK build

在此处输入图片说明

# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# this file is included from prebuilt-shared-library.mk or
# prebuilt-static-library.mk to declare prebuilt library binaries.
#

$(call assert-defined, LOCAL_BUILD_SCRIPT LOCAL_MAKEFILE LOCAL_PREBUILT_PREFIX LOCAL_PREBUILT_SUFFIX)

$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT))
$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
$(call check-LOCAL_MODULE_FILENAME)

# Check that LOCAL_SRC_FILES contains only the path to one library
ifneq ($(words $(LOCAL_SRC_FILES)),1)
$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): The LOCAL_SRC_FILES for a prebuilt library should only contain one item))
$(call __ndk_error,Aborting)
endif

bad_prebuilts := $(filter-out %$(LOCAL_PREBUILT_SUFFIX),$(LOCAL_SRC_FILES))
ifdef bad_prebuilts
$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_SRC_FILES should point to a file ending with "$(LOCAL_PREBUILT_SUFFIX)")
$(call __ndk_info,The following file is unsupported: $(bad_prebuilts))
$(call __ndk_error,Aborting)
endif

prebuilt_path := $(call local-prebuilt-path,$(LOCAL_SRC_FILES))
prebuilt := $(strip $(wildcard $(prebuilt_path)))

ifndef prebuilt
$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_SRC_FILES points to a missing file)
$(call __ndk_info,Check that $(prebuilt_path) exists, or that its path is correct)
$(call __ndk_error,Aborting)
endif

# If LOCAL_MODULE_FILENAME is defined, it will be used to name the file
# in the TARGET_OUT directory, and then the installation one. Note that
# it shouldn't have an .a or .so extension nor contain directory separators.
#
# If the variable is not defined, we determine its value from LOCAL_SRC_FILES
#
LOCAL_MODULE_FILENAME := $(strip $(LOCAL_MODULE_FILENAME))
ifndef LOCAL_MODULE_FILENAME
    LOCAL_MODULE_FILENAME := $(notdir $(LOCAL_SRC_FILES))
    LOCAL_MODULE_FILENAME := $(LOCAL_MODULE_FILENAME:%$(LOCAL_PREBUILT_SUFFIX)=%)
endif
$(eval $(call ev-check-module-filename))

# If LOCAL_BUILT_MODULE is not defined, then ensure that the prebuilt is
# copied to TARGET_OUT during the build.
LOCAL_BUILT_MODULE := $(strip $(LOCAL_BUILT_MODULE))
ifndef LOCAL_BUILT_MODULE
  LOCAL_BUILT_MODULE := $(TARGET_OUT)/$(LOCAL_MODULE_FILENAME)$(LOCAL_PREBUILT_SUFFIX)
  LOCAL_OBJECTS      := $(prebuilt)

  $(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
endif

LOCAL_OBJS_DIR  := $(TARGET_OBJS)/$(LOCAL_MODULE)
LOCAL_SRC_FILES :=

include $(BUILD_SYSTEM)/build-module.mk

I am getting NDK Aborting Stop error in this prebuilt-library.mk file. 我在此prebuilt-library.mk文件中收到NDK中止停止错误。 The file is given above. 该文件在上面给出。 It's also showing failed to build NDK & NDK-build finished with non zero exit value 2. 它还显示构建NDK失败,NDK构建失败,退出值非零2。

How can I fix this error? 如何解决此错误?

Thanks in advance. 提前致谢。

Note: If you already created project and after that you are installing Android NDK, CMake and LLDB through SDK Tools then your project might not build ie you will get an error while Make Project . 注意:如果您已经创建了项目,然后再通过SDK Tools安装Android NDK,CMake和LLDB,则您的项目可能无法构建,即在Make Project时会出现错误。

Follow the below steps: 请按照以下步骤操作:

  1. Install Android NDK, CMake and LLDB 安装Android NDK,CMake和LLDB
  2. Create New Project in Android and checked Include C++ Support 在Android中创建新项目,并选中“ 包括C ++支持” 在此处输入图片说明
  3. At last Enable Exception Support & Runtime Type information Support 最后启用异常支持运行时类型信息支持 在此处输入图片说明
  4. Press to Finish. 按完成。

In app level build.gradle file. 在应用程序级别的build.gradle文件。

  • Add below lines before your apply plugin:... 在您的apply plugin:...之前添加以下行apply plugin:...

     import org.apache.tools.ant.taskdefs.condition.Os Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') 
  • Add in android -> defaultConfig android添加-> defaultConfig

    externalNativeBuild{ cmake{ cppFlags "-frtti -fexceptions" } } externalNativeBuild {cmake {cppFlags“ -frtti -fexceptions”}}

  • Add below lines after buildTypes {} tag buildTypes {}标签之后添加以下行

    externalNativeBuild { cmake { path "CMakeLists.txt" } } task ndkBuild(type: Exec) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine ndkDir + '/ndk-build.cmd', '-C', file('src/main').absolutePath } else { commandLine ndkDir + '/ndk-build', '-C', file('src/main').absolutePath } } externalNativeBuild {cmake {路径“ CMakeLists.txt”}}任务ndkBuild(type:Exec){if(Os.isFamily(Os.FAMILY_WINDOWS)){commandline ndkDir +'/ndk-build.cmd','-C',file ('src / main')。absolutePath}否则{commandLine ndkDir +'/ ndk-build','-C',file('src / main')。absolutePath}}

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

Hope it helps you. 希望对您有帮助。 !! !!

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

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