android studio3.6.3编译Telegram android 1482 问题小记(nebula chatengine 指定版本)

故事的开始是这样的,按照benqi的提示:

D:\TBuild\Telegram> git checkout e222fded6cca5ace3649be6f18b55f526311bc79
Updating files: 100% (10653/10653), done.
Note: switching to 'e222fded6cca5ace3649be6f18b55f526311bc79'.


D:\TBuild\Telegram> git submodule update --init --recursive
Submodule 'TMessagesProj/jni/libtgvoip' (https://github.com/grishka/libtgvoip) registered for path 'TMessagesProj/jni/libtgvoip'
Cloning into 'D:/TBuild/Telegram/TMessagesProj/jni/libtgvoip'...
Submodule path 'TMessagesProj/jni/libtgvoip': checked out 'bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34'

 D:\TBuild\Telegram>

但是打开AS3.6.3,编译时候各种告错,竟然没有指定使用的NDK,也不知道哪个版本合适

1)配置时候说是找不到合适的NDK,我的方法是:在 File > Project Structure

打开窗口,手动指定NDK路径。

ndkversion问题解决

2)也不知道该用哪个版本,用16b和17b会提示:

jni/libs/libavutil.a(mem.o): in function av_malloc:libavutil/mem.c:95: error: undefined reference to 'posix_memalign'

说明版本过低,详见https://www.cnblogs.com/cmd10/p/4915360.html

所以决定使用ndk20,所以改成android16

仍然报错,

最后各种测试,在PATH中设置NDK路径,然后执行ndk-build,每出现一次错误,就看看哪里的问题,反正android.mk里有很多错误,另外见3)

使用这个版本需要对Application.mk设置:

LOCAL_SHORT_COMMANDS := true
APP_PLATFORM := android-16
#NDK_TOOLCHAIN_VERSION := 4.9
#APP_STL := gnustl_static
#NDK_TOOLCHAIN_VERSION := clang
APP_STL := c++_static

3)找不到 unique_ptr.h

老外这样说:User code should never try to include  directly, because it doesn't even exist in other implementations of the C++ standard library. The correct header to include is . The code needs to be fixed to stop trying to include internal implementation details of a specific implementation.

意思是,永远不要引用这个文件,因为只有GCC自己有这个文件,这个文件大概是智能指针相关的,应该使用#include来代替。

4)gifvedio.cpp 中各种报错,主要是MK文件中没有引用头文件目录,

友情提示:个人以为AS提示的信息特别不靠谱,最好在命令行中直接ndk-build看看到底那句有错误。

如果能看到最后输出了:(在libs目录里会有这些文件)

那么我要恭喜你,你成功一半了。NDK这里问题不大了。但是,AS还是会报错,

android studio3.6.3编译Telegram android 1482 问题小记(nebula chatengine 指定版本)_第1张图片

 

这里给出我能用的android.mk的更改后的文件:

LOCAL_SHORT_COMMANDS := true

LOCAL_PATH := $(call my-dir)

LOCAL_MODULE    := avutil 

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := ./ffmpeg/armv7-a/libavutil.a
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
    LOCAL_SRC_FILES := ./ffmpeg/arm64/libavutil.a
else ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_SRC_FILES := ./ffmpeg/i686/libavutil.a
else ifeq ($(TARGET_ARCH_ABI),x86_64)
    LOCAL_SRC_FILES := ./ffmpeg/x86_64/libavutil.a
endif

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := avformat

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := ./ffmpeg/armv7-a/libavformat.a
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
    LOCAL_SRC_FILES := ./ffmpeg/arm64/libavformat.a
else ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_SRC_FILES := ./ffmpeg/i686/libavformat.a
else ifeq ($(TARGET_ARCH_ABI),x86_64)
    LOCAL_SRC_FILES := ./ffmpeg/x86_64/libavformat.a
endif

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := avcodec

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := ./ffmpeg/armv7-a/libavcodec.a
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
    LOCAL_SRC_FILES := ./ffmpeg/arm64/libavcodec.a
else ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_SRC_FILES := ./ffmpeg/i686/libavcodec.a
else ifeq ($(TARGET_ARCH_ABI),x86_64)
    LOCAL_SRC_FILES := ./ffmpeg/x86_64/libavcodec.a
endif

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := avresample

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := ./ffmpeg/armv7-a/libavresample.a
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
    LOCAL_SRC_FILES := ./ffmpeg/arm64/libavresample.a
else ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_SRC_FILES := ./ffmpeg/i686/libavresample.a
else ifeq ($(TARGET_ARCH_ABI),x86_64)
    LOCAL_SRC_FILES := ./ffmpeg/x86_64/libavresample.a
