打包APK时,编译不通过 程序包提示org.apache.http不存在 ?

cocos.bat compile -p android -s G:\work\client -j 2
Updated project.properties
Updated local.properties
Updated file G:\work\client\frameworks\runtime-src\proj.android\proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.
Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml    
make.exe: Entering directory `G:/work/client/frameworks/runtime-src/proj.android'
[armeabi] Prebuilt       : libYvImSdk.so <= jni/prebuild/
[armeabi] StaticLibrary  : libquick_libs.a
[armeabi] StaticLibrary  : libextra.a
[armeabi] StaticLibrary  : libquickextensions.a
[armeabi] StaticLibrary  : libluacocos2d.a
[armeabi] StaticLibrary  : libcocos2d.a
[armeabi] StaticLibrary  : liblocalstorage.a
[armeabi] StaticLibrary  : libspine.a
[armeabi] StaticLibrary  : libui.a
[armeabi] StaticLibrary  : libcocosdenshion.a
[armeabi] StaticLibrary  : libextension.a
[armeabi] StaticLibrary  : libaudioengine.a
[armeabi] StaticLibrary  : libnetwork.a
[armeabi] StaticLibrary  : libcocos2dxinternal.a
[armeabi] StaticLibrary  : libluacocos2dandroid.a
[armeabi] StaticLibrary  : libcocos2dandroid.a
[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] Gdbserver      : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[armeabi] Install        : libYvImSdk.so => libs/armeabi/libYvImSdk.so
[armeabi] SharedLibrary  : libcocos2dlua.so
directory G:/BuildCodeCPP/dev-env/android/ndk/android-ndk-r10e/platforms/android-21/arch-arm/usr/include jni/prebuild G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//audio/android/../include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//audio/android/../.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//audio/android/../../platform/android G:/BuildCodeCPP/dev-env/android/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include G:/BuildCodeCPP/dev-env/android/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include G:/BuildCodeCPP/dev-env/android/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/backward G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../../external/lua/tolua G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/platform/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/platform/android/jni G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/lua/luajit/prebuilt/android/../../include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../../external/lua/luajit/include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../2d G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../3d G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../network G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../editor-support/spine G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../ui G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../../extensions G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../../../runtime-src/Classes G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../auto G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/cocos2d G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/cocosdenshion G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/audioengine G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/network G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/extension G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/spine G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../manual/ui G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../../external/xxtea G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//scripting/lua-bindings/proj.android/../../../../external/lua/quick G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//storage/local-storage/.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//editor-support/spine/.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//network G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//network/.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//ui/../editor-support G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./platform G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./base G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/asio G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/tinyxml2 G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/unzip G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/xxhash G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/nslog G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/poly2tri G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/poly2tri/common G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/poly2tri/sweep G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/clipper G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/curl/prebuilt/android/../../include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/websockets/prebuilt/android/../../include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/extensions/. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/extensions/.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/extensions/GUI/CCControlExtension G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/extensions/GUI/CCScrollView G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/freetype2/prebuilt/android/../../include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/freetype2/prebuilt/android/../../include/android/freetype2 G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/png/prebuilt/android/../../include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/jpeg/prebuilt/android/../../include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/external/zlib/prebuilt/android/../../include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android G:/BuildCodeCPP/dev-env/android/ndk/android-ndk-r10e/sources/android/cpufeatures jni/../../Classes jni/../../Classes/YunVaSDK jni/../../IM_SDK/include jni/../../../cocos2d-x/external G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/proj.android/.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra/luabinding G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/ G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/cjson G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/zlib G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/filesystem G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/lpack G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/lsqlite3 G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../exteral/edtaa3func G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//./../external/ConvertUTF G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/../.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//storage/local-storage/../.. G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//network/../../external/websockets/include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//network/../../external/curl/include/android G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra/../../cocos G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra/../../external/lua/luajit/include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra/../../external/lua/tolua G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra/../../cocos/scripting/lua-bindings/manual G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extra/../../extensions G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/debugger G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/../../cocos G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/extensions/../../external/lua/luajit/include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/proj.android/../../cocos G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/proj.android/../../external/lua/luajit/include G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/proj.android/../../external/lua/tolua G:/work/client/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//../quick_libs/proj.android/../../cocos/scripting/lua-bindings/manual >> ./libs/armeabi/gdb.setup
[armeabi] Install        : libcocos2dlua.so => libs/armeabi/libcocos2dlua.so
make.exe: Leaving directory `G:/work/client/frameworks/runtime-src/proj.android'
Buildfile: G:\work\client\frameworks\runtime-src\proj.android\build.xml

-check-env:
 [checkenv] Android SDK Tools Revision 25.2.5
 [checkenv] Installed at G:\BuildCodeCPP\dev-env\android\sdk\android-sdk-windows

-setup:
     [echo] Project Name: decivise
  [gettype] Project Type: Application

-pre-clean:

clean:
   [delete] Deleting directory G:\work\client\frameworks\runtime-src\proj.android\bin
   [delete] Deleting directory G:\work\client\frameworks\runtime-src\proj.android\gen
