gpt4 book ai didi

java - Android NDK 中止停止,无法创建 NDK 版本

转载 作者:行者123 更新时间:2023-12-01 08:47:44 25 4
gpt4 key购买 nike

enter image description here

# 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

我在此 prebuilt-library.mk 文件中收到 NDK Aborting Stop 错误。该文件已在上面给出。它还显示无法构建 NDK 和 NDK-build 已完成,退出值非零 2。

如何修复此错误?

提前致谢。

最佳答案

注意:如果您已经创建了项目,然后通过 SDK 工具安装 Android NDK、CMake 和 LLDB,那么您的项目可能无法构建,即您在 Make Project 时会收到错误消息。

请按照以下步骤操作:

  1. 安装 Android NDK、CMake 和 LLDB
  2. 在 Android 中创建新项目并选中包括 C++ 支持 enter image description here
  3. 最后启用异常支持运行时类型信息支持 enter image description here
  4. 按完成。

在应用程序级别 build.gradle 文件中。

  • 应用插件之前添加以下行:...

    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')
  • 添加android -> defaultConfig

    外部本地构建{ cmake{ cppFlags“-frtti -fExceptions” }}

  • buildTypes {} 标记后添加以下行

    外部NativeBuild { cmake { 路径“CMakeLists.txt” }}任务 ndkBuild(类型:Exec) { 如果(Os.isFamily(Os.FAMILY_WINDOWS)){ 命令行 ndkDir + '/ndk-build.cmd', '-C', file('src/main').absolutePath } 别的 { 命令行 ndkDir + '/ndk-build', '-C', file('src/main').absolutePath }}

    tasks.withType(JavaCompile) { 编译任务 -> 编译任务.dependsOn ndkBuild}

希望对您有帮助。 !!

关于java - Android NDK 中止停止,无法创建 NDK 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42572012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com