2

I am trying to import an external library into my application, the library is FFmpeg. Here is a link to the module.

I add the library to my libs folder (after downloading it), then from File > New > Import module > select FFmpeg. Now within my apps build gradle I add the line

compile project(':FFmpeg')

Now when I try and sync the project I get this error:

Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.

When I open the file, this is the affected line

apply plugin: 'com.github.dcendents.android-maven'

Basically my end goal is to get the above lib into my project as an external library so I can modify the source code to fix some bugs within the library.

Any help is much appreciated, I have been trying to fix this problem for a really long time but I am not too good with Gradle besides just using dependencies.

Update 1

Apply problems are now fixed however it cant find variables like version name and rootProject.ext.compileSdkVersion as Integer

Error:(6, 0) Could not get unknown property 'VERSION_NAME' for project ':FFmpegAndroid' of type org.gradle.api.Project.

2 Answers2

3

You need to add the plugin to your classpath root build.gradle. You can found it in the Gradle Android Maven plugin. Something like this:

buildscript {
  repositories {
    jcenter()
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    // This is the classpath for the plugin
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
  }
}

allprojects {
  repositories {
    jcenter()
  }
}

UPDATED:

You should look at the ffmpeg android gradle.properties and add it to your root project, here it is:

VERSION_NAME=0.3.2
VERSION_CODE=28
GROUP=com.writingminds

POM_DESCRIPTION=Java implementation of ffmpeg for Android
POM_URL=https://github.com/writingminds/ffmpeg-android-java
POM_SCM_URL=https://github.com/writingminds/ffmpeg-android-java.git
POM_SCM_CONNECTION=scm:https://github.com/writingminds/ffmpeg-android-java.git
POM_SCM_DEV_CONNECTION=scm:https://github.com/writingminds/ffmpeg-android-java.git
POM_LICENCE_NAME=GNU GPLv3
POM_LICENCE_URL=https://github.com/writingminds/ffmpeg-android-java/blob/master/LICENSE.GPLv3
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=hiteshsondhi88
POM_DEVELOPER_NAME=Hitesh Sondhi

The VERSION_NAME is needed in the Ffmpeg Android build.gradle:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"

// This is the library version used when deploying the artifact
version = VERSION_NAME

...

ADVICE:

It's better if you run the ffmpeg-android-java as independent project and then configure it so it can be installed to local maven. Read the details at my answer https://stackoverflow.com/a/46330142/4758255

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
0

You have to add the plugin in your buildscript block. You can add in the top-level build.gradle file or in your module/build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        //..current plugins
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    }
}

About the variables not found you have to check the build.gradle in the library on github

You have to define in your project these variables. Of course use your values.

ext {
    compileSdkVersion = 22
    buildToolsVersion = '22.0.1'
    targetSdkVersion = 22
    minSdkVersion = 16
    versionCode = 28
    versionName = "0.3.2"
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841