简体   繁体   English

构建配置和Android NDK

[英]Build Configurations and the Android NDK

I've spent the last few days struggling with getting a system up and running for building multiple configurations of our Android NDK App. 在过去的几天里,我一直在努力建立一个系统并运行以构建Android NDK应用程序的多个配置。 I am able to build the libraries fine; 我能够很好地建立图书馆; the issues I run into usually stem from keeping those libraries up to date when changing build configurations. 我遇到的问题通常源于在更改构建配置时保持这些库的最新状态。

I need a system that is for the most part fully automated: the user should just change build configurations and everything just works ! 我需要一个大部分完全自动化的系统:用户应该只改变构建配置,一切正常

How have you addressed build configurations and the issues with libraries not being properly rebuilt? 您是如何解决构建配置以及库未正确重建的问题?

I've tried a bunch of different approaches to this, but they all seem to end up with issues that are out of my hands. 我已经尝试了很多不同的方法,但它们似乎最终都出现了我手中的问题。

Initially we just outputted a Shared Object file with the same name regardless of Build Configuration (eg. game.so). 最初,我们只输出一个具有相同名称的共享对象文件,而不管构建配置如何(例如game.so)。 The problem is , changing build configurations doesn't trigger the library to be rebuilt; 问题是 ,更改构建配置不会触发重建库; you have to make a change to the source or build scripts. 你必须对源代码或构建脚本进行更改。 So people change from Debug to Release, run the app, and are unknowingly actually linking to the Debug version still. 所以人们从Debug变为Release,运行应用程序,并且在不知不觉中仍然实际链接到Debug版本。

So then we tried outputting the library to a unique Shared Object based on the build configuration. 因此,我们尝试根据构建配置将库输出到唯一的共享对象。 For example, the debug version is gamed.so. 例如,调试版本是gamed.so。 The release version is gamer.so. 发布版本是gamer.so。 The problem is , the Java code has no concept of build configuration, so how do we know which version of the library to load (which is done from Java)? 问题是 ,Java代码没有构建配置的概念,那么我们如何知道要加载哪个版本的库(这是从Java完成的)?

Well to get around that we do a try/catch looping through all the possible versions of the library attempting to load them. 好吧,为了解决这个问题,我们在试图加载它们的库的所有可能版本中进行try / catch循环。 When we find the one that exists, load it! 当我们找到存在的那个时,加载它! Problem being that the old versions of the library do not get removed when deploying a new configuration to the phone. 问题是在将新配置部署到手机时不会删除旧版本的库。 So if you have built and run both Debug and Release, both of those libraries are now on the phone! 因此,如果您已经构建并运行了Debug和Release,那么这两个库现在都在手机上了! Which ever one you ask for first, it will find and load. 你首先要求的是它,它会找到并加载。

So anyway, this seems like something that must have been solved already, but I have found very little information online. 所以无论如何,这似乎喜欢的事, 必须已解决,但我在网上找到的信息非常少。 Nothing that has met my needs. 没有什么能满足我的需求。

My question is: how have you addressed build configurations and the issues with libraries not being properly rebuilt? 我的问题是: 您如何处理构建配置以及库未正确重建的问题?

This is actually strange. 这实际上很奇怪。 I have always seen that install -r refreshes the /data/data/app.pack.age/lib directory. 我一直看到install -r刷新/data/data/app.pack.age/lib目录。 Which device do you use for development? 您使用哪种设备进行开发?

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

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