2017-03-03 103 views
0

enter image description here的Android NDK正在中止停止,無法創建NDK編譯

# 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 

我越來越NDK正在中止Stop錯誤在此prebuilt-library.mk文件。該文件在上面給出。它也顯示未能建立NDK & NDK-build完成非零退出值2.

我該如何解決這個錯誤?

在此先感謝。

+0

發佈其餘的錯誤消息。我們所知道的是,它是失敗的,而不是它在做什麼時所做的。 –

+0

@GabeSechan發佈了圖片。 –

+0

@AvijitKarmakar請確保您的Android項目和NDK路徑不包含空白區域。 – Lawrance

回答

1

注意:如果您已經創建了項目,然後通過SDK工具安裝Android NDK,CMake和LLDB,那麼您的項目可能不會生成,即您將收到錯誤,而使項目

遵循以下步驟:

  1. 安裝Android NDK,CMake和LLDB
  2. 在Android中創建新項目,並檢查包括C++支持enter image description here
  3. 最後啓用異常支持 & 運行時類型信息支持enter image description here
  4. 按完成。

在應用程序級別build.gradle文件。

  • 添加以下行之前你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') 
    
  • 添加在android - >defaultConfig

    externalNativeBuild { cmake的{ CPPFLAGS 「-frtti -fexceptions」 }}

  • 添加以下行之後buildTypes {}標籤

    externalNativeBuild { cmake的{ 路徑 「的CMakeLists.txt」 } } 任務ndkBuild(類型:執行){ 如果(Os.isFamily(Os.FAMILY_WINDOWS)){命令行ndkDir +'/ ndk-build','-C',文件('src/main')和其他命令行ndkDir +'/ndk-build.cmd','-C' 'src/main')。absolutePath } }

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

希望它可以幫助你。 !