Do anybody know how to debug Android NDK (cocos2dx 3.8)

I spend about 3 days to find a way for debugging Android NDK on Mac OS X (MacBook Pro El Captain), but no results (((…

Do anybody has successful installs for debug using breakpoints?

Thanks in advance!!!

Ok, I found solution:

  1. Install Parallels Desktop 11;
  2. Install Windows 7 SP1 (!!! Windows 7 SP1) or higher;
  3. Install Microsoft Visual Studio 2013, 2015 Community edition higher;
  4. Install http://visualgdb.com/ - Visual Studio Plugin for debugging.
  5. Install on your phone app from AppStore, name: “adbd Insecure”, in app enable checkbox Enable insecure adbd.
  6. Run Visual Studio (!!! As administrator) and create new project type: VisualGDB -> Android -> with third party library -> select Cocos2d-x.
  7. Install all necessary software for VisualGDB. //I tried to map existing Android NDK, but I had errors on Application build.

!!! Don’t forget to enable USB debugging on your phone (tablet).

I hope I will save to someone a day or two. I spent almost 5.

Enjoy…

We using fabric.io, if something crashing on Android device we can catch it and analyze. Not sure how it can be hanled from ide directly.

BTW there was topic regarding Gradle 3.0 and cocos2d-x - there is possibility to make it work in Android studio, so then you can debug your code in same way like in Visual studio…

energyy, thanks for reply, but why don’t you use Flurry or Google analytics?

I think they not supporting NDK crashes, so they can catch only Java errors, with NDK you can get in which C++ class/line app crashed

Got it, thanks, it’s good to know :slight_smile:

One more question, how did you integrate fabric.io in both iOS and Android?

For IOS follow their integration instructions, like running their app, dragging frameworks to project, pasting initialization code, adding /run script in build settings.

For Android little more tricky, we using Android-studio so change your project build.gradle, you can copy/paste just change your package name inside, :

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.+'
        // The Fabric Gradle plugin uses an open ended version to
        // react quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'

apply plugin: 'io.fabric'

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.funlab.movethestone"


        minSdkVersion 15
        targetSdkVersion 22
        versionCode 22
        versionName "1.31"


    }


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


    splits {
        abi {
            enable true
            reset()
            include 'armeabi'
            universalApk false
        }
    }


    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
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])


    compile project(':libcocos2dx')
     

    // Crashlytics Kit
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true
    }
    // NDK Kit
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.1@aar') {
        transitive = true
    }

}

After change your android manifest file, add your fabric key:

<meta-data android:name="io.fabric.ApiKey" android:value="YOUR_KEY" />

Change AppActivity.java - add in oncreate function:

  @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
}

Don’t forget to add import for Fabric classes. Should work after :slight_smile:

Cool :slight_smile: Will try and let you know

Thanks a lot :slight_smile:

Main tricky part in build.gradle is

splits {
        abi {
            enable true
            reset()
            include 'armeabi'
            universalApk false
        }
    }

It making sure that fabric adding only armeabi libs to project, if you need to support different CPU type add it there, but it should match in Application.mk configured platform