2017-10-11 344 views
0

我想将外部库导入到我的应用程序中,库是FFmpeg。这是一个链接到moduleGradle找不到插件

我将库添加到我的libs文件夹(下载之后),然后从文件>新建>导入模块>选择FFmpeg。现在,在我的应用程序建立gradle这个我添加行

compile project(':FFmpeg')

现在,当我尝试和同步的项目中,我得到这个错误:

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

当我打开该文件,这是受影响的行

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

基本上我的最终目标是得到上面的lib放到我的项目作为外部库,所以我可以修改源代码到L内修复了一些bug ibrary。

非常感谢任何帮助,我一直试图解决这个问题很长一段时间,但除了使用依赖关系之外,我对Gradle并不太满意。

更新1

现在申请问题但是固定它不能找到喜欢的版本名称和rootProject.ext.compileSdkVersion变量作为整数

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

回答

1

您需要的插件添加到您的类路径根的build.gradle。你可以在Gradle Android Maven plugin找到它。事情是这样的:

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() 
    } 
} 

更新:

你应该看看ffmpeg的机器人gradle.properties并将其添加到您的根项目,那就是:

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 

需要的VERSION_NAME在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 

... 

忠告:

这是更好,如果你运行的ffmpeg-Android的Java作为独立的项目,然后对其进行配置,因此它可以被安装到本地Maven。在我的回答中阅读详细信息https://stackoverflow.com/a/46330142/4758255

+0

喜这个工作解决问题申请,但现在它无法找到该版本名称或任何其他属性,请看看最新的问题 – RedGooseMental

+0

为什么它会更好,因为Maven的运行?谢谢 – RedGooseMental

+0

因为您会将ffmpeg库的问题隔离到您的代码中。想象一下,如果图书馆因错误或改进而更新。你如何反映你的代码更新?如果直接将该库作为模块包含在内,则需要重新集成该库,这很乏味且容易出错。 –

0

您必须在buildscript区块中添加插件。您可以在顶级build.gradle文件或添加module/build.gradle

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

关于变量没有找到您要检查build.gradle在图书馆上github

你在你的项目中定义这些变量。当然要用你的价值观。

ext { 
    compileSdkVersion = 22 
    buildToolsVersion = '22.0.1' 
    targetSdkVersion = 22 
    minSdkVersion = 16 
    versionCode = 28 
    versionName = "0.3.2" 
} 
+0

请看更新的问题 – RedGooseMental

+0

@RedGooseMental检查答案 –