Dokka plugin not found in Android studio 3 - android

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

Related

Gradle cant find plugin

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

android method not found in gradle

I have and android project named global flow and I after opening with android studio 2.2.3 on a debian linux I watch this error:
Error:(22, 0) Could not find method android() for arguments [build_5ijv6qsqmd3lnd1fe6nzaworu$_run_closure3#1c8251f] on root project 'GlobalFlow' of type org.gradle.api.Project.
Open File
When I try the solution in this forum could not find method android I don't know where to find all the android modules.
I update the build.gradle file in home/alex/GlobalFlow but I am not sure if is this one or the other one in home/alex/GlobalFlow/app. But I understand that the root project's build gradle is in the first path named.
My build.gradel is:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.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
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
compile files('app/libs/junit-4-12-JavaDoc.jar')
}
apply plugin: 'maven'
Where are all android modules?
Thanks.
This is the project/build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
It contains build script instructions. And optionally closures applied to all modules.
The following line allows you to apply com.android.application plugin:
classpath 'com.android.tools.build:gradle:2.2.3'
Also read the NOTE carefully.
This is the project/module/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
// We're in GlobalFlow/app now, adjust the relative path!
compile files('libs/junit-4-12-JavaDoc.jar')
}
apply plugin: 'maven'
When you apply plugin: 'com.android.application' you can use the android { ... } closure to setup Android app build process. Notice they're both in the module build.gradle.
If you were building an Adnroid library you'd apply plugin: 'com.android.library' which also provides you with android { ... } closure.
This is the recommended and default structure as of January 2017.
You can't use the android block in the top level file.
You have to add it in the home/alex/GlobalFlow/app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
dependencies {
//.....
}

Gradle DSL method not found: 'android()' opening project in android studio 1.4

I used Eclipse for programming android application,now i want to use android studio. now I'm new in android studio and i do not khow so much thing about gradle. i open and project which is created with android studio .but when i run it ,this give me following errors:
Error:(17, 0) Gradle DSL method not found: 'android()' Possible
causes:The project 'sheidaamin-AndSt' may be using a version
of Gradle that does not contain the method. Gradle settingsThe build file
may be missing a Gradle plugin. Apply
Gradle plugin
my build.gradle is :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
} } allprojects {
repositories {
jcenter()
} }
android {
compileSdkVersion 23
buildToolsVersion '23.0.2' } dependencies { }
do anyone khow what's wrong with my project setting?
You are using the wrong build.gradle file.
In Android Studio you have a structure like this:
root
|--app
|----build.gradle
|--build.gradle //top level
|--settings.gradle
In the top level file you can't use the android block.
In the top-level file, just use somenthing like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
allprojects {
repositories {
jcenter()
}
}
You have to move the android block inside the app/build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion XX
buildToolsVersion "XX"
defaultConfig {
//
}
}
dependencies {
//
}

Android Studio Gradle DSL method not found: 'android()' -- Error(17,0)

