Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - No option to Link C++ to Gradle

I have been trying to access some CPP Libraries from android and have been following the instructions here:

https://developer.android.com/studio/projects/add-native-code.html#link-gradle

The issue is that there doesn't seem to be an option to 'Link C++ Project with Gradle' when I right click on the app module. Has anyone else had this issue? Did you solve it?

like image 683
H Mirza Avatar asked Nov 09 '16 11:11

H Mirza


2 Answers

Check in your build.gradle file for your App's module. Mine looked like this from the default Android Project:

externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

I removed the cmake section and resynced the project and then the "Link C++ Project with Gradle" was finally available as an option.

like image 62
cjserio Avatar answered Sep 19 '22 17:09

cjserio


Look for a file called "build.gradle"( Module: app ) in "Gradle Scripts" folder.

 defaultConfig {
 ...
 }
 buildTypes {
 ...
 }

Add:

externalNativeBuild {

}

Save and Sync Now

Then right click on "app" and you will see "Link C++ Project with Gradle"

like image 36
Mike Zriel Avatar answered Sep 20 '22 17:09

Mike Zriel