My Android - project contents more than 20 C++ and C libraries. While I compile my project I compile all this libraries. But I don’t change C-code - I change only java – code. Maybe there is a way to avoid libraries compiling for each time? I use eclipse (Java and NDK) and ant. Thanks in advance!
我的Android -项目内容超过20个c++和C库。当我编译我的项目时,我编译所有这些库。但是我不改变C-code——我只改变java代码。也许有一种方法可以避免每次都编译库?我使用eclipse (Java和NDK)和ant。提前谢谢!
Edit1:
Edit1:
Android.mk
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:
Edit2:
build.xml
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>
2 个解决方案
#1
2
Unless you use NDK r8c, you can unconditionally call ndk-build
for your project. It will only copy the libDeflatingDecompressor-v3.so
file from obj/local/armeabi
to libs/armeabi
, stripping away symbol information and taking care of all dependencies and settings.
除非您使用NDK r8c,否则您可以无条件地为您的项目调用NDK -build。它只会复制libdeflatingdispressv3。因此,从obj/local/armeabi到libs/armeabi,删除符号信息并处理所有依赖项和设置。
But in the latest r8c version there is a bug which causes unconditional full rebuild. I have posted a fix for this bug recently.
但是在最新的r8c版本中,有一个缺陷导致无条件的完全重建。我最近已经发布了这个bug的补丁。
#2
2
In your ant build.xml
, you have a check for <available file="./libs/armeabi/libDeflatingDecompressor- v3.so" />
. It seems from the next line, that this file should be without spaces, so ant will never find the library and always try to rebuild by calling ndk-build.
在您的ant构建。xml,您可以检查 <可用文件="。 libs armeabi libdeflatingdecompressor - v3。所以"> 。从下一行来看,该文件应该没有空格,所以ant将永远找不到库,并且总是通过调用ndk-build来尝试重建。
In your <uptodate targetfile="libs/armeabi/libDeflatingDecompressor-v3.so">
you have no property
attribute defined.
在你的 <现时的targetfile = " libs armeabi libdeflatingdecompressor-v3。所以"> 你没有定义属性。
#1
2
Unless you use NDK r8c, you can unconditionally call ndk-build
for your project. It will only copy the libDeflatingDecompressor-v3.so
file from obj/local/armeabi
to libs/armeabi
, stripping away symbol information and taking care of all dependencies and settings.
除非您使用NDK r8c,否则您可以无条件地为您的项目调用NDK -build。它只会复制libdeflatingdispressv3。因此,从obj/local/armeabi到libs/armeabi,删除符号信息并处理所有依赖项和设置。
But in the latest r8c version there is a bug which causes unconditional full rebuild. I have posted a fix for this bug recently.
但是在最新的r8c版本中,有一个缺陷导致无条件的完全重建。我最近已经发布了这个bug的补丁。
#2
2
In your ant build.xml
, you have a check for <available file="./libs/armeabi/libDeflatingDecompressor- v3.so" />
. It seems from the next line, that this file should be without spaces, so ant will never find the library and always try to rebuild by calling ndk-build.
在您的ant构建。xml,您可以检查 <可用文件="。 libs armeabi libdeflatingdecompressor - v3。所以"> 。从下一行来看,该文件应该没有空格,所以ant将永远找不到库,并且总是通过调用ndk-build来尝试重建。
In your <uptodate targetfile="libs/armeabi/libDeflatingDecompressor-v3.so">
you have no property
attribute defined.
在你的 <现时的targetfile = " libs armeabi libdeflatingdecompressor-v3。所以"> 你没有定义属性。