NDK支持AndroidStudio和Android Studio和Eclipse之间进行选择 [英] NDK support in AndroidStudio and choosing between Android Studio and Eclipse
问题描述
我到了一个竞争条件的Android Studio和Eclipse之间进行选择:
- 在我的项目需要一些C ++ code与我的应用程序联系起来。在机器人工作室1.0目前不支持NDK(德precated?!)。话说德precated没有透露整个丑陋的画面。目前,它是相当未知如何,甚至只是链接你的pre-编译的.so库项目。不要谈论编译......虽然很多很多的解决方案,这个每天都在公布的计算器。大多数都涉及到一些pre-beta版本,然后就是不工作,没有现成的,而不是浪费了一些相当长的时间cheking他们之后。
解决方案我已经检查到目前为止:
一个。 NDK随着Android的工作室
℃。 NDK摇篮/ Android的工作室的支持,你打算释放它?
所有这些都是完全不同的,复杂的整合,只是不会工作...
<醇开始=2>这使我想到的问题。 在这environemnt我应该选择? 难道谷歌真的关心他们的开发人员那么多吗?难道他们只是提供一些简单的使用解决方案最新版本??
目前它是相当未知如何,甚至只是链接你的pre-编译的.so库项目。
事实并非如此。在过去,你会压缩它们,重命名存档罐子,包括在您的项目。现在,添加ABI特定版本&LT;项目&GT; /&LT;模块&GT; / src目录/主/ jniLibs /&LT; ABI&GT;
目录(只要你不改变你的sourcesets )。
这有一个主要优势。您可以拆分所产生的 .apk文件
成几个根据ABI每个仅包括其特定的本地库。下面code样本将确保您获得多个 .apk文件
S的基于ABI,每次都会有不同的版本code
根据需要看起来像这样: Axxxxxx
,其中 A
是ABI code,你会得到6位数字的原始版本code。样品code为假定在应用模块中使用。机库将从所有的应用程序的自动依赖回升。
安卓{
// ...
拆分{
ABI {
实现真正的
复位()
包括86,armeabi-V7A,armeabi//指定ABIS你想
universalApk真//如果你想有一个综合的apk以及
}
}
project.ext.version codeS = [//拥有这个是
'armeabi':1,
'armeabi-V7A':2,
'arm64-V8A':3,
MIPS:5,
'MIPS64':6,
86:8,
x86_64的:9
]
android.applicationVariants.all {变种 - &GT;
//为每个输出分配不同的版本code
variant.outputs.each {输出 - &GT;
//保持这种在同一行 - 常规不需要分号,该值可能不完全再
output.version codeOverride = project.ext.version codes.get(output.getFilter(com.android.build.OutputFile.ABI),0)* 1000000 + android.defaultConfig.version code
}
}
}
上面的例子是工作以及我的项目中。
不要谈论编译...
考虑到我花了几个小时试图非原生库项目转换为为一体,并失败,我建议,如果你已经开发的本机项目,保持它的自治系统外,并建立它作为的.so
秒。
我会考虑这一点,并更新了答案,一旦我找到一些有用的东西。不过,我已经找到了你原来的来源很有趣( http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/ )。 基本premise为您更换据的 http://ph0b.com/android-studio-gradle-and-ndk-integration/ (节 Android.mk
, Core.mk
和 Core2.mk
与在 build.gradle
文件的说明编译你的C / C ++源$ C $从Android的工作室ç
),您可以覆盖此默认行为(临时生成文件从摇篮指令)。
I got to a 'race condition' choosing between Android studio and Eclipse:
- My project needs some C++ code to be linked with my app. Currently NDK is not supported (deprecated ?!) in Android Studio 1.0. Saying deprecated does not reveal the whole UGLY PICTURE. Currently it's quite unknown how to even just link your pre-compiled .so libraries to a project. Not to talk about compiling... Although many many solutions to this are being posted in stackoverflow every day. Most of are related to some pre-beta versions, and just dont work, not out of the box, and not after wasting some considerable time cheking them.
Solutions I have checked so far:
b. Android studio, gradle and NDK
c. NDK gradle / Android Studio support, are you planning to release it?
d. Using the Android NDK with Android Studio- Part 1
All of which are quite different and complex to integrate, and just wont work...
- Developing for future Lollipop is, well, being blocked by Google, as they will just not allow using their new SDK's for some time now in Eclipse !?? Why?
Which brings me to the question. In which environemnt should I choose? Do google really care about their developers that much? Can't they just provide some simple usage solution for current version??
Currently it's quite unknown how to even just link your pre-compiled .so libraries to a project.
Not true. In the past you would zip them, rename the archive to jar and include it in your project. Now you add ABI specific versions to <project>/<module>/src/main/jniLibs/<abi>
directory (provided you didn't alter your sourcesets).
This has one major advantage. You can split the resulting .apk
into several based on ABI each including only its specific native libraries. The following code sample will ensure you get multiple .apk
s based on ABI, each will have a different versionCode
as required looking like this: Axxxxxx
where A
is ABI code and you get 6 digits for your original version code. The sample code is supposed to be used in an application module. Native libraries will be picked from all app's dependencies automatically.
android {
//...
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a', 'armeabi' // specify abis you want
universalApk true // if you want a composite apk as well
}
}
project.ext.versionCodes = [ // keep this as is
'armeabi':1,
'armeabi-v7a':2,
'arm64-v8a':3,
'mips':5,
'mips64':6,
'x86':8,
'x86_64':9
]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
// keep this on one line - groovy doesn't need semicolons, the value might not be complete then
output.versionCodeOverride = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
}
}
}
The above example is working well within my project.
Not to talk about compiling...
Considering I spent some hours trying to convert a non-AS native library project to an AS one and failed, I'd suggest that if you have already developed native project, keep it outside of AS and build it as .so
s.
I will look into this and update the answer once I find something useful. However I already found one of your original sources quite interesting (http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/). The basic premise is that you replace According to http://ph0b.com/android-studio-gradle-and-ndk-integration/ (section Android.mk
, Core.mk
and Core2.mk
with instructions in the build.gradle
file.Compiling your C/C++ source code from Android Studio
) you can override this default behavior (ad-hoc makefile from gradle instructions).
这篇关于NDK支持AndroidStudio和Android Studio和Eclipse之间进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!