Advertisement Jump to content
Sign in to follow this  

Unable to see header file in Android Studio

This topic is 774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I have a problem on adding the header (.h) files to Android Studio. First of all, I tried to import my codes, and it has header-only files (interfaces and stuff). The thing is, when I import them, it doesn't show up in the Android Studio. Even when I create a new .h file, it doesn't show up as well. I've called include_directories for the folder that contains the .h files but still it doesn't show up. I've posted a screenshot that includes for the related cmake code. The filename is CharacterFriendship.h, as displayed in the explorer window in screenshot.


Can someone help me?





Share this post

Link to post
Share on other sites

Does this problem persist if you close Android Studio and open it again?


Android Studio creates various project files, which I believe are plain XML - you could open them in a text editor and see if it's lacking a line for your file, and if so, just add one.


You might also have some sort of exclusion rules operating which mean certain filenames would never show up - check the project settings.

Share this post

Link to post
Share on other sites

Yes it's still happening even when I close and open it.


The only xml exist is AndroidManifest.xml which has nothing to do with the files. I have no idea what others (and where) cause there's just too many files there (literally hundreds of them). Most xmls are values.xml with localization values, and the others are more on the UI stuff related to the IDE settings. Besides, it's kinda counter-productive if I manually change them outside the Android Studio if I found them. The only file that seem to care about the cpp files are, as far as I can tell, is the Cmake (Which therefore I show the code in the screenshot). The gradle only tells which cmake list the Android Studio wants to sync with. Please correct me if I'm wrong or if I miss something.


I start off from empty Android project with C++ support and C++ 11 (with rtti and exception), and add a few lines in the gradle such as preprocessor commands and ABIs. Then I modify the CMake like the screenshot to sync the files so it is shown in the IDE, and so it can be compiled. I don't think I add anything related to exclusion rules, unless the default Android Studio project has that exclusion rules, which I don't know about. Is it?


Forgot to mention, my android studio version is 2.2.2. I'm planning on trying to downgrade the version if this isn't solved soon, but I'm not sure if that's the issue.


gradle file:

apply plugin: ''

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.www.www"
        minSdkVersion 24
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
        externalNativeBuild {
            cmake {
                abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
                arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static"
                cppFlags "-std=c++11 -frtti -fexceptions -DANDROID -D__STDC_LIMIT_MACROS -DVK_NO_PROTOTYPES -DVK_USE_PLATFORM_ANDROID_KHR"
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('', {
        exclude group: '', module: 'support-annotations'
    compile ''
    testCompile 'junit:junit:4.12'


<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android=""

    <uses-sdk android:minSdkVersion="24" />

    <uses-feature android:name="" android:required="true" />
    <uses-feature android:name="" android:required="true" />
    <uses-feature android:name="" android:required="true" />
    <uses-feature android:name="android.hardware.gamepad" android:required="true" />
    <uses-feature android:name="android.hardware.screen.landscape" android:required="true" />
    <uses-feature android:name="" android:required="true" />

    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    <uses-feature android:name="" android:required="false" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

            <meta-data android:name="" android:value="www" />
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
Edited by away2903

Share this post

Link to post
Share on other sites
This is normal, :unsure:  Android Studio only use the files that you define in CMakeLists.txt file. Then it only includes the .cpp and the .h with the same name of the .cpp file, for example utils.cpp and utils.h. But if you include utils2.h inside of utils.cpp and this file is in the same folder that utils.cpp, it is not show in the Android Studios environment.
Do somebody tries the Visual Studio 2015 for compile Android C++ code? I think that the Android Studio developers not use the program to professional  Android C++ Applications :( , and i'm looking for alternatives to it. 

Share this post

Link to post
Share on other sites

Oh god, so that's normal... well so far I use the ones that display the project files... that should show the .h files even though it does not guarantee being linked to the project (Might be just me being bad at cmake so far). Android Studio is also annoyingly show the folders based on the directories I included in Cmake (by the cpp/subdirectories you are linking... how confusing is that?) at same tree level. For example, I have Core folder inside an Engine folder... then both are displayed as siblings in the project explorer. It's so confusing.


I'd love to have the Android to work with VS, but I need it to support Android Nougat and it's just not there yet. It works though as I test the Android 19 to my galaxy s3 (debug mode), but professionally I don't know cause I haven't published anything with it yet. You may wanna try it cause it really works as easy as normal VS studio for desktop.

Share this post

Link to post
Share on other sites
Yes, I used the VS 2013 with Android Works (from Nvidia) for a professional project, and this works well. But I had problems with gradle and google-services and other libraries. I will test VS2015 and VS2017.
For us is better because we have the game running in the VS for the desktop version.
Android Studio is not ready for C ++ professional projects, with many files and your own paths, templates, inline files, etc.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!