endif

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := crypto

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := ./boringssl/lib/libcrypto_armeabi-v7a.a
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
    LOCAL_SRC_FILES := ./boringssl/lib/libcrypto_arm64-v8a.a
else ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_SRC_FILES := ./boringssl/lib/libcrypto_x86.a
else ifeq ($(TARGET_ARCH_ABI),x86_64)
    LOCAL_SRC_FILES := ./boringssl/lib/libcrypto_x86_64.a
endif

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := voip
LOCAL_CPPFLAGS := -Wall -std=c++11 -DANDROID -finline-functions -ffast-math -Os -fno-strict-aliasing -O3 -frtti -D__STDC_LIMIT_MACROS
LOCAL_CFLAGS := -O3 -DUSE_KISS_FFT -fexceptions -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX -D__STDC_LIMIT_MACROS -DFIXED_POINT

MY_DIR := libtgvoip

LOCAL_C_INCLUDES := ./jni/opus/include/ ./jni/boringssl/include/ ./jni/libtgvoip/webrtc_dsp/ ./jni/ffmpeg/include/libavformat/

LOCAL_SRC_FILES := \
./libtgvoip/logging.cpp \
./libtgvoip/VoIPController.cpp \
./libtgvoip/VoIPGroupController.cpp \
./libtgvoip/Buffers.cpp \
./libtgvoip/BlockingQueue.cpp \
./libtgvoip/audio/AudioInput.cpp \
./libtgvoip/os/android/AudioInputOpenSLES.cpp \
./libtgvoip/MediaStreamItf.cpp \
./libtgvoip/audio/AudioOutput.cpp \
./libtgvoip/OpusEncoder.cpp \
./libtgvoip/os/android/AudioOutputOpenSLES.cpp \
./libtgvoip/JitterBuffer.cpp \
./libtgvoip/OpusDecoder.cpp \
./libtgvoip/os/android/OpenSLEngineWrapper.cpp \
./libtgvoip/os/android/AudioInputAndroid.cpp \
./libtgvoip/os/android/AudioOutputAndroid.cpp \
./libtgvoip/EchoCanceller.cpp \
./libtgvoip/CongestionControl.cpp \
./libtgvoip/VoIPServerConfig.cpp \
./libtgvoip/audio/Resampler.cpp \
./libtgvoip/NetworkSocket.cpp \
./libtgvoip/os/posix/NetworkSocketPosix.cpp \
./libtgvoip/PacketReassembler.cpp \
./libtgvoip/MessageThread.cpp \
./libtgvoip/audio/AudioIO.cpp

# WebRTC signal processing

LOCAL_SRC_FILES += \
./libtgvoip/webrtc_dsp/webrtc/common_audio/ring_buffer.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/auto_corr_to_refl_coef.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/auto_correlation.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/complex_bit_reverse.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/complex_fft.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/copy_set_operations.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/cross_correlation.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/division_operations.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/dot_product_with_scale.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/downsample_fast.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/energy.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/filter_ar.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/get_hanning_window.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/get_scaling_square.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/ilbc_specific_functions.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/levinson_durbin.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/lpc_to_refl_coef.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/min_max_operations.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/randomization_functions.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/real_fft.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/refl_coef_to_lpc.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/resample.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/resample_48khz.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/resample_by_2.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/resample_by_2_internal.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/resample_fractional.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/spl_init.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/spl_inl.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/spl_sqrt.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/spl_sqrt_floor.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/splitting_filter_impl.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/vector_scaling_operations.c

LOCAL_SRC_FILES += \
./libtgvoip/webrtc_dsp/webrtc/base/checks.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/aecm_core.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/aecm_core_c.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/utility/delay_estimator.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/three_band_filter_bank.cc \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/splitting_filter.cc \
./libtgvoip/webrtc_dsp/webrtc/system_wrappers/source/cpu_features.cc \
./libtgvoip/webrtc_dsp/webrtc/common_audio/sparse_fir_filter.cc \
./libtgvoip/webrtc_dsp/webrtc/common_audio/channel_buffer.cc \
./libtgvoip/webrtc_dsp/webrtc/common_audio/audio_util.cc

#LOCAL_SRC_FILES += \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/utility/block_mean_calculator.cc \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/utility/ooura_fft.cc \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/logging/apm_data_dumper.cc \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aec/aec_core.cc \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aec/aec_resampler.cc \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aec/echo_cancellation.cc \
#./libtgvoip/webrtc_dsp/webrtc/common_audio/wav_header.cc \
#./libtgvoip/webrtc_dsp/webrtc/common_audio/wav_file.cc \
#./libtgvoip/webrtc_dsp/webrtc/base/stringutils.cc

