I am using gradle and I am trying to add kotlin to my project. But when I am trying to add 'kotlin-android-extensions' plugin for gradle it fails to find it.
To use the plugin, you have to add it in your root level file:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
ext.kotlin_version = '1.1.2-4'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Try to add the following to your gradle.build file
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
after that you have to make some changes in your dependencies classpath like this.
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.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
}
}
and in dependencies compile make sure to add jre7 such that.
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
After doing all that rebuild the gradle and you are all done. This worked for me because i was facing the same problem you are now, and after this it's all done. Hope it works for you tooo....
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:+"
try this
Related
While integrating WorkManager in my Application, I updated my app settings as follows:
androidMinSdkVersion = 15
androidTargetSdkVersion = 28
androidCompileSdkVersion = 28
androidBuildToolsVersion = "28.0.0"
Due to version upgrade to 28 I had to update gradle too.
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Project.gradle
buildscript {
repositories {
// Gradle 4.1 and higher include support for Google's Maven repo using
// the google() method. And you need to include this repo to download
// Android Gradle plugin 3.0.0 or higher.
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenCentral()
jcenter()
gradlePluginPortal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Due to all these changes(mainly WorkManger), I had to (was forced to) upgrade the butterknife library version to 9.0.0 at least.
So I updated it as follows in my app.gradle file
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
}
}
But whenever I try to clean-build I keep getting following error in logcat.
ERROR: Could not find com.android.tools.build:gradle:3.1.4.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.jar
Required by:
project :_btn_payment > com.jakewharton:butterknife-gradle-plugin:10.1.0
Any help is appreciated.
You should move your classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0' to Project.gradle
butterknife 10.x only supports AndroidX-enabled builds.
You will changed to version 9.0.0
From gradle gradle plugin 3.0 apt has deprecated,delete classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
library build.gradle
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0'
}
}
I am getting “Plugin with id 'com.android.application' not found”. I have updated the gradle distribution version in gradle wrapper properties but to no avail. Do I need to write the build gradle dependencies somewhere?
You have to add in your top level file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
I have the error below in build.gradle at this line:
apply plugin: 'com.google.gms.google-services'
Error:(56, 0) Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.
It happened after I installed Firebase.
How to solve this?
The error message, Error: Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension, indicates that this plugin needs to be applied to a module which uses the com.android.application plugin.
So, the simple solution is to only include the google-services plugin in your application module and not your library module:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
I had the same problem and solved it updating gradle and google-services versions.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Add the following to the #project level gradle file:
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:3.0.0'
Add the following to the #app level gradle file:
// Dependency for Google Sign-In
compile 'com.google.android.gms:play-services-auth:9.4.0'
Apply plugin
apply plugin: 'com.google.gms.google-services'
I am writing a plugin for NativeScript but I have troubles with the gradle file,
how can I add the mavencentral() to the repositories tag in buildScript and an "apply instruction" ? example:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:2.1.2"
classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
I tried to add this to the include.gradle for my plugin but when I add this plugin in my app project, the build process fails.
i'm trying to add Google analytics inside of the my app using this tutorial:
https://developers.google.com/analytics/devguides/collection/android/v4/
But i stucked on the problem, where to exactly put the line:
apply plugin: 'com.google.gms.google-services'
So my build.gradle top level file is looking like this:
// 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.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
apply plugin: 'com.google.gms.google-services'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
But this is wrong. Where to put apply plugin exactly please?
Thanks for any help.
In andriod studio you have this kind of structure:
root
build.gradle
app
build.gradle
In the top-level build.gradle you have:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
In your app/build.gradle
apply plugin: 'com.google.gms.google-services'
//...
dependencies{
//.....
compile 'com.google.android.gms:play-services-analytics:7.3.0'
}
Should be inside of the object
allprojects
on top of the app build.grade
like this:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'