i have experimental(v:0.4.0) android module that use gradle file with model block like this :
apply plugin: 'com.android.mode.application'
model {
android {
compileSdkVersion = 21
buildToolsVersion = "21.1.2"
defaultConfig.with {
applicationId = "com.example.native_libs"
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 21
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
/*
* native build settings
*/
android.ndk {
moduleName = "native_libs"
stl = "stlport_static"
cppFlags.add("-fexceptions")
cppFlags.add("-fno-rtti")
cppFlags.add("-std=gnu++11")
ldLibs.add("z")
/*
* Other ndk flags configurable here are
* cppFlags.add("-fno-rtti")
* cppFlags.add("-fno-exceptions")
* ldLibs.addAll(["android", "log"])
* stl = "system"
*/
}
android.buildTypes {
debug {
ndk.with {
debuggable = true
}
}
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}}
and now like another module, we can't import java wrapper classes in this module that use experimental plugin.
i change apply plugin: 'com.android.mode.application' to apply plugin: 'com.android.mode.library' but nothing changed and still can't recognize java wrapper classes in native_libs module :(
how to config gradle for native module library?
why experimental plugin don't let to import module, like normal way for other modules?
[edit]
i read this doc
http://tools.android.com/tech-docs/new-build-system/gradle-experimental
but there is not way to import modules that combine native(c/c++) and java.
i find a project in github that done what i want to do :)
https://github.com/frogermcs/FlatBuffs
Related
I am trying to develop a module from my C project with Android Studio. I am having the problem of
Plugin with id 'com.android.model.native' not found.
What did I do wrong?
Thank you!
Below is the App level build.gradle
apply plugin: "com.android.model.native"
model {
android {
compileSdkVersion 27
defaultConfig {
applicationId = 'com.example.androidthings.nativepio'
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
ndk {
//platformVersion = "21"
moduleName "libusb"
ldLibs.addAll(["log"])
CFlags.add("-Wall")
CFlags.add("-I" + file("src/main/jni/android").absolutePath)
CFlags.add("-O3")
}
sources {
main {
jni {
exportedHeaders {
srcDir "src/main/jni/libusb"
}
dependencies {
project ":dependency_module"
}
}
}
}
}
}
Here is the project level build gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This plugin was part of an experimental and old version of the current build system.
You should rewrite your gradle file to work with the current build system. Either let Android Studio generate the necessary additions by linking to your CMake file, or copy from a known-good sample like the HelloJNI sample:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
ndkVersion '21.2.6472646'
defaultConfig {
applicationId 'com.example.hellojni'
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
flavorDimensions 'cpuArch'
productFlavors {
arm8 {
dimension 'cpuArch'
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
}
x86_64 {
dimension 'cpuArch'
ndk {
abiFilters 'x86_64', 'x86'
}
}
universal {
dimension 'cpuArch'
// include all default ABIs. with NDK-r16, it is:
// armeabi-v7a, arm64-v8a, x86, x86_64
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
I have 4 gradle build files: when I build in android studio I am constantly having the error:
No signature of method:
org.gradle.model.ModelMap.getDefaultProguardFile() is applicable for
argument types: (java.lang.String) values: [proguard-android.txt]
file 1
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.9.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
file 2
apply plugin: 'com.android.model.native'
model {
android {
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
defaultConfig {
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 25
versionCode = 1
versionName = '1.0'
}
ndk {
moduleName = 'fpextractor'
platformVersion = 17
toolchain = "clang"
stl = 'gnustl_static' //std::mutex not in gnustl_static
cppFlags.add('-std=c++11')
abiFilters.addAll(['armeabi', 'armeabi-v7a', 'x86'])
//abiFilters.addAll(['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64']) //this is default
//abiFilters.addAll(['armeabi'])
ldLibs.addAll(['android', 'log', 'atomic', 'z'])
}
}
}
// This is just copy out the header file and built lib into distribution
// directory for clint application to use; it is a small overhead of this sample:
// both lib and app are put inside one project space [save maintenance time]
task(distributeLib, type : Copy) {
// trigger build library
dependsOn assemble
into '../distribution/fpextractor/'
from('src/main/jni/fp_extractor.h') {
into 'include/'
}
from('build/outputs/native/release/lib') {
into 'lib/'
}
}
file 3
apply plugin: 'com.android.model.native'
model {
android {
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
defaultConfig {
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 25
versionCode = 1
versionName = '1.0'
}
ndk {
moduleName = 'nativeaudio'
platformVersion = 17
toolchain = "clang"
stl = 'gnustl_static' //std::mutex not in gnustl_static
cppFlags.add('-std=c++11')
abiFilters.addAll(['armeabi', 'armeabi-v7a', 'x86'])
//abiFilters.addAll(['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64']) //this is default
//abiFilters.addAll(['armeabi-v7a'])
ldLibs.addAll(['android', 'log', 'OpenSLES', 'atomic'])
}
}
}
// This is just copy out the header file and built lib into distribution
// directory for clint application to use; it is a small overhead of this sample:
// both lib and app are put inside one project space [save maintenance time]
task(distributeLib, type : Copy) {
// trigger build library
dependsOn assemble
into '../distribution/nativeaudio/'
from('src/main/jni/buf_manager.h') {
into 'include/'
}
from('src/main/jni/android_debug.h') {
into 'include/'
}
from('src/main/jni/debug_utils.h') {
into 'include/'
}
from('src/main/jni/audio_common.h') {
into 'include/'
}
from('src/main/jni/audio_recorder.h') {
into 'include/'
}
from('build/outputs/native/release/lib') {
into 'lib/'
}
}
file 4
apply plugin: 'com.android.model.application'
// Root of 3rd party lib(s): location could be anywhere on the host system
def lib_distribution_root = '../distribution'
model {
repositories {
libs(PrebuiltLibraries) {
// Configure one pre-built lib: shared
nativeaudio {
// Inform Android Studio where header file dir for this lib
headers.srcDir "${lib_distribution_root}/nativeaudio/include"
// Inform Android Studio where lib is -- each ABI should have a lib file
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("${lib_distribution_root}/nativeaudio/lib/${targetPlatform.getName()}/libnativeaudio.so")
}
}
fpextractor {
// Inform Android Studio where header file dir for this lib
headers.srcDir "${lib_distribution_root}/fpextractor/include"
// Inform Android Studio where lib is -- each ABI should have a lib file
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("${lib_distribution_root}/fpextractor/lib/${targetPlatform.getName()}/libfpextractor.so")
}
}
// Configure another pre-built lib: shared;[change to static after Studio supports]
// static lib generation. USING static lib is supported NOW, for that case,
// simple change:
// SharedLibaryBinary --> StaticLibraryBinary
// sharedLibraryFile --> staticLibraryFile
// *.so --> *.a
//gperf {
// headers.srcDir "${lib_distribution_root}/gperf/include"
// binaries.withType(SharedLibraryBinary) {
// sharedLibraryFile = file("${lib_distribution_root}/gperf/lib/${targetPlatform.getName()}/libgperf.so")
// }
//}
}
}
android {
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
defaultConfig {
applicationId='com.gfk.mediawatchapp'
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 25
versionCode = 22
versionName = '255.0.4'
// Enabling multidex support.
//multiDexEnabled true
}
ndk {
platformVersion = 17
moduleName = 'mwlib'
toolchain = "clang"
stl = 'gnustl_static'
cppFlags.add('-std=c++11')
ldLibs.addAll(['android', 'log', 'OpenSLES', 'atomic'])
//build a default combined apk including all ABIs.
//abiFilters.addAll(['armeabi-v7a'])
abiFilters.addAll(['armeabi', 'armeabi-v7a', 'x86']) //this is default
}
sources {
main {
jni {
dependencies {
library 'nativeaudio' linkage 'shared'
library 'fpextractor' linkage 'shared'
// if gperf were *.a, change shared --> static
//library 'gperf' linkage 'shared'
}
}
jniLibs {
// for shared lib, lib need to be pushed to the target too
// Once libs are copied into app/src/main/jniLibs directory,
// Android Studio will pack them into APK's lib/ directory
// Here we like to avoid another duplication by pointing
// to the files that containing our libs' distribution location
// so the same file is used by compiler at host, also packed
// into APk to be used at Target (phone/tablet)
source {
srcDir "${lib_distribution_root}/nativeaudio/lib"
srcDir "${lib_distribution_root}/fpextractor/lib"
//srcDir "${lib_distribution_root}/gperf/lib"
}
}
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles.add(file('proguard-android.txt'))
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
}
dependencies {
println rootProject.getName()
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:25.3.1'
compile 'commons-net:commons-net:3.5'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.amazonaws:aws-android-sdk-core:2.4.2'
compile 'com.amazonaws:aws-android-sdk-s3:2.4.2'
compile 'com.amazonaws:aws-android-sdk-ddb:2.4.2'
compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.4.2'
}
// Unnecessary dependency management:
// Make sure the libs are available when begin compiling application project
// This could be ignored because in real scenario, the pre-built libs are
// already given to us before creating application.
tasks.whenTaskAdded { task ->
if (task.name.contains('compile')) {
task.dependsOn ':nativeaudio:distributeLib'
task.dependsOn ':fpextractor:distributeLib'
}
}
Please: Can anyone help me to understand why I have always the following error:
No signature of method:
org.gradle.model.ModelMap.getDefaultProguardFile() is applicable for
argument types: (java.lang.String) values: [proguard-android.txt]
Gradle experimental does not include getDefaultProguardFile() since it does not have any version of ProGuard config by default.
You can use move the lines from your proguard-android.txt to proguard-rules.pro and then change this line:
proguardFiles.add(file('proguard-android.txt'))
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
into this:
proguardFiles.add(file('proguard-rules.pro'))
For me adding a manifest with
jar {
manifest {
attributes 'Main-Class': com.package.to.main.Class
}
}
helped.
See here: Creating runnable JAR with Gradle
my module build.gradle
apply plugin: 'com.android.application'
model {
android {
// 编译SDK的版本
compileSdkVersion = 23
// build tools的版本
buildToolsVersion = "23.0.3"
//useLibrary = 'org.apache.http.legacy'
defaultConfig.with {
// 应用的包名
applicationId = "com.example.administrator.design"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
tasks.withType(JavaCompile) {
//指定编译JDK版本
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
android.ndk {
moduleName = "test"
ldLibs += "log"
abiFilters += "armeabi"
abiFilters += "armeabi-v7a"
abiFilters += "x86"
}
android.productFlavors {
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
}
android.buildTypes {
release {
// 是否进行混淆
minifyEnabled = false
// 混淆文件的位置
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles += file('proguard-android.txt')
proguardFiles += file('proguard-rules.pro')
//resValue "string", "facebook_app_id", '"597651723652854"'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//testCompile 'junit:junit:4.12'
compile 'org.xutils:xutils:3.3.20'
...
}
my project build.gradle
buildscript {
repositories {
jcenter()
//mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle wrapper
#Mon Mar 28 16:31:26 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
if I use "com.android.tools.build:gradle:0.20" in project build.gradle, and make some according changes it just works fine, But I want the new feature instant, run I have googled almost one afternoon.
Looks like you used an experimental gradle plugin version. The stable version 2.0.0 and the experimental version have some differences regarding the notation in the build.gradle file.
For example the android block needs to be outside the model block. And some attribute specifications are slightly different. Have a look at the Experimental Gradle Plugin User Guide, especially the red highlighted parts in the build.gradle example file.
Also I'm not really sure, but the non-experimental version still doesn't have full NDK support. Although it looks like the experimental version 0.6 does support the NDK as well as Instant Run, so you might use the version 0.6 instead of 2.0.
I am attempting to add a native library to my existing application. My goal is to have the C++ library compile in it's own module in Android Studio using the plugin without manual steps (if possible). I have tried a multitude of suggestions and gotten hints that there is an issue with the build system for copying libraries between modules into the build. I have not been able to solve the problem.
Here are the relevant parts (and some) of my setup:
Android Studio:
Gradle Version: 2.10
Project File Structure:
myproject
+libmodule
| +src/main
| | +java
| | | `-MyWrapper.java
| | `jni
| | `-MyJNI.cpp
| `-build.gradle
+appmodule
| +src/main
| | `java
| | `-MyClass.java
| `-build.gradle
+gradle/wrapper
| `-gradle-wrapper.properties
+-build.gradle
`-settings.gradle
myproject/settings.gradle:
include ':appmodule', ':libmodule'
myproject/build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha9'
}
}
allprojects {
repositories {
mavenCentral()
}
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
myproject/libmodule/build.gradle:
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file("proguard-rules.txt"))
proguardFiles.add(file("proguard-android.txt"))
}
}
android.ndk {
moduleName = "MyLibrary"
stl = "gnustl_shared"
cppFlags.add("-nostdinc++")
cppFlags.add("-I\$(NDK)/sources/cxx-stl/stlport/stlport")
cppFlags.add("-fexceptions")
cppFlags.add("-frtti")
cppFlags.add("-fpermissive")
ldFlags.add("-nodefaultlibs")
ldFlags.add("-Lsrc/main/jniLibs/armeabi-v7a")
ldLibs.add("c")
ldLibs.add("m")
ldLibs.add("dl")
ldLibs.add("log")
ldLibs.add("gcc")
}
android.productFlavors {
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
create("all")
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
}
myproject/appmodule/build.gradle:
apply plugin: 'com.android.model.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile project(':libmodule')
// Support Libraries
// Maven Provided Libraries
compile fileTree(dir: 'libs', include: ['*.jar'])
}
model {
android {
compileSdkVersion = 23
buildToolsVersion = '23.0.2'
defaultConfig.with {
applicationId = "com.me.myandroidapp"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
}
}
android.dexOptions {
jumboMode = true
}
android.packagingOptions {
//Some specific removals for an included lib from maven
}
android.lintOptions {
checkReleaseBuilds = false
abortOnError = false
}
android.buildTypes {
debug {
debuggable = true
minifyEnabled = false
buildConfigFields.with {
create() {
type = "boolean"
name = "SCREENSHOTS"
value = "true"
}
}
buildConfigFields.with {
create() {
type = "boolean"
name = "DEBUGGABLE"
value = "true"
}
}
proguardFiles.add(file("proguard-rules.txt"))
proguardFiles.add(file("proguard-android.txt"))
}
release {
debuggable = false
minifyEnabled = true
buildConfigFields.with {
create() {
type = "boolean"
name = "SCREENSHOTS"
value = "false"
}
}
buildConfigFields.with {
create() {
type = "boolean"
name = "DEBUGGABLE"
value = "false"
}
}
proguardFiles.add(file("proguard-rules.txt"))
proguardFiles.add(file("proguard-android.txt"))
}
}
android.productFlavors {
create("prod") {
applicationId = "com.me.myandroidapp"
}
create("dev") {
applicationId = "com.me.myandroidapp"
}
create("beta") {
applicationId = "com.me.myandroidapp"
}
create("staging") {
applicationId = "com.me.myandroidapp"
}
}
}
if (project.hasProperty("MyProject.properties") && new File(project.property("MyProject.properties")).exists()) {
// Get properties in the property file
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("MyProject.properties"))))
model {
android {
signingConfigs {
//several configs here
}
}
android.buildTypes {
release {
signingConfig = signingConfigs.release
}
}
}
}
MyWrapper.java:
package com.me.androidwrapper;
public class MyWrapper {
private native String doItNatively(String stringinput);
public String doIt(String stringinput) {
return doItNatively(stringinput);
}
static {
System.loadLibrary("MyLibrary");
}
}
myjni.cpp:
extern "C" {
JNIEXPORT jstring JNICALL
Java_com_me_androidwrapper_MyWrapper_doItNatively(JNIEnv *env, jobject instance, jstring stringinput_) {
// C++ happens here
}
}
MyClass.java:
// Weird behavior for IDE adding dependency module happens here:
import com.me.androidwrapper.MyWrapper;
public class MyClass {
public String makeItHappen(String inputstring) {
MyWrapper mywrapper = new myWrapper();
return mywrapper.doIt(inputstring);
}
}
There are no android.mk files in the JNI.
From a cleaned project gradle executes successfully. When I run Make Module on appmodule I get the error:
Error:(5, 37) error: package com.me.androidwrapper does not exist
...and the import statement from MyClass.java is highlighted.
As noted above in the code for MyClass.java, Android Studio offers a quick fix for including a dependency for Module "libmodule" and if I select it the IDE drops the errors. The IDE then resolves the project links correctly if I command-click through the package, class or methods.
I have followed a number of solutions on StackOverflow and in groups for the plugin. There is mention of the new experimental plug-in and build system not copying native libraries between modules in several of them and I have tried methods that set up a aar/jar module as an intermediary. I have also tried methods for manually copying the aar file into the module lib and referencing it as a file or as an aar. Most of these methods have not worked, the best result I have had is to have a successful build, but the application crashes not finding libMyLibrary.so
I have successfully tested the project by including the JNI directly into the appmodule Module using gradle 2.8 with android experimental plugin 0.4.0. This is not a very good solution as the module is complex and the C++ code is maintained separately. The 0.4.0 plugin fails as a multi-module, the library's .so does not package.
There are gaps in my knowledge of the new experimental plugin and I know it has bugs, it is incomplete and some features are still in discussion. Any assistance in tracking down my mistake, or providing a comprehensive work around to the plugin's lack of features would be greatly appreciated.
If you want to add some native libraries to your existing application in Android studio, you can do it in three standard ways. Please read this link https://stackoverflow.com/a/35369267/5475941. In this post I explained how to import your JAR files in Android studio and I explained all possible ways step by step with screenshots. I hope it helps.
I am trying to use the ffmpeg libraries with Android NDK in the experimental plugin.
I am attempting to compile this example:
https://github.com/roman10/android-ffmpeg-tutorial/blob/master/android-ffmpeg-tutorial01/jni/tutorial01.c
My problem is that the header files are not being found by the compiler:
Error:(13, 32) libavcodec/avcodec.h: No such file or directory
I added flags to build.grade:
cppFlags += "-ilibavcodec -ilibavutil -ilibavformat -ilibswscale"
ldFlags += "-llibavcodec -llibavutil -llibavformat -llibswscale"
Which seems to keep lint happy, but not the compiler. (Not sure if I have done this right?)
I Have added the header files to the /jni folder:
And build.grade looks like this:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "roman10.tutorial.android_ffmpeg_tutorial01"
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 23
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
android.ndk {
moduleName = "tutorial01"
ldLibs += ["android","log","jnigraphics","z"]
cppFlags += "-ilibavcodec -ilibavutil -ilibavformat -ilibswscale"
ldFlags += "-llibavcodec -llibavutil -llibavformat -llibswscale"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.0.1'
}
Thanks.