为 Android 构建问题 Mailcore2 库

Posted

技术标签:

【中文标题】为 Android 构建问题 Mailcore2 库【英文标题】:Building issue Mailcore2 library for Android 【发布时间】:2015-08-17 19:05:42 【问题描述】:

我将 MailCore2 用于邮件 android 应用程序。我按照文档 (https://github.com/MailCore/mailcore2/tree/master/build-android) 中提供的构建说明进行操作。

$ export ANDROID_SDK=/path/to/android-sdk
$ export ANDROID_NDK=/path/to/android-ndk
$ cd build-android
$ ./build.sh

我收到这些消息:

CMake Error at CMakeLists.txt:80 (message):
  ERROR: Could not find ctemplate


-- Configuring incomplete, errors occurred!
See also "/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/cmake-build/CMakeFiles/CMakeOutput.log".
cp: /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/cmake-build/src/include/MailCore: No such file or directory
Android NDK: WARNING:/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/Android.mk:MailCore: non-system libraries in linker flags: -lc++_shared    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[armeabi] Compile++ thumb: MailCore <= com_libmailcore_AbstractMessage.cpp
In file included from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/TypesUtils.h:7:0,
                 from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/native/com_libmailcore_AbstractMessage.cpp:3:
/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/core/basetypes/MCBaseTypes.h:5:40: fatal error: MailCore/MCAutoreleasePool.h: No such file or directory
 #include <MailCore/MCAutoreleasePool.h>
                                        ^
compilation terminated.
make: *** [/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/obj/local/armeabi/objs/MailCore//Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/__/__/src/java/native/com_libmailcore_AbstractMessage.o] Error 1
cp: /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/libs/armeabi/libMailCore.so: No such file or directory
Android NDK: WARNING:/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/Android.mk:MailCore: non-system libraries in linker flags: -lc++_shared    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[armeabi-v7a] Compile++ thumb: MailCore <= com_libmailcore_AbstractMessage.cpp
In file included from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/TypesUtils.h:7:0,
                 from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/native/com_libmailcore_AbstractMessage.cpp:3:
/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/core/basetypes/MCBaseTypes.h:5:40: fatal error: MailCore/MCAutoreleasePool.h: No such file or directory
 #include <MailCore/MCAutoreleasePool.h>
                                        ^
compilation terminated.
make: *** [/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/obj/local/armeabi-v7a/objs/MailCore//Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/__/__/src/java/native/com_libmailcore_AbstractMessage.o] Error 1
cp: /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/libs/armeabi-v7a/libMailCore.so: No such file or directory
Android NDK: WARNING:/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/Android.mk:MailCore: non-system libraries in linker flags: -lc++_shared    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[x86] Compile++      : MailCore <= com_libmailcore_AbstractMessage.cpp
In file included from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/TypesUtils.h:7:0,
                 from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/native/com_libmailcore_AbstractMessage.cpp:3:
/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/core/basetypes/MCBaseTypes.h:5:40: fatal error: MailCore/MCAutoreleasePool.h: No such file or directory
 #include <MailCore/MCAutoreleasePool.h>
                                        ^
compilation terminated.
make: *** [/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/obj/local/x86/objs/MailCore//Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/__/__/src/java/native/com_libmailcore_AbstractMessage.o] Error 1
cp: /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/libs/x86/libMailCore.so: No such file or directory
Android NDK: WARNING:/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/Android.mk:MailCore: non-system libraries in linker flags: -lc++_shared    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[x86_64] Compile++      : MailCore <= com_libmailcore_AbstractMessage.cpp
In file included from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/TypesUtils.h:7:0,
                 from /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/java/native/com_libmailcore_AbstractMessage.cpp:3:
/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/../../src/core/basetypes/MCBaseTypes.h:5:40: fatal error: MailCore/MCAutoreleasePool.h: No such file or directory
 #include <MailCore/MCAutoreleasePool.h>
                                        ^
compilation terminated.
make: *** [/Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/obj/local/x86_64/objs/MailCore//Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/jni/__/__/src/java/native/com_libmailcore_AbstractMessage.o] Error 1
cp: /Users/thee/AndroidStudioProjects/JavaMailApp/libs/mailcore2-master/build-android/libs/x86_64/libMailCore.so: No such file or directory
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning

它生成二进制文件mailcore2-android-version.aar,如文档中所述,但我不能在我的项目中使用它。每次我尝试使用 mailcore 库的功能时它都会崩溃。

有什么想法吗?

【问题讨论】:

你必须得到 ctemplate: "ERROR: Could not find ctemplate" 是的,我找不到它的来源。我搜索了很长时间,但似乎没有人有类似的问题。我不知道 ctemplate 是什么以及它的用途。所以,如果有人能在这个特定的错误上给我一个线索,那就太好了...... 【参考方案1】:

如果这是在 Mac OS X 上,您可以下载缺少的组件 CTemplate (here) 和 Libetpan (here;如果稍后弹出该错误)。安装这些组件为我解决了这些错误。

【讨论】:

【参考方案2】:

有点晚,但可能对未来的用户有用:

build-android/includes 中创建一个“MailCore”目录。 然后从src/ 目录执行(对于 OS X):

cp `find . -name '*.h'`  ../build-android/includes/MailCore/

它对我有用!

【讨论】:

感谢您的提示,但我必须将所有头文件复制到“include”文件夹中,而不是“includes”。然后它起作用了。

以上是关于为 Android 构建问题 Mailcore2 库的主要内容,如果未能解决你的问题,请参考以下文章

在 Linux 上构建 Mailcore2

使用 mailcore2 在 gmail 帐户中创建标签

使用 mailcore2 将 HTML 展平为文本 object-c

在 Swift 中发送 Mailcore2 普通电子邮件

mailcore2 imap 错误域=MCOErrorDomain 代码=5

Mailcore2 - 从特定日期开始搜索电子邮件