新建项目
运行cocos 3.16 根目录(F:\cocos2d-x-3.16)的setup.py
cocos new fbtest5 -l cpp -p com.fbtest5.cocos -d G:\MyCocosCpp316打开android studio3.2.1
-
打开项目
file -> open
后 报错
Could not find method implementation() for arguments [directory '../java/libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
这个时候还需要导入依赖项
File->New->Import Moudle, 将Cocos2dx项目中的libcocos2dx库工程导入,我的库工程目录如下图。(注意:libcocos2dx库工程不在proj.android-studio目录下,而在原始Cocos2dx\cocos2d\cocos\platform\android\java下)
G:\MyCocosCpp316\fbtest6\cocos2d\cocos\platform\android\java
-- =================================================
G:\MyCocosCpp316\fbtest6\proj.android-studio\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
-- =================================================
G:\MyCocosCpp316\fbtest6\proj.android-studio\gradle\wrapper\gradle-wrapper.properties
#Tue Mar 14 17:40:59 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
G:\MyCocosCpp316\fbtest6\proj.android-studio\local.properties
ndk.dir=E\:\\cocos\\android-ndk-r14b
sdk.dir=F\:\\android_sdk\\sdk
运行预编译
或者