Debugging C++ using AS2.2 and externalNativeBuild

427 views
Skip to first unread message

Iliya Koreshev

unread,
Aug 23, 2016, 6:59:40 PM8/23/16
to android-ndk
Hey all,
Converted my entire project to AS2.2 with externalNativeBuild finally and got everything to build; however, having problems getting the debugger to see breakpoints in C++. Java works as expected but C++never breaks. I've tried Hybrid, Native and Auto debugger all the same behavior.

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.app.myapp"
        minSdkVersion 14
        targetSdkVersion 23

        // Enabling multidex support.
        multiDexEnabled true

        dexOptions {
            javaMaxHeapSize "4g"
        }

        externalNativeBuild {
            ndkBuild {
                targets "MyApp"
                arguments "NDK_MODULE_PATH:=../../../libs","NDK_TOOLCHAIN_VERSION:=clang","-j8"
                //cppFlags "-O2", "-std=c++14","-frtti","-fpermissive","-fexceptions","-ferror-limit=1","-Qunused-arguments","-Wno-extern-c-compat","-Wno-deprecated-register"
                abiFilters "armeabi-v7a"
            }
        }
    }

    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    productFlavors {
        create("arm7")
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:+'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.4@aar') {
        transitive = true
    }
}


 

Kenneth Geisshirt

unread,
Aug 24, 2016, 10:38:45 AM8/24/16
to android-ndk

Try to add a buildType 'debug'  and remember - g as option to your compiler.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/7ec2af61-ac94-4a1a-9bcb-87151bf4c714%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Iliya Koreshev

unread,
Aug 24, 2016, 6:06:58 PM8/24/16
to android-ndk, ken...@geisshirt.dk
Added debug under BuildType still getting the same issue. Why would I need to add the -g option to the compiler?

...
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            minifyEnabled false
        }
    }
...

NoAngel

unread,
Sep 5, 2016, 11:16:17 AM9/5/16
to android-ndk, ken...@geisshirt.dk
because adding -g u make compiler to generate debugging information, such as symbols for Your breakpoints, which can be used by debugger.

Jomo Fisher

unread,
Sep 6, 2016, 1:07:31 PM9/6/16
to android-ndk
Hi Iliya,
I don't see any problem with your build.gradle. When you debug are you debugging the release configuration or the debug configuration?
If it's debug then could you create a small repro project and open a bug for us? https://code.google.com/p/android/issues/list
Kind regards,
Jomo
Message has been deleted

Muhammad Arafat

unread,
Sep 9, 2016, 7:45:28 PM9/9/16
to android-ndk
I have recently got debugging C++ to work with both the experimental gradle 0.7.3 and the sable 2.2-rc1 both on AS 2.2 RC. The key thing I did is to attach the C++ lib to the main module in the application (usually called 'app'). Because as you creates a new run configuration (app-native for example), you need to select a module from a drop down list, and this list only has the 'app' module.

Hope this was helpfull..

Iliya Koreshev

unread,
Sep 20, 2016, 1:45:31 PM9/20/16
to android-ndk
Okay figured it out... feeling a bit stupid right now...

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            minifyEnabled false
            jniDebuggable true  //!!! this line was missing !!!
        }
    }

Raymond Chiu

unread,
Sep 21, 2016, 6:43:37 PM9/21/16
to android-ndk
Hi Iliya,

That looks like a bug.  Android Studio shouldn't be checking that flag to determine if the build is debuggable, and Gradle use the buildType.debug.debuggable flag instead of jniDebuggable.  Would you have a sample project that can reproduce this problem?

Raymond
Reply all
Reply to author
Forward
0 new messages