LOCAL_SRC_FILES += \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/ns/noise_suppression_x.c \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/ns/noise_suppression.c \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/ns/ns_core.c \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/ns/nsx_core_c.c \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/ns/nsx_core.c \
./libtgvoip/webrtc_dsp/webrtc/common_audio/fft4g.c

LOCAL_SRC_FILES += \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/agc/legacy/analog_agc.c \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/agc/legacy/digital_agc.c

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_SRC_FILES += \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/aecm_core_neon.cc.neon \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/min_max_operations_neon.c.neon \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/downsample_fast_neon.c.neon \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/cross_correlation_neon.c.neon \
./libtgvoip/webrtc_dsp/webrtc/common_audio/signal_processing/filter_ar_fast_q12_armv7.S.neon
#LOCAL_SRC_FILES += \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aec/aec_core_neon.cc.neon
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/utility/ooura_fft_neon.cc.neon
LOCAL_SRC_FILES += \
./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/ns/nsx_core_neon.c.neon
#LOCAL_ARM_NEON := true
endif

#ifeq ($(TARGET_ARCH_ABI),x86)
#LOCAL_SRC_FILES += \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aec/aec_core_sse2.cc \
#./libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/utility/ooura_fft_sse2.cc
#endif

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_CPPFLAGS := -Wall -std=c++11 -DANDROID -frtti -DHAVE_PTHREAD -finline-functions -ffast-math -O0
LOCAL_C_INCLUDES += ./jni/boringssl/include/
LOCAL_ARM_MODE := arm
LOCAL_MODULE := tgnet
LOCAL_STATIC_LIBRARIES := crypto

LOCAL_SRC_FILES := \
./tgnet/ApiScheme.cpp \
./tgnet/BuffersStorage.cpp \
./tgnet/ByteArray.cpp \
./tgnet/ByteStream.cpp \
./tgnet/Connection.cpp \
./tgnet/ConnectionSession.cpp \
./tgnet/ConnectionsManager.cpp \
./tgnet/ConnectionSocket.cpp \
./tgnet/Datacenter.cpp \
./tgnet/EventObject.cpp \
./tgnet/FileLog.cpp \
./tgnet/MTProtoScheme.cpp \
./tgnet/NativeByteBuffer.cpp \
./tgnet/Request.cpp \
./tgnet/Timer.cpp \
./tgnet/TLObject.cpp \
./tgnet/FileLoadOperation.cpp \
./tgnet/ProxyCheckInfo.cpp \
./tgnet/Handshake.cpp \
./tgnet/Config.cpp

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_CFLAGS := -Wall -DANDROID -DHAVE_MALLOC_H -DHAVE_PTHREAD -DWEBP_USE_THREAD -finline-functions -ffast-math -ffunction-sections -fdata-sections -O0
LOCAL_C_INCLUDES += ./jni/libwebp/src
LOCAL_ARM_MODE := arm
LOCAL_STATIC_LIBRARIES := cpufeatures
LOCAL_MODULE := webp

ifneq ($(findstring armeabi-v7a, $(TARGET_ARCH_ABI)),)
  NEON := c.neon
else
  NEON := c
endif

