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'
Related
I updated my kotlin version to 1.4.20 in project build.gradle file in Android Studio. But, i am not able sync my project. I am getting this error:
A problem occurred configuring root project 'Modules'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find kotlin-scripting-compiler-embeddable-1.4.20.jar (org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.4.20).
Searched in the following locations:
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.20/kotlin-scripting-compiler-embeddable-1.4.20.jar
> Could not find kotlin-stdlib-common-1.4.20.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20).
Searched in the following locations:
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.20/kotlin-stdlib-common-1.4.20.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I also went to Tools->Kotlin->Configure Kotlin Plugin Updates and installed the latest kotlin. Still i am getting this error.
So, What could be the reason?
build.gradle (Modules)
buildscript {
ext {
kotlinVersion = "1.4.20"
gradleVersion = '4.0.0'
}
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:${gradleVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
build.gradle (:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: "$rootDir/gradle/local-aar.gradle"
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.google.gms:google-services:${gmsLibVersion}"
}
}
apply plugin: 'com.google.gms.google-services'
//Rest of the code
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
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.
Folks,
I am trying to use
com.github.ksoichiro:android-observablescrollview:1.5.1
and I had several problems which prompted me to add:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
to my Project's build.gradle file, now when I try to sync my project I get the following message:
Error:Cause: java.io.FileNotFoundException: D:\Backup 2015\Development\AndroidStudioProjects\IKAG\src\main\AndroidManifest.xml (The system cannot find the path specified)
This is my whole build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'com.android.application'
//
repositories {
mavenCentral()
}
android {
compileSdkVersion 20
buildToolsVersion '21.1.2'
}
dependencies {
// Other dependencies are omitted
compile 'com.github.ksoichiro:android-observablescrollview:1.5.1'
}
allprojects {
repositories {
jcenter()
}
}