使用Android Studio进行cocos2d-x开发
2023-09-27 14:28:00 时间
cocos2d-x进行android时官方使用的是eclipse+ADT+NDK的模式,但是随着Android Studio正式版的推出,越来越多的开发者正开始转变他们的开发工具为Android Studio。
Android Studio相对于eclipse+ADT的优势 Android Studio是基于Intellij的IDEA社区版进行开发而成的,而IDEA则被誉为最智能的JAVA开发工具,Android Studio在智能提醒、预览xml布局界面等功能方面相较于eclipse方面是比较优势的。 ADT正在被谷歌官方边缘化,谷歌方面已经宣布不再对ADT进行支持开发了,这将意味着很多bug得不到及时的修复、新功能难以添加上去。 Android Studio具有更加优秀的用户界面。 使用Android Studio进行cocos2d-x的开发 Android Studio的ndk配置Android Studio使用ndk十分方便。
1
2
3
4
5
6
7
8
9
10
11
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C\:/Android/android-sdk-windows
ndk.dir=C\:/Android/android-ndk-r10e
1
2
3
4
5
sourceSets.main {
jni.srcDirs = [] // 这里代表的是c++源码的目录,默认不写为src/main/jni下,因为在windows下直接使用gradle进行编译会出错,因为这里将它制空,然后后面用其他脚本进行编译
jniLibs.srcDir src/main/libs // 生成的.so的目录
assets.srcDir src/main/assets // assets目录
} /span br /pre /td /tr /tbody /table /figure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
buildscript {
repositories {
jcenter()
}
dependencies {
classpath com.android.tools.build:gradle:1.1.1
}
}
apply plugin: com.android.application
repositories {
jcenter()
// flatDir{
// dirs libs
// }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.vincent.twoplusone.app"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(proguard-android.txt), proguard-rules.pro
}
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir src/main/libs
assets.srcDir src/main/assets
}
}
dependencies {
compile fileTree(dir: libs, include: [*.jar])
// compile(name:loginModule-release, ext:aar)
compile project(:loginModule)
compile com.android.support:appcompat-v7:22.2.0
}
至此ndk配置完成。
使用Android Stduio开发cocos2d-x首先用Android Studio和cocos的脚本分别创建一个新的项目,然后就是将cocos项目中对应的文件拷贝到相应的目录下面。
最后因为Android Studio在window下直接使用ndk进行编译会因为一些全局变量的缺失导致失败,需要使用在src\main 目录下使用以下脚本进行编译(其中一些全局变量需要自行配制):
1
ndk-build NDK_ROOT=%NDK_ROOT% NDK_MODULE_PATH=%NDK_MODULE_PATH% ANDROID_SDK_ROOT=%ANDROID_SDK_ROOT% NDK_TOOLCHAIN_VERSION=4.9
相关文章
- Android线程间通信之handler
- Android开发第二讲,简介Android Studio
- Android开发之深入理解Android Studio构建文件build.gradle配置
- Android Studio:一个简单的米英尺单位转化app的实现过程
- Android studio DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs
- [Android Studio] Using API of OpenCV DNN
- 转: android studio 消除SDK更新时的“https://dl-ssl.google.com refused”错误
- 转:从零开始开发一款Android App (from 简书)
- Android Studio入门(安装-->开发调试)
- Windows下快速搭建安卓开发环境android-studio
- Android开发入门——Andoird Studio的安装与配置
- Android Studio设置字体和主题【转】
- Android Studio实现记单词App,背完四六级一次过~
- Android Studio实现简单的购物商城界面
- Android Studio 插件开发7、创建模板代码【代码篇】
- Android Studio 插件开发7、创建模板代码【效果篇】
- Android Studio插件开发官网案例地址
- Android Studio 插件开发6、LiveTemplete 的使用
- Android Studio 插件开发3、将数据存储到Service
- 【Android OpenCV】Visual Studio 创建支持 OpenCV 库的 CMake 工程 ② ( VS 中创建 CMake 工程 | CMake 工程中配置 OpenCV 头文件 )
- Android dependency ‘xxx‘ has different version for the compile错误解决步骤
- Android Studio、Git 解决合并冲突
- 解决 Android Studio : minSdkVersion 8 cannot be smaller than version
- Android Studio 3.0 引入新功能,支持Kotlin语言
- 使用Visual Studio 2015开发Android 程序
- 使用Android内部的DownloadProvider下载文件,并获取cache权限
- Android在自定义View(SurfaceView)中实现进度条Progress
- Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 8
- 【Android 性能优化】应用启动优化 ( 方法追踪代码模板 | 示例项目 | SD 卡访问权限 | 示例代码 | 获取 Trace 文件 | Android Studio 查看文件)