Native Debug Android Studio

11,305

Solution 1

you can try this:

1.in app/build.gradle:

at dependencies label:

releaseCompile project(path: ':youModuleName', configuration: 'release')
debugCompile project(path: ':youModuleName', configuration: 'debug')

2.in youModule/build.gradle:

at android label:

publishNonDefault true

demo:

https://github.com/sunalong/JNIDemo

Solution 2

I encounter the same question, and I got the solution to solve it. But I'm not sure weather the solution is good for you. My solution is: Add the so path in your debug configuration. 1. Open the 'Run/Debug Configurations' dialog; 2. Click 'Debugger' Tab; 3. Add the 'Symbol Directories' with your so path.

My configuration as followenter image description here:

Solution 3

If you've followed all the steps here http://www.akaita.com/post/android-native-library-module-debug/ then you might also be suffering from a bug which is still in Android Studio 2.3.3 which is that the project's IML file gets out of sync with the gradle scripts and gets stuck in the release variant. See the accepted answer on this SO question: Debug a dynamically loaded native library in Android Studio?.

To quote that answer: "t turns out this is due to an old bug in AS. Apparently in the past the "SELECTED_BUILD_VARIANT" in the "native-android-gradle" section in the IML file could become out of step with the actual selected flavour."

To fix this issue, shut down Android Studio and open the IML file for the module that's building the native library (in the case of a single module app, just the app's IML file), and look for "native-android-gradle". For me this had become stuck as the release variant. Manually changing this and restarting got my symbols back.

Share:
11,305
Влад Новосельцев
Author by

Влад Новосельцев

Updated on June 09, 2022

Comments

  • Влад Новосельцев
    Влад Новосельцев almost 2 years

    There was such an error when I run Native debugging through Genymotion.

    Starting LLDB server: run-as org.cocos2dx.cpp_empty_test 
      /data/data/org.cocos2dx.cpp_empty_test/lldb/bin/start_lldb_server.sh 
      /data/data/org.cocos2dx.cpp_empty_test/lldb 
      /data/data/org.cocos2dx.cpp_empty_test/lldb/tmp/platform.port1442313534865 
      "lldb process:gdb-remote packets"
    Now Launching Native Debug Session
    Attention! No symbol directories found - please check your native debug configuration
    Failed to attach native debugger: Invalid URL: adb://[169.254.67.102:5555]:46216
    Invalid URL: adb://[169.254.67.102:5555]:46216
    Process finished with exit code 0
    
    • Víctor Martín
      Víctor Martín over 8 years
      You need to attach the debugger to a device. The android platform of target device should have gdbserver agent for remote debugging.
    • milosmns
      milosmns over 8 years
      Try cleaning and re-packaging the app first, worked for me.
    • Slava
      Slava about 8 years
      Hello, have you found any solution?
  • GoZoner
    GoZoner over 5 years
    First link, to akaita..., is dead.