LOCAL_SRC_FILES := \
./libwebp/dec/alpha.c \
./libwebp/dec/buffer.c \
./libwebp/dec/frame.c \
./libwebp/dec/idec.c \
./libwebp/dec/io.c \
./libwebp/dec/quant.c \
./libwebp/dec/tree.c \
./libwebp/dec/vp8.c \
./libwebp/dec/vp8l.c \
./libwebp/dec/webp.c \
./libwebp/dsp/alpha_processing.c \
./libwebp/dsp/alpha_processing_sse2.c \
./libwebp/dsp/cpu.c \
./libwebp/dsp/dec.c \
./libwebp/dsp/dec_clip_tables.c \
./libwebp/dsp/dec_mips32.c \
./libwebp/dsp/dec_neon.$(NEON) \
./libwebp/dsp/dec_sse2.c \
./libwebp/dsp/enc.c \
./libwebp/dsp/enc_avx2.c \
./libwebp/dsp/enc_mips32.c \
./libwebp/dsp/enc_neon.$(NEON) \
./libwebp/dsp/enc_sse2.c \
./libwebp/dsp/lossless.c \
./libwebp/dsp/lossless_mips32.c \
./libwebp/dsp/lossless_neon.$(NEON) \
./libwebp/dsp/lossless_sse2.c \
./libwebp/dsp/upsampling.c \
./libwebp/dsp/upsampling_neon.$(NEON) \
./libwebp/dsp/upsampling_sse2.c \
./libwebp/dsp/yuv.c \
./libwebp/dsp/yuv_mips32.c \
./libwebp/dsp/yuv_sse2.c \
./libwebp/enc/alpha.c \
./libwebp/enc/analysis.c \
./libwebp/enc/backward_references.c \
./libwebp/enc/config.c \
./libwebp/enc/cost.c \
./libwebp/enc/filter.c \
./libwebp/enc/frame.c \
./libwebp/enc/histogram.c \
./libwebp/enc/iterator.c \
./libwebp/enc/picture.c \
./libwebp/enc/picture_csp.c \
./libwebp/enc/picture_psnr.c \
./libwebp/enc/picture_rescale.c \
./libwebp/enc/picture_tools.c \
./libwebp/enc/quant.c \
./libwebp/enc/syntax.c \
./libwebp/enc/token.c \
./libwebp/enc/tree.c \
./libwebp/enc/vp8l.c \
./libwebp/enc/webpenc.c \
./libwebp/utils/bit_reader.c \
./libwebp/utils/bit_writer.c \
./libwebp/utils/color_cache.c \
./libwebp/utils/filters.c \
./libwebp/utils/huffman.c \
./libwebp/utils/huffman_encode.c \
./libwebp/utils/quant_levels.c \
./libwebp/utils/quant_levels_dec.c \
./libwebp/utils/random.c \
./libwebp/utils/rescaler.c \
./libwebp/utils/thread.c \
./libwebp/utils/utils.c \

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_CPPFLAGS := -frtti
LOCAL_CFLAGS += '-DVERSION="1.3.1"' -DFLAC__NO_MD5 -DFLAC__INTEGER_ONLY_LIBRARY -DFLAC__NO_ASM
LOCAL_CFLAGS += -D_REENTRANT -DPIC -DU_COMMON_IMPLEMENTATION -fPIC -DHAVE_SYS_PARAM_H
LOCAL_CFLAGS += -O3 -funroll-loops -finline-functions
LOCAL_LDLIBS := -lz -lm
LOCAL_C_INCLUDES := ./jni/exoplayer/libFLAC/include
LOCAL_ARM_MODE := arm
LOCAL_CPP_EXTENSION := .cc
LOCAL_MODULE := flac

LOCAL_SRC_FILES := \
./exoplayer/libFLAC/bitmath.c                     \
./exoplayer/libFLAC/bitreader.c                   \
./exoplayer/libFLAC/bitwriter.c                   \
./exoplayer/libFLAC/cpu.c                         \
./exoplayer/libFLAC/crc.c                         \
./exoplayer/libFLAC/fixed.c                       \
./exoplayer/libFLAC/fixed_intrin_sse2.c           \
./exoplayer/libFLAC/fixed_intrin_ssse3.c          \
./exoplayer/libFLAC/float.c                       \
./exoplayer/libFLAC/format.c                      \
./exoplayer/libFLAC/lpc.c                         \
./exoplayer/libFLAC/lpc_intrin_avx2.c             \
./exoplayer/libFLAC/lpc_intrin_sse2.c             \
./exoplayer/libFLAC/lpc_intrin_sse41.c            \
./exoplayer/libFLAC/lpc_intrin_sse.c              \
./exoplayer/libFLAC/md5.c                         \
./exoplayer/libFLAC/memory.c                      \
./exoplayer/libFLAC/metadata_iterators.c          \
./exoplayer/libFLAC/metadata_object.c             \
./exoplayer/libFLAC/stream_decoder.c              \
./exoplayer/libFLAC/stream_encoder.c              \
./exoplayer/libFLAC/stream_encoder_framing.c      \
./exoplayer/libFLAC/stream_encoder_intrin_avx2.c  \
./exoplayer/libFLAC/stream_encoder_intrin_sse2.c  \
./exoplayer/libFLAC/stream_encoder_intrin_ssse3.c \
#./exoplayer/libFLAC/windows_unicode_filenames.c   \
./exoplayer/libFLAC/window.c

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_ARM_MODE  := arm
LOCAL_MODULE := sqlite
LOCAL_CFLAGS 	:= -w -std=c11 -Os -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1
LOCAL_CFLAGS 	+= -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0

LOCAL_SRC_FILES     := \
./sqlite/sqlite3.c

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false

