Reputation: 1104
I have tried to convert my existing ndk Project to Android Studio according to http://ph0b.com/new-android-studio-ndk-support/#usingndkbuild but couldn't resolve all errors.
Now I get following error:
/home/nxp/Documents/Projects/Android_Ucode_demo/app/src/main/jni/ECDSA-jni.c
Error:(44, 30) openssl/ossl_typ.h: No such file or directory
Folder Structure:
app
build
...
libs
...
src
main
assets
...
java
...
jni
include.openssl
...
ossl_type.h
...
Android.mk
libcrypto-static.a
ECDSA-jni.c
jniLibs
armeabi
libECDSA.so
res
...
AndroidManifest
app.iml
build.gradle
lint.xml
build
...
gradle
...
...
build.gradle
...
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle-experimental:0.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
gradle/wrapper/gradle-wrapper.properties
#Thu Sep 17 09:57:00 CEST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
app/build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 22
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "com.mycompany.myapp"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
}
}
android.ndk {
moduleName = "openssl"
}
android.sources{
main.jni {
source {
srcDirs = ['src/main/jni']
}
}
main.jniLibs {
source {
srcDirs = ['src/main/jniLibs']
}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile files('libs/aretepoplib.jar')
}
app/src/main/jni/Android.mk
LOCAL_PATH := $(call my-dir)
$(info LOCAL_PATH := $(LOCAL_PATH))
include $(CLEAR_VARS)
LOCAL_MODULE := openssl
LOCAL_SRC_FILES = libcrypto-static.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include frameworks/base/include
LOCAL_LDLIBS := -llog -lGLESv2
LOCAL_MODULE := ECDSA
LOCAL_SRC_FILES := ECDSA-jni.c
LOCAL_STATIC_LIBRARIES := openssl
include $(BUILD_SHARED_LIBRARY)
Upvotes: 2
Views: 1963
Reputation: 1233
the error is because src/main/jni/include is not inside the include path, add it in with
cppFlags.addAll(['-I' + file('src/main/jni/include')])
examples are in Teapot
mainly because android studio/gradle compiles source file recursively, but it DOES NOT add sub-directories along the way to include path; you will need to handle it manually.
hope you are not using that libcrypto-static.a there: static lib needs to support different ABIs[check your existing application.mk], so one lib will have different binaries for different ABI. it is good to build yourself and use; Teapot build native-app-glue as static lib and use it locally. Same for libECDSA.so; Unless you are building for just one armeabi flavor, Android Studio would complain for not finding other ABI libs. You could check for hello-libs in the same repo.
When it comes down to lib usage, cmake is much simpler. If you so choose cmake, examples are in the same repo, master-cmake branch.
Upvotes: 0
Reputation: 57203
You can enjoy the full power of ndk-build and get support of the experimental grade plugin with native debugging in Android Stidio, see define LOCAL_SRC_FILES in ndk{} DSL
Upvotes: 0
Reputation: 574
Simple way is to migrate the NDK project don't import the project please copy your files exactly with same package names and the add supporting lib's in dependencies do the gradel sync properly , And supporting with min and max.
Upvotes: 3