android so 不能编译进,.so正确编译进apk里打包

我先说说我犯错的 地方。 1.jni下的Android.mk里的c文件 没有写全 LOCAL_SRC_FILES :=

2.app下的Android.mk没有这句:include $(LOCAL_PATH)/jni/Android.mk

好。这样之后 make android的时候就不会报错了。会在out/target/product/generic/obj/lib下生成相应的.so。这里有就说明你的.so编译成功。

JNI下的Android.mk:

#

# Copyright 2009 Cedric Priscal

#

# 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.

#

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

#TARGET_PLATFORM := android-3

LOCAL_MODULE_TAGS := eng

#LOCAL_MODULE_TAGS := optional

# This is the target being built.

LOCAL_MODULE    := libserialport         //

# All of the source files that we will compile.

LOCAL_SRC_FILES :=  \

SerialPort.c \

RemoTIAPI.c                                                //这里只要你的jni下有多少c文件都要写完。不然。。。

# All of the shared libraries we link against.

LOCAL_SHARED_LIBRARIES := \

libutils

# No static libraries.

LOCAL_STATIC_LIBRARIES :=

# Also need the JNI headers.

LOCAL_C_INCLUDES += \

$(JNI_H_INCLUDE)

# No special compiler flags.

LOCAL_CFLAGS +=

#LOCAL_LDLIBS := -ldl -llog

LOCAL_PRELINK_MODULE := false

include $(BUILD_SHARED_LIBRARY)  //编译so库

项目下的Android.mk:

TOP_LOCAL_PATH:= $(call my-dir)

# Build activity

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

#  LOCAL_MODULE_TAGS := user, eng

LOCAL_MODULE_TAGS := optional                     //这里也要注意!这里 要与你make android源码后出现的列表里的TARGET_BUILD_VARIANT=xxx 一样

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME :=FieldTest

#  LOCAL_CERTIFICATE := platform

LOCAL_JNI_SHARED_LIBRARIES := libserialport         //安装库

## Use the folloing include to make our RemoteControl apk.

include $(BUILD_PACKAGE)                                        //编译成apk

include $(LOCAL_PATH)/jni/Android.mk                     //调用库的编译

# ============================================================

# Also build all of the sub-targets under this one: the shared library.

#include $(call all-makefiles-under,$(LOCAL_PATH))

其他的 注释可以在网上搜到。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值