[getlibpath] Library dependencies:
[getlibpath] No Libraries
   [subant] No sub-builds to iterate on

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 25.2.5
 [checkenv] Installed at G:\BuildCodeCPP\dev-env\android\sdk\android-sdk-windows

-setup:
     [echo] Project Name: decivise
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 28.0.0
     [echo] Resolving Build Target for decivise...
[gettarget] Project Target:   Android 9
[gettarget] API level:        28
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\bin
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\bin\res
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\bin\rsObj
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\bin\rsLibs
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\gen
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\bin\classes
    [mkdir] Created dir: G:\work\client\frameworks\runtime-src\proj.android\bin\dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for decivise...
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] Found 1 AIDL files.
     [aidl] Compiling 1 AIDL files.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 42 source files to G:\work\client\frameworks\runtime-src\proj.android\bin\classes
    [javac] 警告: [options] 源值1.5已过时, 将在未来所有发行版中删除
    [javac] 警告: [options] 目标值1.5已过时, 将在未来所有发行版中删除
    [javac] 警告: [options] 要隐藏有关已过时选项的警告, 请使用 -Xlint:-options。
    [javac] G:\work\client\frameworks\runtime-src\proj.android\src\org\cocos2dx\lua\PlatformSDK.java:7: 错误: 程序包org.apache.http不存在
    [javac] import org.apache.http.Header;
    [javac]                       ^
    [javac] G:\work\client\frameworks\runtime-src\proj.android\src\org\cocos2dx\lua\PlatformSDK.java:8: 错误: 程序包org.apache.http.entity不存在
    [javac] import org.apache.http.entity.StringEntity;
    [javac]                              ^
    [javac] 注: 某些输入文件使用或覆盖了已过时的 API。
    [javac] 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
    [javac] 注: 某些输入文件使用了未经检查或不安全的操作。
    [javac] 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
    [javac] 2 个错误
    [javac] 3 个警告
编译模式:debug
使用 Eclipse 工程:G:\work\client\frameworks\runtime-src\proj.android
未指定 Android 目标平台版本,自动查找一个可用版本...
正在执行:'"G:\BuildCodeCPP\dev-env\android\sdk\android-sdk-windows\tools\android" update project -t android-28 -p G:\work\client\frameworks\runtime-src\proj.android'

正在执行 ndk-build...
NDK 编译模式:debug
NDK_TOOLCHAIN_VERSION: 4.9
正在执行:'"G:\BuildCodeCPP\dev-env\android\ndk\android-ndk-r10e\ndk-build" -C G:\work\client\frameworks\runtime-src\proj.android -j2 NDK_MODULE_PATH=G:\work\client\frameworks\runtime-src\proj.android\../../cocos2d-x;G:\work\client\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos/;G:\work\client\frameworks\runtime-src\proj.android\../../cocos2d-x/external;G:\work\client\frameworks\runtime-src\proj.android\../../cocos2d-x/cocos/scripting NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1'

正在生成 apk 文件...
正在执行:'"G:\BuildCodeCPP\dev-env\android\ant\apache-ant-1.10.5\bin\ant" clean debug -f G:\work\client\frameworks\runtime-src\proj.android\build.xml -Dsdk.dir="G:\BuildCodeCPP\dev-env\android\sdk\android-sdk-windows"'

执行命令出错,返回值:1。

严重错误提示:

 [javac] G:\work\client\frameworks\runtime-src\proj.android\src\org\cocos2dx\lua\PlatformSDK.java:7: 错误: 程序包org.apache.http不存在
    [javac] import org.apache.http.Header;
    [javac]                       ^
    [javac] G:\work\client\frameworks\runtime-src\proj.android\src\org\cocos2dx\lua\PlatformSDK.java:8: 错误: 程序包org.apache.http.entity不存在
    [javac] import org.apache.http.entity.StringEntity;

    useLibrary 'org.apache.http.legacy'

我的 proj.android 文件夹下面。没有 build.gradle 文件。

proj.android-studio 文件夹下有 build.gradle 文件,而且我发现 useLibrary 配置就是 ‘org.apache.http.legacy’ 。

那我下载一个 Android-studio 打包APK,试试?

@BigBear 大佬可以帮忙看下嘛?

引擎版本:cocos2d-x-3.9
NDK:android-ndk-r10e

我找到解决方案了。
参考链接:https://blog.csdn.net/yy1300326388/article/details/48784475
我是根据这个方法解决的。

我在配置文件里加入了‘useLibrary ‘org.apache.http.legacy’,但始终不能在Android studio里引入这个jar,是什么原因呢?我的SDK目录里确实有这个jar,后来还是将jar拷贝到项目里的libs目录下才解决的

打包APK时,还遇到下面这个错误。
[dex] Pre-Dexing G:\work\client\frameworks\runtime-src\proj.android\libs\yayavoice_libs_20170523.jar
[dx] Error occurred during initialization of VM
[dx] Could not reserve enough space for 1048576KB object heap

经Google之后,我关掉很多程序,确保是64位Java程序后,打包就成功了。