搭建SDL 的Android 开发环境,的详细步骤(建立sdl2.0 for Android开发环境)

搭建SDL 的Android 开发环境,的详细步骤(建立sdl2.0 for Android开发环境)


1.安装下载jdk,进入该网页: http://java.sun.com/javase/downloads/index.jsp (或者直接点击下载)如下图:
选择 Download JDK 只下载JDK,无需下载jre.



这里是用的windows xp,32位机器,所以下载 windows X86 i586,下面我都是以windows xp为基础来说明。



我这里下载了两个,你要下载最新版的,并且安装最新版的就可以了。




2.下载安装,Android SDK,地址:


http://developer.android.com/sdk/index.html




选自己的对应机型下载。




点击如上图,下载,下载完毕(我这里是32位的xp)





3.下载android-ndk-r7b安装包,下载地址:


地址:http://developer.android.com/sdk/ndk/index.html


下载后解压缩到你的工作目录,例如:C:\Android\android-ndk-r9c,结果如下图:



现在你下载好最新的ndk并且解压出来了:




Android ndk包含build、docs、samples、sources、GNUmakefile、ndk-build、ndk-gdb及readme等内容。
其中samples下面包含几个实例开发演示项目。




4.注意,网上有些人说要另外下载Eclipse,现在其实是不需要的,只需要下载Android SDK,里面集成了相对于Android开发的Eclipse。






5.下载完毕,先安装JDK, 安装jdk如图:




然后安装Android SDK,只需解压下载的压缩包,注意不要有中文路径,很多开发工具不支持中文。
解压完之后,如图:




adt-bundle-windows-x86-20131030就是sdk以及Eclipse开发工具,google人性化很好,非常绿色(就是我的老爷机用起来很慢)。




6. 最后解压安装ndk。只要将ndk解压到你的想要的文件目录下面便可(强调:解压出来的路径不要有中文),我的如下图:




7. 打开adt-bundle-windows-x86-20131030 文件夹里面的,Eclipse.exe,启动画面如图,这个就是Android的开发ide了:




8.在Eclipse中设定ndk。





指定你解压出来的ndk的文件路径:






9.到这里,你的Android ndk 开发环境以及算基本搭建完毕,可以试试建立一个 HelloWorld




建立一个Android application :







设定 程序图标:



选择blank activity




看到Eclipse IDE 窗口左侧生成了一个helloworld的 activitiy




此时,创建了一个简单的Android空白工程,里面有HelloWorld语句;





10.创建一个Android模拟器来进行模拟程序:






在上面设定有段的模拟器的 内存,加速,版本,还有屏幕大小等参数。名字随你起。
然后运行你上面的helloworld。




弹出Android模拟器,开机启动Android中。。。。。





在这个时间,我的姥爷机特别慢......你如果也是老爷机,那么可以先去喝杯茶。


喝完茶之后,发现:

HelloWorld出现了。










//===========================================================================================//

11.你可以去搭建sdl图形开发环境了,现在的sdl2.0支持在Android用jni c去编程,不过据说SDL2.0 Android现在还有很多bug。


SDL(Simple DirectMedia Layer)是一套开放源代码的跨平台多媒体开发库,使用C语言写成。SDL提供了数种控制图像、声音、输出入的函数,让开发者只要用相同或是相似的代码就可以开发出跨多个平台(Linux、Windows、Mac OS X等)的应用软件。目前SDL多用于开发游戏、模拟器、媒体播放器等多媒体应用领域,而且现在支持Android(尽管不是很成熟)。


下面是在外国网上找到的我成功编译出来的教材,跟着他的步骤可以容易的配置Android SDL开发环境

//
//
Android Programming using SDL and C - Setting up the Build System and Compiling a First Program
Sat, 07/28/2012 - 07:07 — Benjamin Caspari
As Android programs are usually written in Java, it's a bunch of work to set up the build system to write SDL programs in C. However, this will give you a better performance than writting them in Java, since the library itself is also written in C and JNI calls are expensive!
I have set up the build environment using Windows 7, but using Linux should work the same way.


1. Get the Android SDK and install it
Get the Android SDK from its official site and install it following the detailed instructions that you can find there, including Eclipse and the ADT plugin and setting up an Android virtual device. Make sure it works correctly, for example by compiling and starting the "Hello world" example.


