Gradle cant find plugin - android

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.

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

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"
}

Related

Dokka plugin not found in Android studio 3

I'm trying to use the dokka plugin in my Kotlin project, but I'm getting the following message:
Error:(7, 0) Plugin with id 'org.jetbrains.dokka' not found.
I'm using Android Studio version 3.0.
Thanks in advance.
Using Dokka with Kotlin in Android Studio for the first time
#1. Settings
##1.1 Settings in build.gradle(Project)
buildscript {
ext {
version_dokka = "0.10.0"
version_gradle = "3.5.2"
version_kotlin = "1.3.41"
...
}
dependencies {
classpath "com.android.tools.build:gradle:$version_gradle"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${version_dokka}"
...
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
##1.2 Settings in build.gradle(Module:app)
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
...
// Dokka used for auto-generation documentation
dokka {
outputFormat = 'html'
//outputDirectory = "$buildDir/dokka"
configuration {
// Do not output deprecated members
skipDeprecated = true
// Emit warnings about not documented members.
reportUndocumented = true
// Do not create index pages for empty packages
skipEmptyPackages = true
}
}
}
// workaround: create DocsByDokka
task DocsByDokka (type: org.jetbrains.dokka.gradle.DokkaTask) {
outputFormat = "html"
outputDirectory = "$buildDir/dokka"
}
Don't forget to sync
#2. Building the docs
##2.1 Your code should contain comments.
Take a look at the following link, in order to get more details:
https://kotlinlang.org/docs/reference/kotlin-doc.html
##2.2 Go to the Gradle-Window in Android Studio
I have to click on "Gradle" at the right top corner in Android Studio 3
After clicking on "Gradle" a window opens.
--> MyProject --> app --> Tasks --> DocsByDokka
Gradle-Window in Android Studio
##2.3 Generate Docs
Double Click on DocsByDokka in the Gradle-Window.
#3. Find the docs
##3.1 Go to your Project-Folder
Select the Project and not the Android view. I find this by default at the left corner of Android Studio.
--> MyProject --> app --> build --> dokka --> app
There you are going to find index.html. Right-click and select "Open in Browser".
So, when I ran into the issue, example I was reading, did not specify exactly where to put dokka dependencies. Once I figured those out, the project compiled and build:
build.gradle (Project level file):
buildscript {
ext.kotlin_version = '1.2.51'
ext.kotlin_version = '1.2.30'
ext.dokka_version = '0.9.17'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
build.gradle (Module level file):
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
dokka {
outputFormat = 'javadoc'
outputDirectory = "$buildDir/javadoc"
}
}
When running Dokka on Android code, you need to use the versions of the plugin specific to Android, instead of the stand-alone Gradle forms:
apply plugin: 'org.jetbrains.dokka-android'
and
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${versions.dokka}"
as pointed out in the Android section of the Dokka GitHub page.
when running android apply plugin: 'org.jetbrains.dokka-android'
result is Plugin with id 'org.jetbrains.dokka-android' not found.
so change to org.jetbrains.dokka is working
You can generate Dokka documentatiton without Dokka plugin... Use EasyDokkaPlugin
Add the following at the end of build.gradle of each sub-module that you wish to generate documentation:
apply from: 'https://raw.github.com/Vorlonsoft/EasyDokkaPlugin/master/dokka.gradle'
You can now generate documentation by Dokka documentation engine in Javadoc format:
$ gradle dokkaJavadocsJar

Gradle: how to include an existing, complete project as a subproject?

I git clone a complete gradle project "CompleteGradleProjA" from github and include it into my local project as a submodule. By "complete gradle project" I mean that I can go into directory "CompleteGradleProjA" and issue command
cd CompleteGradleProjA && gradle build
to build it.
My directory structure looks like this,
MyProj
|---CompleteGradleProjA
| |---build.gradle
|
|---build.gradle
My question is: How can I call "CompleteGradleProjA/build.gradle" without changing anything of it from my root "build.gradle"?
The following root "build.gradle" config does not help.
apply plugin: 'java'
dependencies {
compile project(':CompleteGradleProjA')
}
I got error message
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':compileJava'.
> Could not determine the dependencies of task ':compileJava'.
"CompleteGradleProjA" is an android porject and "CompleteGradleProjA/build.gradle" looks like this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
CompleteGradleProjA/build.gradle
apply plugin: 'com.android.library'
// if your project isn't library then use this:
// apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0' // if needed
}
settings.gradle
include ':CompleteGradleProjA'
Use apply plugin: 'com.android.library' or apply plugin: 'com.android.application' instead of apply plugin: 'java'
To include a custom project as part of your gradle build, first ensure the submodule is already included within the project folder and accessible via your settings.gradle. i.e.
include ':app', ':your_project_name'
You then register the project as a dependency of another by using in your project's build.gradle:
dependencies {
compile project(path: ':your_project_name')
}
In newer versions compile has been deprecated. See here on what to use.