LOCAL_MODULE 	:= tmessages.29
LOCAL_CFLAGS 	:= -w -std=c11 -Os -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1
LOCAL_CFLAGS 	+= -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS 	+= -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math -D__STDC_CONSTANT_MACROS
LOCAL_CPPFLAGS 	:= -DBSD=1 -ffast-math -Os -funroll-loops -std=c++11
LOCAL_LDLIBS 	:= -ljnigraphics -llog -lz -latomic -lOpenSLES -lEGL -lGLESv2 -landroid
LOCAL_STATIC_LIBRARIES := webp sqlite tgnet avformat avcodec avresample avutil voip flac

LOCAL_SRC_FILES     := \
./opus/src/opus.c \
./opus/src/opus_decoder.c \
./opus/src/opus_encoder.c \
./opus/src/opus_multistream.c \
./opus/src/opus_multistream_encoder.c \
./opus/src/opus_multistream_decoder.c \
./opus/src/repacketizer.c \
./opus/src/analysis.c \
./opus/src/mlp.c \
./opus/src/mlp_data.c

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_ARM_MODE := arm
    LOCAL_CPPFLAGS += -DLIBYUV_NEON
    LOCAL_CFLAGS += -DLIBYUV_NEON
    LOCAL_CFLAGS += -DOPUS_HAVE_RTCD -DOPUS_ARM_ASM
    LOCAL_SRC_FILES += \
#    ./opus/celt/arm/celt_neon_intr.c \
#    ./opus/silk/arm/NSQ_neon.c \
    ./opus/silk/arm/arm_silk_map.c

#    LOCAL_SRC_FILES += ./opus/celt/arm/celt_pitch_xcorr_arm-gnu.S

else
	ifeq ($(TARGET_ARCH_ABI),x86)
	    LOCAL_CFLAGS += -Dx86fix
 	    LOCAL_CPPFLAGS += -Dx86fix
	    LOCAL_ARM_MODE  := arm
#	    LOCAL_SRC_FILES += \
#	    ./libyuv/source/row_x86.asm

#	    LOCAL_SRC_FILES += \
#	    ./opus/celt/x86/celt_lpc_sse.c \
#		./opus/celt/x86/pitch_sse.c \
#		./opus/celt/x86/pitch_sse2.c \
#		./opus/celt/x86/pitch_sse4_1.c \
#		./opus/celt/x86/vq_sse2.c \
#		./opus/celt/x86/x86_celt_map.c \
#		./opus/celt/x86/x86cpu.c \
#		./opus/silk/fixed/x86/burg_modified_FIX_sse.c \
#		./opus/silk/fixed/x86/vector_ops_FIX_sse.c \
#		./opus/silk/x86/NSQ_del_dec_sse.c \
#		./opus/silk/x86/NSQ_sse.c \
#		./opus/silk/x86/VAD_sse.c \
#		./opus/silk/x86/VQ_WMat_sse.c \
#		./opus/silk/x86/x86_silk_map.c
    endif
endif

LOCAL_SRC_FILES     += \
./opus/silk/CNG.c \
./opus/silk/code_signs.c \
./opus/silk/init_decoder.c \
./opus/silk/decode_core.c \
./opus/silk/decode_frame.c \
./opus/silk/decode_parameters.c \
./opus/silk/decode_indices.c \
./opus/silk/decode_pulses.c \
./opus/silk/decoder_set_fs.c \
./opus/silk/dec_API.c \
./opus/silk/enc_API.c \
./opus/silk/encode_indices.c \
./opus/silk/encode_pulses.c \
./opus/silk/gain_quant.c \
./opus/silk/interpolate.c \
./opus/silk/LP_variable_cutoff.c \
./opus/silk/NLSF_decode.c \
./opus/silk/NSQ.c \
./opus/silk/NSQ_del_dec.c \
./opus/silk/PLC.c \
./opus/silk/shell_coder.c \
./opus/silk/tables_gain.c \
./opus/silk/tables_LTP.c \
./opus/silk/tables_NLSF_CB_NB_MB.c \
./opus/silk/tables_NLSF_CB_WB.c \
./opus/silk/tables_other.c \
./opus/silk/tables_pitch_lag.c \
./opus/silk/tables_pulses_per_block.c \
./opus/silk/VAD.c \
./opus/silk/control_audio_bandwidth.c \
./opus/silk/quant_LTP_gains.c \
./opus/silk/VQ_WMat_EC.c \
./opus/silk/HP_variable_cutoff.c \
./opus/silk/NLSF_encode.c \
./opus/silk/NLSF_VQ.c \
./opus/silk/NLSF_unpack.c \
./opus/silk/NLSF_del_dec_quant.c \
./opus/silk/process_NLSFs.c \
./opus/silk/stereo_LR_to_MS.c \
./opus/silk/stereo_MS_to_LR.c \
./opus/silk/check_control_input.c \
./opus/silk/control_SNR.c \
./opus/silk/init_encoder.c \
./opus/silk/control_codec.c \
./opus/silk/A2NLSF.c \
./opus/silk/ana_filt_bank_1.c \
./opus/silk/biquad_alt.c \
./opus/silk/bwexpander_32.c \
./opus/silk/bwexpander.c \
./opus/silk/debug.c \
./opus/silk/decode_pitch.c \
./opus/silk/inner_prod_aligned.c \
./opus/silk/lin2log.c \
./opus/silk/log2lin.c \
./opus/silk/LPC_analysis_filter.c \
./opus/silk/LPC_inv_pred_gain.c \
./opus/silk/table_LSF_cos.c \
./opus/silk/NLSF2A.c \
./opus/silk/NLSF_stabilize.c \
./opus/silk/NLSF_VQ_weights_laroia.c \
./opus/silk/pitch_est_tables.c \
./opus/silk/resampler.c \
./opus/silk/resampler_down2_3.c \
./opus/silk/resampler_down2.c \
./opus/silk/resampler_private_AR2.c \
./opus/silk/resampler_private_down_FIR.c \
./opus/silk/resampler_private_IIR_FIR.c \
./opus/silk/resampler_private_up2_HQ.c \
./opus/silk/resampler_rom.c \
./opus/silk/sigm_Q15.c \
./opus/silk/sort.c \
./opus/silk/sum_sqr_shift.c \
./opus/silk/stereo_decode_pred.c \
./opus/silk/stereo_encode_pred.c \
./opus/silk/stereo_find_predictor.c \
./opus/silk/stereo_quant_pred.c \
./opus/silk/LPC_fit.c

