[android ndk] -android studio中编译生成so文件

本文详细介绍了在Android开发中遇到的NDK编译问题,包括错误提示、解决步骤和注意事项。通过调整gradle.properties文件设置、清理项目缓存等方法,可以有效解决编译失败的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.android.useDeprecatedNdk=true

Error:Execution failed for task ':app:compileDebugNdk'.
> Error: NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental. Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.

该问题是需要在工程目录下的gradle.properties文件下,加上android.useDeprecatedNdk=true即可

 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2.build.gradle少了配置

Warning:Native C/C++ source code is found, but it seems that NDK option is not configured. Note that if you have an Android.mk, it is not used for compilation. The recommended workaround is to remove the default jni source code directory by adding:
android {
sourceSets {
main {
jni.srcDirs = []
}
}
}
to build.gradle, manually compile the code with ndk-build, and then place the resulting shared object in src/main/jniLibs.
make.exe: *** No rule to make target `E:\as_workspaces\IntentDemo\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/app/E_\as_workspaces\IntentDemo\app\src\main\jni', needed by `E:\as_workspaces\IntentDemo\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/app/E_\as_workspaces\IntentDemo\app\src\main\jni\JNI_Demo.o'. Stop.
:app:compileDebugNdk FAILED

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

3.

make.exe: *** No rule to make target `E:\as_workspaces\IntentDemo\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/JNI_Demo/E_\as_workspaces\IntentDemo\app\src\main\jni', needed by `E:\as_workspaces\IntentDemo\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/JNI_Demo/E_\as_workspaces\IntentDemo\app\src\main\jni\JNI_Demo.o'.  Stop.

Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Android\android-ndk-r10\ndk-build.cmd'' finished with non-zero exit value 2

------------------------------------------------------------------------------- 

4.关于Eclipse中始终无法编译通过的问题

如果觉得JNI的代码都没有错,就先clean一下项目清下缓存,然后把命令行窗口关闭,重新再打开。再试一下即可。

------------------------------------------------------------------------------- 

5.Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml

如果.mk文件里没有定义APP_PLATFORM android-19,那么会使用默认的。所以加上后,把project.properties里面也改成target=android-19。AndroidManifest.xml里面android:minSdkVersion可以不改

------------------------------------------------------------------------------- 

6.Android NDK: LOCAL_MODULE definition in jni/Android.mk must not contain space

这个问题是因为.mk文件里面有空格字符,你可以把里面的中文注释都去掉,把中文空格都改成英文空格,或者干脆都去掉。

------------------------------------------------------------------------------- 

7.

http://www.th7.cn/Program/Android/201509/550864.shtml

http://blog.youkuaiyun.com/lamp_zy/article/details/48976737

http://blog.k-res.net/archives/1788.html

http://www.cnblogs.com/flyme/p/4431762.html

http://blog.k-res.net/archives/1788.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值