cocos2dx 3.7 android studio 整合

下载了 cocos2dx 3.7 版本,安装上去了, 在vs下能跑出来hello world, 不动的情况下,导入都android studio 里面, 能运行到手机上,但是闪退,具体错误如下:

07-23 10:05:17.245  13028-13028/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp from loader dalvik.system.PathClassLoader: findLibrary returned null
            at java.lang.Runtime.loadLibrary(Runtime.java:365)
            at java.lang.System.loadLibrary(System.java:535)
            at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:207)
            at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:222)
            at android.app.Activity.performCreate(Activity.java:5165)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1103)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2520)
            at android.app.ActivityThread.access$600(ActivityThread.java:162)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:158)
            at android.app.ActivityThread.main(ActivityThread.java:5751)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
            at dalvik.system.NativeStart.main(Native Method)


```


这个是什么原因啊, 在手机上,则提示的是   很抱歉 “libcocos2dx” 已停止运行!

求各位大神帮帮忙啊!!! 在线等,着急中

自己顶一下,不要下沉啊 ~~!!!! 坛主,帮帮忙啊

应该是没有编译出so库,
我在Eclipse中也出现了这个问题,Eclipse工程不运行编译C++代码的脚本,导致打包的jar中没有so库。

Eclipse下问题解决,需要修改工程设置,勾选Propertes-Builders-CDT Builder

要成功编译还需进行进一步修改,参考 http://www.cocoachina.com/bbs/read.php?tid-296022.html

android studio 请参考http://www.cocoachina.com/bbs/read.php?tid-313980-fpage-3.html

在Mac上Android Studio1.3.1使用以下的app/build.gradle编译,注意applicationId改成自己的

import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: ‘com.android.application’

android {
compileSdkVersion 22
buildToolsVersion “22.0.1”

defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 10
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}

sourceSets.main {
    java.srcDir "src"
    res.srcDir "res"
    jniLibs.srcDir "libs"
    manifest.srcFile "AndroidManifest.xml"
    assets.srcDir "assets"
}

signingConfigs {

   release {
        if (project.hasProperty("RELEASE_STORE_FILE")) {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        if (project.hasProperty("RELEASE_STORE_FILE")) {
            signingConfig signingConfigs.release
        }
    }
}

sourceSets.main.jni.srcDirs = ] // disable automatic ndk-build call, which ignore our Android.mk

}

// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec, dependsOn: ‘copyResources’) {
workingDir file(‘jni’)
commandLine getNdkBuildCmd()
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}

task cleanNative(type: Exec) {
workingDir file(‘jni’)
commandLine getNdkBuildCmd(), ‘clean’
}

task mydir {
doLast {
delete ‘assets’
mkdir(‘assets’)
}
}

task copyResources(dependsOn: ‘mydir’, type: Copy) {
// println ‘call copyResources’
from ‘…/…/Resources’
into ‘assets’
}

clean.dependsOn cleanNative

dependencies {
compile fileTree(dir: ‘libs’, include: ‘*.jar’])
compile project(’:libcocos2dx’)
}

def getNdkDir() {
if (System.env.ANDROID_NDK_ROOT != null)
return System.env.ANDROID_NDK_ROOT

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkdir = properties.getProperty('ndk.dir', null)

if (ndkdir == null)
    throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")
println(ndkdir)
return ndkdir

}

def getNdkBuildCmd() {
def ndkbuild = getNdkDir() + “/ndk-build”
if (Os.isFamily(Os.FAMILY_WINDOWS))
ndkbuild += “.cmd”
println(ndkbuild)
return ndkbuild
}