LOCAL_SRC_FILES     += \
./opus/silk/fixed/LTP_analysis_filter_FIX.c \
./opus/silk/fixed/LTP_scale_ctrl_FIX.c \
./opus/silk/fixed/corrMatrix_FIX.c \
./opus/silk/fixed/encode_frame_FIX.c \
./opus/silk/fixed/find_LPC_FIX.c \
./opus/silk/fixed/find_LTP_FIX.c \
./opus/silk/fixed/find_pitch_lags_FIX.c \
./opus/silk/fixed/find_pred_coefs_FIX.c \
./opus/silk/fixed/noise_shape_analysis_FIX.c \
./opus/silk/fixed/process_gains_FIX.c \
./opus/silk/fixed/regularize_correlations_FIX.c \
./opus/silk/fixed/residual_energy16_FIX.c \
./opus/silk/fixed/residual_energy_FIX.c \
./opus/silk/fixed/warped_autocorrelation_FIX.c \
./opus/silk/fixed/apply_sine_window_FIX.c \
./opus/silk/fixed/autocorr_FIX.c \
./opus/silk/fixed/burg_modified_FIX.c \
./opus/silk/fixed/k2a_FIX.c \
./opus/silk/fixed/k2a_Q16_FIX.c \
./opus/silk/fixed/pitch_analysis_core_FIX.c \
./opus/silk/fixed/vector_ops_FIX.c \
./opus/silk/fixed/schur64_FIX.c \
./opus/silk/fixed/schur_FIX.c

LOCAL_SRC_FILES     += \
./opus/celt/bands.c \
./opus/celt/celt.c \
./opus/celt/celt_encoder.c \
./opus/celt/celt_decoder.c \
./opus/celt/cwrs.c \
./opus/celt/entcode.c \
./opus/celt/entdec.c \
./opus/celt/entenc.c \
./opus/celt/kiss_fft.c \
./opus/celt/laplace.c \
./opus/celt/mathops.c \
./opus/celt/mdct.c \
./opus/celt/modes.c \
./opus/celt/pitch.c \
./opus/celt/celt_lpc.c \
./opus/celt/quant_bands.c \
./opus/celt/rate.c \
./opus/celt/vq.c \
./opus/celt/arm/armcpu.c \
./opus/celt/arm/arm_celt_map.c

LOCAL_SRC_FILES     += \
./opus/ogg/bitwise.c \
./opus/ogg/framing.c \
./opus/opusfile/info.c \
./opus/opusfile/internal.c \
./opus/opusfile/opusfile.c \
./opus/opusfile/stream.c

LOCAL_C_INCLUDES    := \
./jni/opus/include \
./jni/opus/silk \
./jni/opus/silk/fixed \
./jni/opus/celt \
./jni/opus/ \
./jni/opus/opusfile \
./jni/libyuv/include \
./jni/boringssl/include \
./jni/ffmpeg/include \
./jni/emoji \
./jni/exoplayer/include \
./jni/exoplayer/libFLAC/include \
./jni/intro

