在studio中使用libsdl2.so,编译SDL Demo
1.准备编译好的libSDL2.so,编译方法下一篇《linux下交叉编译android版本的libSDL2.so》详述。需要的目录结构是
libs
|--armeabi
|--libmain.so
|--libSDL2.so
|--armeabi-v7a
|--libmain.so
|--libSDL2.so
该libSDL2.so由android API 26,在debian系统中编译而来,studio环境在windows 7.
2. 打开studio,选择Import project
3. 本例子从官网下载的最新SDL2-2.0.5.zip,选择android-project
4.后面的步骤,都是默认。
5.Build --> Make Project,报错:
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 "$USE_DEPRECATED_NDK=true" in gradle.properties to continue using the current NDK integration.
6.为了解决第5点的错误,在工程目录下,新增一个文件gradle.properties,填入一句配置
android.useDeprecatedNdk=true
7.重新 build-->make project , 成功了!但是工作还没有结束。如果直接运行,会报错,因为找不到libSDL2.so
8.在app目录下,创建libs目录,将前面准备好的.so文件的目录拷进去,如下:
9.在app目录下的build.gradle加入
sourceSets { main { jniLibs.srcDirs = ['libs'] } }
10. run-->run‘app’,大功告成!
posted on 2017-10-12 21:26 zhuxian2009 阅读(229) 评论(0) 编辑 收藏 举报