I am attempting to run my project in Android Studio but the error appears below:
I have followed many sources just to get this to run and have wound up here, but do not know what else to do.
How can I configure this project to run?
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
settings.gradle:
include ':app'
local.properties:
sdk.dir=C\:\\Users\\KJA\\AppData\\Local\\Android\\sdk
gradle.propertes:
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
I went ahead and downloaded the project from the link you provided: http://javapapers.com/android/android-chat-bubble/
Since this is an old tutorial, you simply need to upgrade the software, gradle, the android build tools and plugin.
Make sure you have the latest Gradle and Android Studio:
https://www.gradle.org/
http://tools.android.com/tech-docs/new-build-system/version-compatibility
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
}
Then run gradle:
gradle installDebug
In your top level build.gradle you seem to have the code
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
You can't have this code at the top level build.gradle because the android build plugin isn't loaded just yet. You can define the compile version and build tools version in the app level build.gradle.
For some unknown reason, Android Studio incorrectly adds the android()
method in the top-level build.gradle file.
Just delete the method and it works for me.
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
}
I have tried to manage this issue via below steps :
Delete android { ... } block in top level root gradle file
Look into
compileSdkVersion 22
buildToolsVersion "22.0.0"
lines of code in app/gradle file here only one of the version persent in below dropdown should be present else it would give provide option to downloaad the same.
I got this same error when I was trying to import an Eclipse NDK project into Android Studio. It turns out, for NDK support in Android Studio, you need to use a new gradle and android plugin (and gradle version 2.5+ for that matter). This plugin, requires changes in the module's build.gradle file. Specifically the "android{...}" object should be inside "model{...}" object like this:
apply plugin: 'com.android.model.application'
model {
android {
....
}
}
So if you have updated your gradle configuration to use the new gradle plugin, and the new android plugin, but didn't change the module's build.gradle syntax, you could get "Gradle DSL method not found: 'android()'" error.
I prepared a patch file here that has some further explanations in the comments:
https://gist.github.com/shumoapp/91d815de6e01f5921d1f
These are the changes I had to do after importing the native-audio ndk project into Android Studio.
Correcting gradle settings is quite difficult. If you don't know much about Gradle it requires you to learn alot. Instead you can do the following:
1) Start a new project in a new folder. Choose the same settings with your project with gradle problem but keep it simple: Choose an empty main activity.
2) Delete all the files in ...\NewProjectName\app\src\main folder
3) Copy all the files in ...\ProjectWithGradleProblem\app\src\main folder to ...\NewProjectName\app\src\main folder.
4) If you are using the Test project (\ProjectWithGradleProblem\app\src\AndroidTest) you can do the same for that too.
this method works fine if your Gradle installation is healthy. If you just installed Android studio and did not modify it, the Gradle installation should be fine.
Actually i tried many combinations nothing worked
but when i modified my application gradle file with following
buildTypes {
release {
minifyEnabled false
}
}
By removing the Line
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
it worked Normally :)) cheers
Another solution if you have installed android-studio-bundle-143.2915827-windows
and gradle2.14
You can verify in
C:\Program Files\Android\Android Studio\gradle if you have gradle-2.14.
Then you must go to
C:\Users\\AndroidStudioProjects\android_app\
And in this build.gradle you put this code:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Then, go to C:\Users\Raul\AndroidStudioProjects\android_app\Desnutricion_infantil\app
And in this build.gradle you put:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
}
You must check your sdk version and the buildTools.
compileSdkVersion 23
buildToolsVersion '24.0.0'
Save all changes and restart AndroidStudio and all should be fine !
Just delete these lines from the root build.gradle
android {
compileSdkVersion 19
buildToolsVersion '19.1' }
Now trying and compile again. It should work.
Change to root build.gradle file
to
// 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:1.5.0'
// 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
}
What worked for me was to import the project with "File -> New -> Project from Version Control" then choose your online source (GitHub for example). This way all the .gradle files were created in the import.
I also meet that problems,and just delete bottom code:
DELETE THESE LINES:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
}
it worked。
This error has occurred when i was importing a project from Github. This happens as the project was of older version. Just try to delete these methods below from your root gradle.
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
then try again.
I hope it works.

Maven Dependencies with Android Studio / Gradle

I am using the Gradle build system bundled with Android Studio. So far, I am able to build multi-project setups using dependencies that are stored in my project structure. I would now like to use a maven dependency, to no avail. I have written a very simple build.gradle file that always fails :
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile 'com.google.android:support-v4:r7'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
with the following message :
* What went wrong:
A problem occurred configuring project ':absabs'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':absabs:compile'.
> Could not find com.google.android:support-v4:r7.
Required by:
absabs:absabs:unspecified
....
Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionNotFoundException: Could not find com.google.android:support-v4:r7.
It happens with any artifact I have tried so far. Any idea of what's wrong ?
Thanks
The "repositories" block in the buildscript section only applies to the build environment. You also need to specify which repository to use when resolving dependencies for building your project, so you need to put something like the following in your build.gradle file:
repositories {
mavenCentral()
}
Your complete file would look something like this:
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:support-v4:r7'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Note the two instances of "repositories". You can read more about what this actually means in the gradle docs.
Seems that current Android Studio version doesn't pick up new dependencies immediately. Try to restart IDE.
Edit:
This is not needed for Android Studio >= 0.1.4v. It has build in action Sync Project with Gradle file. You can find it under Tools > Android > Sync Project with Gradle file or just button in Toolbar.
http://tools.android.com/tech-docs/new-build-system/user-guide
Note: This only affects the code running the build, not the project. The project itself needs to declare its own repositories and dependencies. This will be covered later.
So you have to declare
repositories {
mavenCentral()
}
in your project scope once more.
I did it this way:
In Top build.gradle (Project: YourProject) I added:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.h2database:h2:1.4.187'
//NOTE: you can get the latest version in http://mvnrepository.com/artifact/com.h2database/h2
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
NOTE: I added this along with the predefined jcenter() repositories.
And then for my app/build.gradle file I added whichever library or dependency I needed on:
dependencies {
....//Add dependency here
}
I recently had to use a maven dependency in gradle, maybe this little example will be of use for someone.
In maven:
<dependency>
<groupId>com.turo</groupId>
<artifactId>pushy</artifactId>
<version>0.12.1</version>
</dependency>
In grade that turns into:
repositories {
mavenCentral()
}
dependencies {
compile 'com.turo:pushy:0.12.1'
}
maven
Maven continues using XML as the format to write build specification. However, structure is diametrically different. Maven has its own problems. Dependencies management does not handle well conflicts between different versions of the same library (something Ivy is much better at). XML as the build configuration format is strictly structured and highly standardized. Customization of targets (goals) is hard. Since Maven is focused mostly on dependency management, complex, customized build scripts are actually harder to write in Maven than in gradel.

Categories

Resources