LOCAL_SRC_FILES     += \
./libyuv/source/compare_common.cc \
./libyuv/source/compare_gcc.cc \
./libyuv/source/compare_neon64.cc \
./libyuv/source/compare_win.cc \
./libyuv/source/compare.cc \
./libyuv/source/convert_argb.cc \
./libyuv/source/convert_from_argb.cc \
./libyuv/source/convert_from.cc \
./libyuv/source/convert_jpeg.cc \
./libyuv/source/convert_to_argb.cc \
./libyuv/source/convert_to_i420.cc \
./libyuv/source/convert.cc \
./libyuv/source/cpu_id.cc \
./libyuv/source/mjpeg_decoder.cc \
./libyuv/source/mjpeg_validate.cc \
./libyuv/source/planar_functions.cc \
./libyuv/source/rotate_any.cc \
./libyuv/source/rotate_argb.cc \
./libyuv/source/rotate_common.cc \
./libyuv/source/rotate_gcc.cc \
./libyuv/source/rotate_mips.cc \
./libyuv/source/rotate_neon64.cc \
./libyuv/source/rotate_win.cc \
./libyuv/source/rotate.cc \
./libyuv/source/row_any.cc \
./libyuv/source/row_common.cc \
./libyuv/source/row_gcc.cc \
./libyuv/source/row_mips.cc \
./libyuv/source/row_neon64.cc \
./libyuv/source/row_win.cc \
./libyuv/source/scale_any.cc \
./libyuv/source/scale_argb.cc \
./libyuv/source/scale_common.cc \
./libyuv/source/scale_gcc.cc \
./libyuv/source/scale_mips.cc \
./libyuv/source/scale_neon64.cc \
./libyuv/source/scale_win.cc \
./libyuv/source/scale.cc \
./libyuv/source/video_common.cc

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_CFLAGS += -DLIBYUV_NEON
    LOCAL_SRC_FILES += \
        ./libyuv/source/compare_neon.cc.neon    \
        ./libyuv/source/rotate_neon.cc.neon     \
        ./libyuv/source/row_neon.cc.neon        \
        ./libyuv/source/scale_neon.cc.neon
endif

LOCAL_SRC_FILES     += \
./jni.c \
./audio.c \
./utils.c \
./image.c \
./video.c \
./intro/IntroRenderer.c \
./gifvideo.cpp \
./SqliteWrapper.cpp \
./TgNetWrapper.cpp \
./NativeLoader.cpp \
./emoji/emoji_suggestions_data.cpp \
./emoji/emoji_suggestions.cpp \
./exoplayer/flac_jni.cc \
./exoplayer/flac_parser.cc \
./exoplayer/opus_jni.cc \
./exoplayer/ffmpeg_jni.cc \
./libtgvoip/client/android/tg_voip_jni.cpp \
./fast-edge.cpp \
./genann.c \
./secureid_ocr.cpp

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/cpufeatures)

build.gradle中,

1. 签名部分需要自己添加文件

2. google-services.json 文件需要从高版本目录中提取

3. 我直接注释了NDK部分过程。因为前文我们已经手动编译好了,这里还是一直报错,不知道为啥

然后需要指定路径来打包

sourceSets {
        main {
                jniLibs.srcDirs = ['libs']
            }
    }

附录一下我调试好的build.gradle

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    google()
    jcenter()
}

configurations {
    compile.exclude module: 'support-v4'
}

