A problem occurred configuring project ':feature-ABC'.
> 'kotlin-android' expects one of the Android Gradle plugins to be applied to the project:
* android
* com.android.application
* android-library
* com.android.library
* com.android.test
* com.android.feature
* com.android.dynamic-feature
* com.android.instantapp
Gradle build is failing for an existing project after updating Android Studio gradle to 5.6.4. My plugin version is 3.6.1. It was previously working for Android Studio gradle 5.2.1 and plugin version 3.3.0.
I am relatively new to Android Studio so please ignore my ignorance about something basic that I might be missing. But this error really has me stumped.
EDIT: Posting build.gradle file
apply from: rootProject.file('jacoco-full-report.gradle')
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://microsoft-maps.bintray.com/Maven" }
}
dependencies {
apply from: 'dependencies.gradle'
classpath pluginDep.androidGradle
classpath pluginDep.jacoco
classpath pluginDep.kotlin
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://www.jitpack.io" }
mavenCentral()
}
jacoco {
toolVersion = '0.8.2'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I realise the source of the error now.
com.android.feature and various other plugins have been deprecated in the newer gradle version. So either I had to migrate to new plugins (instant apps) or revert to old gradle (which I am doing because this a collaborative project and I don't have the authority to make structural changes)
Related
I am trying to build my first project to Android and during build I am getting the following error.
I have been looking a lot at previous question but the fixes dont work or are not available in 2019 unity.
IMAGE FULL RES
Gradle.Build file
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
allprojects {
buildscript {
repositories {
google()
jcenter()
}
dependencies {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
classpath 'com.android.tools.build:gradle:3.4.0'
}
}
repositories {
google()
jcenter()
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have updated the version of Android Studio at the 3.4.1.
Immediately the version of Android Gradle Plugin Version and Gradle Version weren't the last so I have changed with 3.4.1 and 5.1.1 (File > Project structure > Project).
Now, I'm trying to create an apk but I have the error "Could not find com.android.tools.build:gradle:3.4.1".
The project is created with cordova and first I have updated cordova at the version 9.0.0.
I also have noticed that I don't have Build > Generated Signed Apk but only Build > Build Bundle.
After a long search, I have tried to:
1. change task wrapper with
wrapper {gradleVersion = '2.14.1'}
add google() in
repositories {
mavenCentral()
jcenter()
google()
}
Verify that the link "distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip" is correct
Verify that there is the function mavenCentral()
In File > Settings > Build, Execution... > Build Tools > Gradle "Use default gradle wrapper" is checked and "Offline work" not checked
build.gradle
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
jcenter()
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
mavenCentral();
jcenter()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-
5.1.1-all.zip
What can I do to fix the problem? And what can I do to have the function Generated Signed Apk?
You have to add the google() maven repo in the buildscript block
buildscript {
repositories {
google() // <-- add this
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
It is not related to your issue but for the other dependencies you should add the same repo also in the allprojects block
allprojects {
repositories {
google()// <-- add this.
jcenter()
}
}
Pay attention to wrapper task with gradle 5.x.
Defining a custom wrapper or init task is deprecated with gradle 4.8 and removed in gradle 5.x. Attempting to replace a built-in task will produce an error similar to the following:
Cannot add task 'wrapper' as a task with that name already exists.
To avoid this issue, instead of this:
task wrapper(type:Wrapper) {
//configuration
}
Do this:
wrapper {
//configuration
}
Android sonarqube worked until I updating android studio. Now it gives an error
FAILURE: Build failed with an exception.
* What went wrong:
com.android.build.gradle.api.ApkVariant.getCompileLibraries()Ljava/util/Collection;
I think this happens because gradle dependency syntax changed from 'compile' to 'implementation' like below in newest android version.
from
dependencies {
compile ........
compile ........
}
to
dependencies {
implementation ........
implementation ........
}
Can anyone please help me to configure sonarqube for new android version
Read the last part of the answer to get the latest updates
Original answer
I've performed some researches:
here you can
find the issue tracked internally by SonarQube
here you
can find the issue opened by a SonarQube developer asking Google
about the API change. As stated by Google engineers this change is intended and an alternative API already exists. SonarQube stated they won't support android plugin 3.0.0 until the final release or at least RC version
Result:
To continue to work you are forced to build your project with the current stable Android Studio and Android plugin v2.X.X
UPDATE - 6th November 2017
SonarQube released the new version 2.6 which is fully compatible with the AGP (Android Gradle Plugin) 3.0.0.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: "org.sonarqube"
More info in the release page HERE
You can use my solution https://github.com/SonarSource/sonar-scanner-gradle/pull/33
buildscript {
repositories {
jcenter()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
After sonarqube 2.6 was released just updating the plugin was enough for me
plugins {
id "org.sonarqube" version "2.6"
}
Updating Benoit answer, the official sonar scanner gradle plugin (v2.6-rc1) already supports the new gradle syntax. So, update your root gradle script to:
buildscript {
repositories {
jcenter()
google()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "com.github.SonarSource:sonar-scanner-gradle:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
Try to use lower version of gradle
I am trying to upgrade the version of Firebase to 11.4.2
I made the following changes in my project:
in project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and my module gradle file:
compile "com.google.firebase:firebase-messaging:11.4.2"
I am getting this error when I build the project:
Error:Could not GET
'https://maven.google.com/com/google/firebase/firebase-messaging/11.4.2/firebase-messaging-11.4.2.pom'.
Received status code 403 from server: Authentication required
To fix the problem:
Download Android Studio 3.0 version
Update the Gradle plugin to classpath 'com.android.tools.build:gradle:3.0.0'
Update gradle wrapper version of the project to: distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip
The build tools must be at least 26.0.2
if you are working with proxy, you must configure your project gradle.
With new Android Studio 3.0 the error list suggests a "link" "Add Google Maven repository and sync project", which will change build.grade (Module:...) repositories to:
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
**google()**
}
that fixed my problem.
Android sonarqube worked until I updating android studio. Now it gives an error
FAILURE: Build failed with an exception.
* What went wrong:
com.android.build.gradle.api.ApkVariant.getCompileLibraries()Ljava/util/Collection;
I think this happens because gradle dependency syntax changed from 'compile' to 'implementation' like below in newest android version.
from
dependencies {
compile ........
compile ........
}
to
dependencies {
implementation ........
implementation ........
}
Can anyone please help me to configure sonarqube for new android version
Read the last part of the answer to get the latest updates
Original answer
I've performed some researches:
here you can
find the issue tracked internally by SonarQube
here you
can find the issue opened by a SonarQube developer asking Google
about the API change. As stated by Google engineers this change is intended and an alternative API already exists. SonarQube stated they won't support android plugin 3.0.0 until the final release or at least RC version
Result:
To continue to work you are forced to build your project with the current stable Android Studio and Android plugin v2.X.X
UPDATE - 6th November 2017
SonarQube released the new version 2.6 which is fully compatible with the AGP (Android Gradle Plugin) 3.0.0.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: "org.sonarqube"
More info in the release page HERE
You can use my solution https://github.com/SonarSource/sonar-scanner-gradle/pull/33
buildscript {
repositories {
jcenter()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
After sonarqube 2.6 was released just updating the plugin was enough for me
plugins {
id "org.sonarqube" version "2.6"
}
Updating Benoit answer, the official sonar scanner gradle plugin (v2.6-rc1) already supports the new gradle syntax. So, update your root gradle script to:
buildscript {
repositories {
jcenter()
google()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "com.github.SonarSource:sonar-scanner-gradle:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
Try to use lower version of gradle