2. Get the Android NDK and install it
Also download the Android NDK from here and extract it. I recommend adding the path to your PATH environment variable.


3. Get SDL 2.0
Download the source snapshot of SDL 2.0.


4. Create your project
After you extracted the source snapshot, copy the android-project directory and rename it. You will build your project directory based on this. Now, copy the SDL subdirectory from the archive into the jni directory of your project. Rename the SDL_config_android.h file in the includes subdirectory to SDL_config.h (Overwrite the existing one!). Place your SDL application source files into the jni\src directory and add all source files to the android.mk file there(其实SDL里面的文件就是官网下载的sdl加压出来的根目录的src和include,和Android.mk,注意要修个include里面的config头文件,替换掉原来的文件,同时候记得替换mk文件里面的YourSourceHere为你的源文件名):





Make sure that Android.mk in the SDL subdirectory contains "LOCAL_MODULE := SDL2" and not "LOCAL_MODULE := SDL" - this is a known bug in the source for now




Before compiling the C code, you should create an Eclipse project. Start Eclipse and choose "File -> New -> Other -> Android Project from Existing Code". Select your projets directory and create the corresponding clipse project. Select the right build target in the projects properties (at least Android 1.6!):




5. Compile and run your project





After saving your Eclipse project, open a command line, navigate to your projects base directory and call the ndk-build script from there. You should see a output similar like this:


If you get linker errors (e.g. missing OpenGL libs), be sure that the right target in your project.properties file is set (e.g. "target=android-10"). A quick and dirty soultion may be to add the line "APP_PLATFORM := android-9" to the file \build\core\add-application.mk.
Now you can run the project from Eclipse in your Android virtual device:


Now you can edit your programs properties and add new code - recompile the c code by calling the ndk-build script every time you changed it.


If you get lint errors complaining about the wrong Android API, go to the projects preferences, choose "Android Lint Preferences" and set the severity for NewApi to "Warning" or less - this is a known bug at the moment:


/
/















用上面“它” 的方法基本可以编译过去,我个人修改了些:




APP_STL:=gnustl_static
APP_ABI:=armeabi armeabi-v7a
同时我添加修个了自己的main.c的源代码:






然后,在工程文件的目录下面重新 ndk-build,可以生成SDL 库文件,编译通过,如图:





运行结果,刷红色的屏幕,跟程序一样,运行正常,ok,到这里停笔。



sdl Android 示例工程下载地址:

工程源码下载地址:

http://download.csdn.net/detail/mynameislinduan/6819481




如转载请标明出处,原创者Done Lin  :http://my.csdn.net/mynameislinduan


SDL是一个跨平台的多媒体开发库,可以在不同操作系统的平台上进行多媒体应用的开发。在Android平台上,可以利用SDL进行视频播放的开发。 使用SDL进行Android视频播放的步骤如下: 1. 引入SDL库:在Android项目中引入SDL库,并在项目的build.gradle文件中进行相应配置。 2. 创建SDLActivity:创建一个继承自SDLActivity的Activity类,并实现SDLInterface接口。 3. 初始化SDL:在SDLActivity的onCreate()方法中,进行SDL的初始化操作。可以设置屏幕信息、音频信息等。 4. 加载视频:在SDLActivity的onResume()方法中,进行视频资源的加载操作。可以使用SDL_video.h中的API进行视频资源的加载。可以将视频资源放在assets目录下,使用SDL_RWFromFile函数进行加载。 5. 处理视频帧:在SDLActivity的onNativeResize()方法中,通过SDL_GetWindowSurface函数获取视频帧。然后将视频帧进行解码、渲染等处理操作。 6. 播放视频:通过SDL_RenderPresent函数将处理后的视频帧进行播放。 7. 退出播放:在SDLActivity的onPause()方法中,进行视频播放的释放操作。可以使用SDL_FreeSurface函数释放视频帧资源。 总结:利用SDL进行Android视频播放的开发,主要涉及SDL库的引入、SDLActivity的创建与初始化、视频资源的加载与处理、视频帧的渲染与播放等步骤。通过以上步骤,可以实现基于SDLAndroid视频播放功能。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mynameislinduan

你的鼓励是我最大动力写博客不易

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值