dependencies {
    compileOnly 'org.checkerframework:checker-qual:2.5.0'
    compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-messaging:17.3.0'
    implementation 'com.google.firebase:firebase-config:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-vision:15.0.2'
    implementation 'com.google.android.gms:play-services-wallet:16.0.0'
    implementation 'com.google.android.gms:play-services-wearable:15.0.1'
    implementation 'com.android.support:support-core-ui:28.0.0-rc01'
    implementation 'com.android.support:support-compat:28.0.0-rc01'
    implementation 'com.android.support:support-core-utils:28.0.0-rc01'
    implementation 'com.android.support:support-v13:28.0.0-rc01'
    implementation 'com.android.support:palette-v7:28.0.0-rc01'
    implementation 'com.android.support:exifinterface:28.0.0-rc01'
    implementation 'net.hockeyapp.android:HockeySDK:5.1.0'
    implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
    implementation 'com.stripe:stripe-android:2.0.2'
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.2'



    defaultConfig.applicationId = "org.telegram.messenger"

 //   sourceSets.main.jniLibs.srcDirs = ['./jni/']

    sourceSets {
        main {
                jniLibs.srcDirs = ['libs']
            }
    }
/*
    externalNativeBuild {
        ndkBuild {
            path "jni/Android.mk"
        }
    }
*/
    lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
    }

    dexOptions {
        jumboMode = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    signingConfigs {
        debug {
            storeFile file("config/birdchat.jks")
            storePassword "tjj31415"
            keyAlias "key0"
            keyPassword "tjj31415"
        }

        release {
            storeFile file("config/birdchat.jks")
            storePassword "tjj31415"
            keyAlias "key0"
            keyPassword "tjj31415"
        }
    }

    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
            signingConfig signingConfigs.debug
            applicationIdSuffix ".beta"
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }

    defaultConfig.versionCode = 1358

    sourceSets.debug {
        manifest.srcFile 'config/debug/AndroidManifest.xml'
    }

    sourceSets.release {
        manifest.srcFile 'config/release/AndroidManifest.xml'
    }

    flavorDimensions "minApi"

    productFlavors {
        armv7 {
            ndk {
                abiFilters "armeabi-v7a"
            }
            ext {
                abiVersionCode = 1
            }
        }
        x86 {
            ndk {
                abiFilters "x86"
            }
            ext {
                abiVersionCode = 2
            }
        }


        arm64 {
            ndk {
                abiFilters "arm64-v8a"
            }
            ext {
                abiVersionCode = 5
            }
        }
        x64 {
            ndk {
                abiFilters "x86_64"
            }
            ext {
                abiVersionCode = 6
            }
        }

        afat {
            sourceSets.debug {
                manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
            }
            sourceSets.release {
                manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
            }
            ext {
                abiVersionCode = 0
            }
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            output.processManifest.doLast {
                def abiVersion = variant.productFlavors.get(0).abiVersionCode
                String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"
                def manifestContent = file(manifestPath).getText()
                manifestContent = manifestContent.replace(String.format('android:versionCode="%d"', defaultConfig.versionCode), String.format('android:versionCode="%s"', defaultConfig.versionCode * 10 + abiVersion))
                file(manifestPath).write(manifestContent)
            }
        }
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionName "4.9.1"

		vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
/*
        externalNativeBuild {
            ndkBuild {
                arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM=android-16", "jobs=8", "LOCAL_SHORT_COMMANDS=true"
                abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
                //abiFilters  "arm64-v8a", "x86_64"
            }
        }
*/

    }
}

apply plugin: 'com.google.gms.google-services'

这时已经可以在模拟器安装了,但是还是运行报错,主要是几个参数没有设置:

把文件org.telegram.messenger.BuildVars里面的参数HOCKEY_APP_HASHHOCKEY_APP_HASH_DEBUG都加上,同一个值就行.需要注册并登陆可以去这里

取页面里面的HOCKEYAPP_APP_ID参数

备注:如果只需要App包起来,BuildVars必填参数

  • APP_HASH:这里
  • APP_HASH: 这里
  • HOCKEY_APP_HASH:这里
  • HOCKEY_APP_HASH_DEBUG:这里

5)附录一些版本号的对应关系

Android 4.4 19 KITKAT Platform Highlights
Android 4.3 18 JELLY_BEAN_MR2 Platform Highlights
Android 4.2, 4.2.2 17 JELLY_BEAN_MR1 Platform Highlights
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
Android 3.2 13 HONEYCOMB_MR2
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
Android 3.0.x 11 HONEYCOMB Platform Highlights
Android 2.3.4
Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights
Android 2.3.2
Android 2.3.1
Android 2.3 9 GINGERBREAD
Android 2.2.x 8 FROYO Platform Highlights
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
Android 2.0.1 6 ECLAIR_0_1
Android 2.0 5 ECLAIR
Android 1.6 4 DONUT Platform Highlights
Android 1.5 3 CUPCAKE Platform Highlights
Android 1.1 2 BASE_1_1

 

6)附录一些NDK下载地址:

Windows

https://dl.google.com/android/repository/android-ndk-r20-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r19c-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r18b-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r17c-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r16b-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r15c-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r14b-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r13b-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r12b-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r11c-windows-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r10e-windows-x86_64.zip


Mac

https://dl.google.com/android/repository/android-ndk-r19c-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r18b-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r17c-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r16b-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r14b-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r13b-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r12b-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r11c-darwin-x86_64.zip

https://dl.google.com/android/repository/android-ndk-r10e-darwin-x86_64.zip

转自:https://www.jianshu.com/p/b534ed223cd2
 

你可能感兴趣的:(telegram,telegram,android)