我的Android - 项目内容超过20个C ++和C库。当我编译我的项目时,我编译了所有这些库。但我不改变C代码 - 我只改变了java代码。也许有一种方法可以避免每次编译库?我使用eclipse(Java和NDK)和ant。 提前致谢!
EDIT1:
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := DeflatingDecompressor-v3
LOCAL_SRC_FILES := DeflatingDecompressor/DeflatingDecompressor.cpp
LOCAL_LDLIBS := -lz
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := LineBreak-v2
LOCAL_SRC_FILES := LineBreak/LineBreaker.cpp LineBreak/liblinebreak- 2.0/linebreak.c LineBreak/liblinebreak-2.0/linebreakdata.c LineBreak/liblinebreak- 2.0/linebreakdef.c
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
EXPAT_DIR := expat-2.0.1
LOCAL_MODULE := expat
LOCAL_SRC_FILES := $(EXPAT_DIR)/lib/xmlparse.c $(EXPAT_DIR)/lib/xmlrole.c $(EXPAT_DIR)/lib/xmltok.c
LOCAL_CFLAGS := -DHAVE_EXPAT_CONFIG_H
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(EXPAT_DIR)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(EXPAT_DIR)/lib
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := NativeFormats-v2
LOCAL_CFLAGS := -Wall
LOCAL_LDLIBS := -lz -llog
LOCAL_STATIC_LIBRARIES := expat
LOCAL_SRC_FILES := \
NativeFormats/main.cpp \
NativeFormats/JavaNativeFormatPlugin.cpp \
NativeFormats/JavaPluginCollection.cpp \
NativeFormats/util/AndroidUtil.cpp \
NativeFormats/util/JniEnvelope.cpp \
NativeFormats/zlibrary/core/src/constants/ZLXMLNamespace.cpp \
NativeFormats/zlibrary/core/src/encoding/DummyEncodingConverter.cpp \
NativeFormats/zlibrary/core/src/encoding/Utf16EncodingConverters.cpp \
NativeFormats/zlibrary/core/src/encoding/Utf8EncodingConverter.cpp \
NativeFormats/zlibrary/core/src/encoding/JavaEncodingConverter.cpp \
NativeFormats/zlibrary/core/src/encoding/ZLEncodingCollection.cpp \
NativeFormats/zlibrary/core/src/encoding/ZLEncodingConverter.cpp \
NativeFormats/zlibrary/core/src/filesystem/ZLDir.cpp \
NativeFormats/zlibrary/core/src/filesystem/ZLFSManager.cpp \
NativeFormats/zlibrary/core/src/filesystem/ZLFile.cpp \
NativeFormats/zlibrary/core/src/filesystem/ZLInputStreamDecorator.cpp \
NativeFormats/zlibrary/core/src/filesystem/zip/ZLGzipInputStream.cpp \
NativeFormats/zlibrary/core/src/filesystem/zip/ZLZDecompressor.cpp \
NativeFormats/zlibrary/core/src/filesystem/zip/ZLZipDir.cpp \
NativeFormats/zlibrary/core/src/filesystem/zip/ZLZipEntryCache.cpp \
NativeFormats/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp \
NativeFormats/zlibrary/core/src/filesystem/zip/ZLZipInputStream.cpp \
NativeFormats/zlibrary/core/src/language/ZLCharSequence.cpp \
NativeFormats/zlibrary/core/src/language/ZLLanguageDetector.cpp \
NativeFormats/zlibrary/core/src/language/ZLLanguageList.cpp \
NativeFormats/zlibrary/core/src/language/ZLLanguageMatcher.cpp \
NativeFormats/zlibrary/core/src/language/ZLStatistics.cpp \
NativeFormats/zlibrary/core/src/language/ZLStatisticsGenerator.cpp \
NativeFormats/zlibrary/core/src/language/ZLStatisticsItem.cpp \
NativeFormats/zlibrary/core/src/language/ZLStatisticsXMLReader.cpp \
NativeFormats/zlibrary/core/src/library/ZLibrary.cpp \
NativeFormats/zlibrary/core/src/logger/ZLLogger.cpp \
NativeFormats/zlibrary/core/src/util/ZLFileUtil.cpp \
NativeFormats/zlibrary/core/src/util/ZLStringUtil.cpp \
NativeFormats/zlibrary/core/src/util/ZLUnicodeUtil.cpp \
NativeFormats/zlibrary/core/src/xml/ZLAsynchronousInputStream.cpp \
NativeFormats/zlibrary/core/src/xml/ZLPlainAsynchronousInputStream.cpp \
NativeFormats/zlibrary/core/src/xml/ZLXMLReader.cpp \
NativeFormats/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp \
NativeFormats/zlibrary/core/src/unix/filesystem/ZLUnixFSDir.cpp \
NativeFormats/zlibrary/core/src/unix/filesystem/ZLUnixFSManager.cpp \
NativeFormats/zlibrary/core/src/unix/filesystem/ZLUnixFileInputStream.cpp \
NativeFormats/zlibrary/core/src/unix/filesystem/ZLUnixFileOutputStream.cpp \
NativeFormats/zlibrary/core/src/unix/library/ZLUnixLibrary.cpp \
NativeFormats/zlibrary/text/src/model/ZLCachedMemoryAllocator.cpp \
NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp \
NativeFormats/zlibrary/text/src/model/ZLTextParagraph.cpp \
NativeFormats/zlibrary/ui/src/android/filesystem/JavaFSDir.cpp \
NativeFormats/zlibrary/ui/src/android/filesystem/JavaInputStream.cpp \
NativeFormats/zlibrary/ui/src/android/filesystem/ZLAndroidFSManager.cpp \
NativeFormats/zlibrary/ui/src/android/library/ZLAndroidLibraryImplementation.cpp \
NativeFormats/fbreader/src/bookmodel/BookModel.cpp \
NativeFormats/fbreader/src/bookmodel/BookReader.cpp \
NativeFormats/fbreader/src/formats/EncodedTextReader.cpp \
NativeFormats/fbreader/src/formats/FormatPlugin.cpp \
NativeFormats/fbreader/src/formats/PluginCollection.cpp \
NativeFormats/fbreader/src/formats/fb2/FB2BookReader.cpp \
NativeFormats/fbreader/src/formats/fb2/FB2CoverReader.cpp \
NativeFormats/fbreader/src/formats/fb2/FB2MetaInfoReader.cpp \
NativeFormats/fbreader/src/formats/fb2/FB2Plugin.cpp \
NativeFormats/fbreader/src/formats/fb2/FB2Reader.cpp \
NativeFormats/fbreader/src/formats/fb2/FB2TagManager.cpp \
NativeFormats/fbreader/src/formats/css/StyleSheetParser.cpp \
NativeFormats/fbreader/src/formats/css/StyleSheetTable.cpp \
NativeFormats/fbreader/src/formats/html/HtmlBookReader.cpp \
NativeFormats/fbreader/src/formats/html/HtmlDescriptionReader.cpp \
NativeFormats/fbreader/src/formats/html/HtmlEntityCollection.cpp \
NativeFormats/fbreader/src/formats/html/HtmlPlugin.cpp \
NativeFormats/fbreader/src/formats/html/HtmlReader.cpp \
NativeFormats/fbreader/src/formats/html/HtmlReaderStream.cpp \
NativeFormats/fbreader/src/formats/oeb/NCXReader.cpp \
NativeFormats/fbreader/src/formats/oeb/OEBBookReader.cpp \
NativeFormats/fbreader/src/formats/oeb/OEBCoverReader.cpp \
NativeFormats/fbreader/src/formats/oeb/OEBMetaInfoReader.cpp \
NativeFormats/fbreader/src/formats/oeb/OEBPlugin.cpp \
NativeFormats/fbreader/src/formats/oeb/OEBTextStream.cpp \
NativeFormats/fbreader/src/formats/oeb/XHTMLImageFinder.cpp \
NativeFormats/fbreader/src/formats/rtf/RtfBookReader.cpp \
NativeFormats/fbreader/src/formats/rtf/RtfDescriptionReader.cpp \
NativeFormats/fbreader/src/formats/rtf/RtfPlugin.cpp \
NativeFormats/fbreader/src/formats/rtf/RtfReader.cpp \
NativeFormats/fbreader/src/formats/rtf/RtfReaderStream.cpp \
NativeFormats/fbreader/src/formats/txt/PlainTextFormat.cpp \
NativeFormats/fbreader/src/formats/txt/TxtBookReader.cpp \
NativeFormats/fbreader/src/formats/txt/TxtPlugin.cpp \
NativeFormats/fbreader/src/formats/txt/TxtReader.cpp \
NativeFormats/fbreader/src/formats/util/EntityFilesCollector.cpp \
NativeFormats/fbreader/src/formats/util/MergedStream.cpp \
NativeFormats/fbreader/src/formats/util/MiscUtil.cpp \
NativeFormats/fbreader/src/formats/util/XMLTextStream.cpp \
NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp \
NativeFormats/fbreader/src/formats/doc/DocBookReader.cpp \
NativeFormats/fbreader/src/formats/doc/DocMetaInfoReader.cpp \
NativeFormats/fbreader/src/formats/doc/DocPlugin.cpp \
NativeFormats/fbreader/src/formats/doc/DocStreams.cpp \
NativeFormats/fbreader/src/formats/doc/OleMainStream.cpp \
NativeFormats/fbreader/src/formats/doc/OleStorage.cpp \
NativeFormats/fbreader/src/formats/doc/OleStream.cpp \
NativeFormats/fbreader/src/formats/doc/OleStreamParser.cpp \
NativeFormats/fbreader/src/formats/doc/OleStreamReader.cpp \
NativeFormats/fbreader/src/formats/doc/OleUtil.cpp \
NativeFormats/fbreader/src/formats/doc/DocInlineImageReader.cpp \
NativeFormats/fbreader/src/formats/doc/DocFloatImageReader.cpp \
NativeFormats/fbreader/src/library/Author.cpp \
NativeFormats/fbreader/src/library/Book.cpp \
NativeFormats/fbreader/src/library/Comparators.cpp \
NativeFormats/fbreader/src/library/Library.cpp \
NativeFormats/fbreader/src/library/Tag.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/NativeFormats/util \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/constants \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/encoding \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/filesystem \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/image \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/language \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/library \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/logger \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/util \
$(LOCAL_PATH)/NativeFormats/zlibrary/core/src/xml \
$(LOCAL_PATH)/NativeFormats/zlibrary/text/src/model
include $(BUILD_SHARED_LIBRARY)
EDIT2:
的build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="FBReaderJ" default="help">
<loadproperties srcFile="local.properties" />
<property file="ant.properties" />
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
unless="sdk.dir"
/>
<target name="init" description="Initialization...">
<fail message="Ant 1.7.0 or higher is required. Please upgrade your ant.">
<condition>
<not>
<antversion property="ant.version" atleast="1.7.0"/>
</not>
</condition>
</fail>
</target>
<target name="native" unless="native.libraries.are.uptodate">
<fail message="Native libraries are not up-to-date. Please run ndk-build manually.">
<condition>
<os family="windows" />
</condition>
</fail>
<echo message="Building native libraries..."/>
<exec executable="${ndk.dir}/ndk-build" />
<echo message="DONE (Building native libraries)"/>
</target>
<target name="check.native.libraries" depends="init">
<echo message="Checking if native libraries are up-to-date..."/>
<condition property="native.libraries.are.uptodate" value="true">
<and>
<!-- Check if libDeflatingDecompressor exists and is up to date -->
<available file="./libs/armeabi/libDeflatingDecompressor- v3.so" />
<uptodate targetfile="libs/armeabi/libDeflatingDecompressor-v3.so">
<srcfiles dir="jni/DeflatingDecompressor" includes="**/*.cpp"/>
</uptodate>
<!-- Check if libLineBreak exists and is up to date -->
<available file="./libs/armeabi/libLineBreak-v2.so" />
<uptodate property="libLineBreak-build-is-not-required" targetfile="libs/armeabi/libLineBreak-v2.so">
<srcfiles dir="jni/LineBreak" includes="**/*.cpp,**/*.c,**/*.h"/>
</uptodate>
<!-- Check if libNativeFormats exists and is up to date -->
<available file="./libs/armeabi/libNativeFormats-v2.so" />
<uptodate property="libNativeFormats-build-is-not-required" targetfile="libs/armeabi/libNativeFormats-v2.so">
<srcfiles dir="jni/NativeFormats" includes="**/*.cpp,**/*.c,**/*.h"/>
</uptodate>
</and>
</condition>
<echo message="DONE (Checking if native libraries are up-to-date)"/>
</target>
<target name="resources" depends="init, check.native.libraries">
<echo message="Cleaning up the 'res/drawable' folder..." />
<delete dir="res/drawable/">
<files includes="**"/>
</delete>
<echo message="DONE (Cleaning up the 'res/drawable' folder)" />
<echo message="Copying icons files to 'res/drawable/' folder..." />
<copy todir="res/drawable" verbose="false" overwrite="true" flatten="true">
<fileset file="icons/fbreader.png" />
<fileset dir="icons/" includes="*/*" />
</copy>
<echo message="DONE (Copying icons files to 'res/drawable/' folder)" />
</target>
<target name="-pre-build" depends="init, resources, native">
</target>
<!--
<target name="-pre-compile">
</target>
<target name="-post-compile">
</target>
-->
<target name="clean">
<echo message="Deleting temporary files..." />
<delete dir="gen" />
<delete dir="bin" />
<delete dir="res/drawable" />
<delete dir="out" />
<delete dir="obj" />
<echo message="DONE (Deleting temporary files)" />
</target>
<target name="distclean" depends="clean">
<echo message="Deleting native libraries..." />
<delete dir="libs/armeabi" />
<delete dir="libs/armeabi-v7a" />
<delete dir="libs/x86" />
<delete dir="libs/mips" />
<delete dir="libs/mips-r2" />
<delete dir="libs/mips-r2-sf" />
<echo message="DONE (Deleting native libraries)" />
</target>
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>
答案 0 :(得分:2)
在您的build.xml
中,您需要检查<available file="./libs/armeabi/libDeflatingDecompressor- v3.so" />
。从下一行看来,这个文件应该没有空格,所以ant永远不会找到库并且总是尝试通过调用ndk-build来重建。
在<uptodate targetfile="libs/armeabi/libDeflatingDecompressor-v3.so">
中,您没有定义property
属性。
答案 1 :(得分:2)
除非您使用NDK r8c ,否则您可以无条件地为您的项目调用ndk-build
。它只会将libDeflatingDecompressor-v3.so
文件从obj/local/armeabi
复制到libs/armeabi
,删除符号信息并处理所有依赖项和设置。
但是在最新的 r8c 版本中,存在导致无条件完全重建的错误。我最近发布了a fix这个错误。