deltachat / deltachat-android

Email-based instant messaging for Android.
GNU General Public License v3.0
1.13k stars 147 forks source link

ndk-build fails for NDK r16b #248

Closed Hocuri closed 6 years ago

Hocuri commented 6 years ago

Delta Chat version

Newest GitHub version

Expected behavior

ndk-build to work :-)

Actual behavior

$ ndk-build
/home/user/DeltaChat/android-ndk-r16b/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): armeabi    
/home/user/DeltaChat/android-ndk-r16b/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed in a future NDK release.
Many lines of output...
[armeabi] Compile arm    : messenger.1 <= misc.c
jni/./messenger-backend/libs/netpgp/src/misc.c: In function 'pgp_mem_readfile':
jni/./messenger-backend/libs/netpgp/src/misc.c:953:13: error: call to 'mmap' declared with attribute error: mmap is not available with _FILE_OFFSET_BITS=64 when using GCC until android-21. Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or switch to Clang.
  mem->buf = mmap(NULL, mem->allocated, PROT_READ,
             ^
make: *** [obj/local/armeabi/objs/messenger.1/./messenger-backend/libs/netpgp/src/misc.o] Error 1

Naturally, when i build and launch Delta Chat anyway, it crashes ("Unfortunately, Delta Chat has stopped.").

Steps to reproduce the problem

Follow the "Install Development Environment" and then the "Build" instructions in the readme (Or did I miss something / do something wrong ?)

r10s commented 6 years ago

When DuckDuckGo'ing for the core error ("mmap is not available with _FILE_OFFSET_BITS=64 when using GCC until android-21. Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or switch to Clang."), I got eg. this result - https://github.com/android-ndk/ndk/issues/332#issuecomment-344560630 - seems as if we have to fix sth. for the newer NDKs.

Maybe this is also the reasons why F-Droid makes problems these days.

Hocuri commented 6 years ago

I think that clang can be used like this:

diff --git a/MessengerProj/jni/Application.mk b/MessengerProj/jni/Application.mk
index 038832a..5f18821 100644
--- a/MessengerProj/jni/Application.mk
+++ b/MessengerProj/jni/Application.mk
@@ -1,4 +1,4 @@
 APP_PLATFORM := android-14
 APP_ABI := armeabi armeabi-v7a x86
-NDK_TOOLCHAIN_VERSION := 4.9
+NDK_TOOLCHAIN_VERSION := clang
 APP_STL := gnustl_static

With clang, you have to use NULL instead of 0 if you mean a pointer: (Or would nullptr be better?)

diff --git a/MessengerProj/jni/gifvideo.cpp b/MessengerProj/jni/gifvideo.cpp
index 3de0db8..1b341b2 100644
--- a/MessengerProj/jni/gifvideo.cpp
+++ b/MessengerProj/jni/gifvideo.cpp
@@ -160,7 +160,7 @@ jint Java_com_b44t_ui_Components_AnimatedFileDrawable_createDecoder(JNIEnv *env,
         info->video_dec_ctx = info->video_stream->codec;
     }

-    if (info->video_stream <= 0) {
+    if (info->video_stream == NULL) {
         LOGE("can't find video stream in the input, aborting %s", info->src);
         delete info;
         return 0;

(Am I right assuming that a pointer can't have a negative value?)

But there still is an error (although it appears way later):

clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/armeabi/libmessenger.1.so] Error 1

I attached the full error log: error.txt

Update: The diffs can be seen here: https://github.com/deltachat/deltachat-android/compare/master...Hocceruser:master

r10s commented 6 years ago

Okay, while my normal development environment works, I can reproduce the problem with a fresh Android Studio install using the new NDK android-ndk-r16b-*-x86_64.zip - i assume, you use the same one?

As a workaround, you could use NDK android-ndk-r15c-*-x86_64.zip , however, of course, sooner or later we should fix the problem directly. I've added an appropriate hint in the readme.

PR to fix the issue are very welcome.

Regarding the F-Droid-Problem: F-Droid uses r15c, so this should not be a problem there.

r10s commented 6 years ago

seems as if we stuck in ndk r14b, see #220, one can fix this later, but for now, this seems to be out of scope.

Ampli-fier commented 6 years ago

Closed after README update 3ecb5a4: "dependecy on NDK 14b".