1

I am using preBuilt library of OpenSSL in project but i am getting error as:

Error:(62, 11) fatal error: 'openssl/asn1.h' file not found
Error:(62, 11) fatal error: 'openssl/asn1.h' file not found

and my Android.mk file is here

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := myLibrary
TARGET_PLATFORM := android-3
LOCAL_SRC_FILES := native-lib.cpp
LOCAL_C_INCLUDES = $(LOCAL_PATH)/src/main/jni/include/openssl
LOCAL_LDLIBS := -llog

include $(BUILD_SHARED_LIBRARY)

getting error in rss.h

headers of rsa.h

# include <openssl/asn1.h>    
# ifndef OPENSSL_NO_BIO
#  include <openssl/bio.h>
# endif
# include <openssl/crypto.h>
# include <openssl/ossl_typ.h>
# ifndef OPENSSL_NO_DEPRECATED
#  include <openssl/bn.h>
# endif

the error here is cannot find OpenSSL

build.graddle

apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
            keyAlias 'manvish'

        }
    }

        compileSdkVersion 25
        buildToolsVersion '26.0.2'
        defaultConfig {
            applicationId "com.example.manvish.bwssb"
            minSdkVersion 19
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            vectorDrawables.useSupportLibrary = true
            multiDexEnabled true
            ndk {
                moduleName "myLibrary"
            }
        }

        buildTypes {
            release {

                shrinkResources false
                minifyEnabled true
                zipAlignEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                        'proguard-rules.pro'
                signingConfig signingConfigs.config

                debuggable true
            }
            debug {
                shrinkResources false
                minifyEnabled true
                zipAlignEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                        'proguard-rules.pro'
                signingConfig signingConfigs.config

                debuggable true
            }
        }
        }



    android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
        }

    }

    android {
        defaultConfig {

                ndk {
                    moduleName "myLibrary"
                    ldLibs "log"
                }

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-vector-drawable:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'xyz.danoz:recyclerviewfastscroller:0.1.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'
    compile files('libs/MorphoSmart_SDK_6.13.2.0-4.1.jar')

    //    compile 'com.google.android.gms:play-services-location:11.0.4'

    //    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/core.jar')
    compile('org.apache.httpcomponents:httpmime:4.3') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile('org.apache.httpcomponents:httpcore:4.4.1') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'

    }
    compile 'com.google.code.gson:gson:2.7'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile files('libs/zip4j_1.3.2.jar')
    compile files('libs/idkit.jar')
    compile files('libs/jna-4.0.0.jar')
    compile 'org.apache.commons:commons-lang3:3.6'
    compile 'com.github.bumptech.glide:glide:3.7.0'
}

I have added .so files in appropriate folders. its been four days I am not able to fix this.

please help me guys.

6
  • 1
    What does $(LOCAL_PATH)/src/main/jni/include/openssl resolve to, and does $(LOCAL_PATH)/src/main/jni/include/openssl/openssl/asn1.h indeed exist? By the way, why are you setting android-3 in your native makefile when your minSdkVersion is 19? Commented Jan 29, 2018 at 9:00
  • @Michael Yes asn1.h file exist i checked in the include folder. Commented Jan 29, 2018 at 9:04
  • I'm sure the file exists somewhere, but does it exist exactly at whatever $(LOCAL_PATH)/src/main/jni/include/openssl/openssl/asn1.h resolves to? (and not e.g. at $(LOCAL_PATH)/src/main/jni/include/openssl/asn1.h)? Also, note that those .h files may actually be symlinks, which may or may not work on Windows. Commented Jan 29, 2018 at 9:12
  • @Michael file exactly exist here $(LOCAL_PATH)/src/main/jni/include/openssl..but totally openssl is not recognising ..i am using Ubuntu Commented Jan 29, 2018 at 9:19
  • 1
    " file exactly exist here $(LOCAL_PATH)/src/main/jni/include/openssl" Then shouldn't you be adding (LOCAL_PATH)/src/main/jni/include to LOCAL_C_INCLUDES, if you expect statements like #include <openssl/asn1.h> to work? Btw, it looks like you've got a typo in your makefile: the = after LOCAL_C_INCLUDES ought to be either := or +=. Commented Jan 29, 2018 at 9:36

1 Answer 1

2

Your Android.mk is in ${proj}/src/main/jni, which becomes your $(LOCAL_PATH). Therefore, you should use

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

This will find ${proj}/src/main/jni/include/openssl/asn1.h as

#include <openssl/asn1.h>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.