Plugin with id 'android-sdk-manager' not found

i want to add
https://github.com/gabrielemariotti/cardslib
but android studio give me this error :
Error:(9, 0) Cause: cannot get property 'compileSdkVersion' on extra properties extension as it does not exist
The best way to use this library with Andriod Studio is to add this dependency in your build.gradle
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.9.1'
}
If you want to clone locally you should check the top level build.gradle (in the root) inside the github repo.
It sets some variables, and you have to add these parts in your top level build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
}
}
ext {
compileSdkVersion = 19
buildToolsVersion = "20.0.0"
}
I had same problem with ChangeLog Library.(https://github.com/gabrielemariotti/changeloglib)
I thought there is no need for applying android-sdk-manager plugin for a library, android library plugin is enough. So i removed android-sdk-manager plugin from build.gradle left only android library plugin like below.
Change this:
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.library'
to this:
apply plugin: 'com.android.library'
It worked without any problem in my case. I hope it will help someone else too.

How do you include romainguy's ViewServer in Android Studio with Gradle?

I'm trying to use RomainGuy's ViewServer (https://github.com/romainguy/ViewServer) with my Android Studio project using Gradle, and I can't get it to work.
My understanding is to add a folder in project root ('libraries'), drop the ViewServer directory into it (not the full ViewServer directory but the actual library viewserver folder within ViewServer, and reference it in settings.gradle
include ':VendorSearch'
include ':libraries:ViewServer'
and also in my build.gradle file
compile project(":libraries:ViewServer")
When I do this I get a message that says
Could not find any version that matches com.android.tools.build.gradle:0.5.+
I tried then manually updating build.gradle in ViewServer to use the latest build tools (0.7.+ at the time of posting), but I get the same error with the new gradle version.
Any help and general clarification of how to include non-jar third party libraries would be appreciated!
You probably need to add the repository. Change the gradle.build from:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
}
to
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
}

Adding Maven dependencies to Gradle in Android Studio

I am trying to make use of some maven dependencies in a new Android project, but I am new to using Android-Studio and Gradle. I looked at a few other solutions such as this:
How to import Maven dependency in Android Studio/IntelliJ?
and thought it looked simple enough. So I modified the build.gradle file to this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android:android:4.1.1.4'
compile 'com.factual:factual-java-driver:1.7.7-android'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
but when I compiled the project I got the error:
Gradle: A problem occurred configuring root project 'LookAroundYouProject'.
> Failed to notify project evaluation listener.
> Main Manifest missing from /home/tstewart/AndroidStudioProjects/LookAroundYouProject/src/main/AndroidManifest.xml
I am not really sure what this is telling me. Currently it is just a simple hello world example and it worked before modifying the gradle file.
EDIT:
I moved the compile statements from the Top-level build file to the one within the application itself and for some reason this seemed to work and I no longer appear to be getting errors. Sadly I have no idea why this is the case.

Categories

Resources