简体   繁体   English

Android Gradle构建两次包含jni库

[英]Android gradle build includes jni libs twice

I've been trying to solve a problem about Android build, but couldn't figure out how to solve it. 我一直在尝试解决有关Android构建的问题,但不知道如何解决。 Basically, I am trying to build an Android project using Gradle. 基本上,我正在尝试使用Gradle构建一个Android项目。 It works perfect, but the size of the final apk is 7MB more than when I builded with Eclipse. 它可以完美运行,但是最终apk的大小比我使用Eclipse构建时大了7MB。

When I unzip the apk, I see that the JNI Libs are included twice. 解压缩apk时,我发现JNI Lib被包含两次。 Which is different from the Eclipse build that includes it only one time. 这与只包含一次的Eclipse构建不同。 Here is the paths I can find them in the APK: 这是我可以在APK中找到它们的路径:

  • lib/armeabi LIB / armeabi
  • lib/armeabi-v7a LIB / armeabi-V7A
  • main/jniLibs/armeabi 主/ jniLibs / armeabi
  • main/jniLibs/armeabi-v7a 主/ jniLibs / armeabi-V7A

In my project, those two files are in: 在我的项目中,这两个文件位于:

  • android/app/src/main/jniLibs/armeabi Android设备/应用/ src目录/主/ jniLibs / armeabi
  • android/app/src/main/jniLibs/armeabi-v7a Android设备/应用/ src目录/主/ jniLibs / armeabi-V7A

I have two different build.graddle files in: 我在以下两个不同的build.graddle文件中:

  • android/ 安卓/
  • android/app/ Android设备/应用/

None of them contains anything related to the JNI Libs. 它们均不包含与JNI库有关的任何内容。

To build a release, I use the command: 要构建发行版,我使用以下命令:

./gradlew assembleRelease

And everything works fine. 而且一切正常。 I use Gradle 1.10. 我使用Gradle 1.10。

I was wondering if someone ever encountered the problem and find a solution to avoid to the JNI Libs to be included twice in the APK. 我想知道是否有人遇到过这个问题,并且找到了一种解决方法,以避免将JNI Libs包含在APK中两次。

Thanks :) 谢谢 :)

Put .so files in... 将.so文件放入...

/src/main/jniLibs/armeabi-v7a /src/main/jniLibs/x86 / src / main / jniLibs / armeabi-v7a / src / main / jniLibs / x86

directories and gradle will correctly package the .so files into the correct app and it won't include the duplicates 目录和gradle会将.so文件正确打包到正确的应用中,并且不会包含重复项

This is a good reference.. http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/ 这是一个很好的参考。.http ://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM