Plugin with id 'com.wonbin.myplugin' not found - gradle

I wrote a demo for learning gradle for android . i used the JAR
1) project root dir build.gradle
buildscript {
repositories {
jcenter()
flatDir {dirs 'build_libs'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.wonbin.myplugin:MyPlugin:1.0'
}
}
apply plugin: 'com.wonbin.myplugin'
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have leanrd that the plugin id is the properties filename in the plugin project. But still when I run ./gradlew assemble , it happens:
Build file '/home/wonbin/MyApp/build.gradle' line: 13
What went wrong: A problem occurred evaluating root project 'MyApp'.
Plugin with id 'com.wonbin.myplugin' not found.
what should i do ?

Probably your build_dir doesn't correspond to the correct file structure. You can reference your jar in the classpath directly instead, like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath file('/path/to/your/plugin.jar')
}
}
apply plugin: 'com.wonbin.myplugin'

Related

gradle cannot find flatDirs file

The external jar exists. However, gradle cannot get it even though the path is right. How should it be resolved?
project build.gradle
buildscript{
repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs "../libs"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
module build.gradle
repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs "../libs"
}
}
folder structure
X:/Dev/IntelliJProjects/libs //all flatDir libs go here
X:/Dev/IntelliJProjects/my-project/my-project--core
when i run gradlew clean publishtomavenlocal
Could not resolve all files for configuration ':my-project--core:compileClasspath'.
Could not find external-project:myDependency:1.0.0.
Searched in the following locations:
- file:/X:/Dev/IntelliJProjects/libs/myDependency-1.0.0.jar
but when I go to the folder, the file is there.

Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2) flutter project

I have an error with lint-gradle-api.jar, I looked at other similar questions on the forums but I still have the problem.
Does anyone have an idea ?
Error running Gradle:
Exit code 1 from: C:\Users\bgbra\Documents\Flutter_apps\flutter_app\android\gradlew.bat app:properties:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\bgbra\Documents\Flutter_apps\flutter_app\android\app\build.gradle' line: 25
What went wrong:
A problem occurred evaluating project ':app'.
Could not resolve all artifacts for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
build.gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my build.gradle file. I don't know, will it help you.
buildscript {
ext.kotlin_version = '1.3.10'
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
// global properties used in sub modules
ext {
versionCodeProp = 81100
versionNameProp = "0.8.11-dev"
versionBuild = System.getenv("BUILD_NUMBER") as Integer ?: 0
buildNumberProp = "${versionBuild}"
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
Probably you shoul add maven to allprojects branch.

Add dependency and plugin in seperate file using "apply from" in gradle

My build.gradle inside app directory contains:
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
mavenCentral();
jcenter()
}
}
def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
apply from: 'build-extras.gradle'
}
And this is my build-extras.gradle file:
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:1.2.2'
}
}
apply plugin: 'com.github.triplet.play'
Am I correct to assume that build-extras.gradle should be "merged" inside original file? No matter how I move it around I get Error:Plugin with id 'com.github.triplet.play' not found.
If i move classpath 'com.github.triplet.gradle:play-publisher:1.2.2' up to the main file and leave just apply plugin: 'com.github.triplet.play' inside build-extras.gradle then it seems to work fine. So am I wrongly defining dependencies?
A build.gradle file can only ever have one buildscript block. You are correct with the paragraph explanation. Add the plugin dependency to your main build file's dependencies block within the buildscript, then conditionally apply the plugin using whatever logic you'd like.

adding errorprone to gradle build file

I am trying to add errorprone to my gradle build file as follows:
relevant parts of build.gradle
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
}
}
plugins {
id 'java'
id 'application'
id 'idea'
id 'com.github.johnrengelman.shadow' version '1.2.4'
id "net.ltgt.errorprone" version "0.0.9"
}
dependencies {
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'
}
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.19'
}
error from classpath line when I run gradle clean
Could not find method classpath() for arguments [net.ltgt.gradle:gradle-errorprone-plugin:0.0.9] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Any thoughts on what is causing this issue and what might help resolve this? Thanks
I got errorprone to work with gradle by making the following changes:
replaced this from dependencies:
classpath net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'
with
errorprone "com.google.errorprone:error_prone_core:latest.release"
and removed the configurations line:
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.19'
}
This worked.

Gradle error: Could not find org.apache.httpcomponents:httpclient-android:4.3.5.1

I'm trying do use the Apache httpclient for Android in my Gradle project and I don't understand why I get this error when running ./gradle build:
Could not find org.apache.httpcomponents:httpclient-android:4.3.5.1.
My top-level build.gradle contains:
// 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.12.+'
}
}
My project build.gradle starts with:
apply plugin: 'com.android.application'
dependencies {
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':workspace:google_play_services:libproject:google-play-services_lib')
}
What's wrong with that?
In The Central Repository Browser of Maven the package I need is listed:
http://search.maven.org/#browse|-305040853
You have to add in your project build.gradle
repositories {
mavenCentral()
}
If you would like to put it in the top level file you can add this in the top level build.gradle:
allprojects {
repositories {
mavenCentral()
}
}

Resources