groovy lang Missing Property Exception [duplicate] - groovy

After updating to Android Studio 4 I got this error:
A problem occurred configuring project ':app'.
groovy.lang.MissingPropertyException: No such property: scope for class: com.android.build.gradle.internal.variant.ApplicationVariantData
My gradle:
classpath 'com.android.tools.build:gradle:4.1.0-alpha10'
gradle-wrapper.properties:
https://services.gradle.org/distributions/gradle-6.5-bin.zip

I had the same issue. Removing all fabric references in build.gradle solved my case.
you can try to remove
apply plugin: 'io.fabric'
and
classpath 'io.fabric.tools:gradle:1.31.2'
lines from your build.gradle file.
Fabrics Crashlytics deprecated. If you are using Fabric Crashlytics you can replace it with Firebase Crashlytics.

I had the same problem, in particular with the the same stack trace as #display name (on the comments).
From there I noticed the reference to Crashlytics. And effectively that was the issue: the old, deprecated, version (from Fabric). Migrating to the new Firebase Crashlytics fixed the issue for me.

Update in OCTOBER 2020 :
Fabric is deprecated, so remove all plugins and dependencies depend on Fabric.io
like :
apply plugin: 'io.fabric'
classpath 'io.fabric.tools:gradle:1.31.2'
maven {
url 'https://maven.fabric.io/public'
}
and after deletaion you must add :
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
in your build.gradle.
https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android

Just remove or comment it out. it works for me.
apply plugin: 'io.fabric'
and
classpath 'io.fabric.tools:gradle:1.+'
from both gradle file.

Please update your Gradle dependency to:
classpath "com.android.tools.build:gradle:4.0.0"
and in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

This started happening for me when upgrading Android Studio from 4.0.2 to 4.1. Unfortunately, I had to update a branch that still includes fabric, the only way I could get it working was to downgrade android studio and make the fixes and be able to make a new build.
Download old versions here:
Windows: https://android-studio.en.uptodown.com/windows/versions
Mac: https://android-studio.en.uptodown.com/mac/versions

I am using Fabrics Crashlytics and i got the same error after updating my Android plugin for Gradle to version 4.1:
classpath 'com.android.tools.build:gradle:4.1.0-rc01'
I need to upgrade gradle plugin to upload native debug symbols to Google play console as stated in this link.
https://developer.android.com/studio/preview/features#native-crash-symbolization
To use Android plugin for gradle version 4.1,
your minimum gradle version needs to be version 6.5.
I used gradle version 6.5.1
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
Upgrading from Fabric Crashlytics to Firebase Crashlytics solved the issue for me, this could be because fabric is not compatible with the newer versions of Android plugin for gradle. For more information on how to upgrade from Fabric crashlytics to Firebase Crashlytics. Check out this link https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android

If you are using com.google.firebase:firebase-crashlytics-gradle dependency in your project, just update to version 2.0.0-beta04 it is helped to me.

Remove all that connected with deprecated library such as fabric crashlytics etc.

Updating dependencies in build.gradle (Project level) solved my issue:
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0'

I updated the de.mannodermaus.gradle.plugins:android-junit5 to the latest version

I run into this problem with an older project which I was maintaining after a longer period. Problem was that project was still using older gradle scripts, plugins and dependencies.
The biggest problem was fabric.io which is not maintained and compatible with the latest gradle version. Stack trace in build output which contained crashlytics references pointed me to the fabric. I recommend checking it. In your case, it might be related to other plugins.
Stack trace example:
at com.crashlytics.tools.gradle.ProjectVariantState$deriveFrom.call(Unknown Source)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.createTaskBuilder(CrashlyticsPlugin.groovy:301)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.this$2$createTaskBuilder(CrashlyticsPlugin.groovy)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.crashlytics.tools.gradle.CrashlyticsPlugin.addPluginTasks(CrashlyticsPlugin.groovy:271)

In Project level build.gradle Just downgrade the version of dependency 'com.android.tools.build:gradle:4.5.0' to your last/lower version was 'com.android.tools.build:gradle:4.0.1' and
In "gradle-wrapper.properties" downgrade the "distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip" to last/lower version like "distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip" .
and sync and run .

On Android Studio simply open build.gradle (Project) and the IDE should suggest an update to crashlytics, accept that and the error will be gone.

Related

Ionic Capacitor app give me lots of errors

I'm on Windows 10 and I've created a Ionic 5.0.7 app with Capacitor 2.0.0.
I use this command to build app:
ionic build
After, I use this command:
npx cap sync
And, to finish, I use this command to open Android Studio:
npx cap open android
The first problem come during building on Android Studio:
org.gradle.api.reflect.ObjectInstantiationException: Could not create
an instance of type
com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create
an instance of type
com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
And...
java.lang.NoClassDefFoundError:
org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
Caused by: java.lang.NoClassDefFoundError:
org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
I've other random errors... It's weird...
Update
Check #Carl Pool 's answer
They fixed it in the new capacitor Version, no need to downgrade anymore
Old Answer
To fix this downgrade Gradle and Gradle plugin in Android Studio.
File -> Project Structure -> Project
If you keep the plugin to 4.0.0 it will require a minimum Gradle version of 6 so put it back to a lower version like 3.6.3
Version 6 of Gradle does not support LazyConfigurationUsageContext as mentionened by #NishaBhat, so use 5.6.4 instead.
This issue currently has a ticket on Github:
https://github.com/ionic-team/capacitor/issues/3003
This issue has been resolved in Capacitor version 2.1.2.
https://github.com/ionic-team/capacitor/issues/3003
Please update the Capacitor dependencies in package.json to version 2.1.2 and then in Android Studio click the button to sync the project with Gradle.
"#capacitor/android": "^2.1.2",
"#capacitor/core": "2.1.2",
Switch to using gradle version 5.6.4. That did the trick for me. LazyConfigurationUsageContext doesn't have support in gradle versions 6.0+
I was getting an error
Cause: org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
I solved by downgraded distributionUrl(gradle/wrapper/gradle-wrapper.properties) to https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
it will give an error if above 6+
Same problem.. had many issues:
Errors and how I solved:
Error 1. Gradle sync failed: Server returned HTTP response code: 403 for URL: http://services.gradle.org/distributions/gradle-5.6.4-all.zip
Solution - Downloaded the zip file and stored in on my local in the \android\gradle\wrapper folder.
Updated the distribution URL to: distributionUrl=./gradle-5.6.4-all.zip
Error 2. java.lang.NoClassDefFoundError & java.lang.NoClassDefFoundError:
Solution - Downloaded Gradle version 5.6.4 and updated the environment variables.
Error 3. Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
Updated as per the image below
i have not downgraded the gradle version 6.1.1 But what i did is that:
I removed these lines from build.gradle file
apply plugin: 'com.novoda.bintray-release' &
classpath 'com.novoda:bintray-release:0.9.1'
The Issue just gone like Boom !!
I think this Bintray Dependencies just conflicting behind the scene.

This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer

This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer.
but my android studio version is 3.2.1 and there is no new update from Google
Try to edit your project build.gradle file and set the android build gradle plugin to classpath 'com.android.tools.build:gradle:3.2.1' within the dependency section.
See also the documentation of the android grade plugin
It's a bit late, But easy and effective.
Click on About Android Studio,
Check the current version,
Open build.gradle of Project and put it in front of the class path. e.g Your studio version is 3.5.2, then your classpath should look like this
classpath 'com.android.tools.build:gradle:3.5.2'
You would need to lower your gradle version and android plugin version, or you can download latest version from beta or canary update channels.
To enable updates from other channels go to Help -> Check for Updates -> Congifure automatic updates and in that dialog select channel you want. After selecting check for update again and it will show you latest version.
This issue is caused due to use of newer version of gradle in the project.
There are two options to resolve this:
Option 1:
Change gradle/wrapper/gradle-wrapper.properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Change project level gradle build.gradle file
classpath("com.android.tools.build:gradle:3.3.2")
Option 2:
Update your Android Studio to newer version. (Highly recommended)
In IntelliJ IDEA this is an open bug: https://youtrack.jetbrains.com/issue/IDEA-252823
As a workaround, you can change the build tools version as other people advise.
My project was failing with this dependency:
com.android.tools.build:gradle:7.0.0-alpha03
Now it's working with this:
com.android.tools.build:gradle:4.0.2
As a side note, you should change that dependency in build.gradle in some projects or in dependencies.kt in newer projects.
That was the most updated version that worked.
After an update the Android Studio does not show the layout's design for some reason. I tried newer versions as well, but it did not work. So I decided to downgrade my IDE.
When I opened my project, I got the same error. The solution was the following:
Open the Project Structure.
Select the Project field.
Use the appropriate Android Plugin Version. You can copy it from a new project's structure.
Change the Gradle version too what you need.
OK.
Find the gradle-wrapper.properties file and open it.
Change the distributionUrl to that gradle version url what you saved in the Project Structure.
Or if you don't mind, then you can update your AS.
Had the same Issue when i decided to install another version of Android Studio, what worked for me was:
Creating a new project with the current version of Android Studio just to go check the classpath version at the project level build.gradle inside the dependencies section, at the time it was this:
classpath 'com.android.tools.build:gradle:3.5.0-rc01'
Copied that line and replaced it on the project i was working on.
in project's build.gradle file comment classpath com.android.tools.build:gradle:. File → Project Structure select Android Gradle Plugin Version to match Android Studio version
You can now update your android studio to 3.4 stable version. Updates for stable version are now available. cheers!!!
i just change gradle version classpath 'com.android.tools.build:gradle:3.5.3' to
classpath 'com.android.tools.build:gradle:3.3.2' and now working.
I encountered with this error and just decrease gradle version and android plugin version to 5.1.1 and 3.4.2.
Close VPN worked for me! It suprised me.
this issue occur for me after downgrade Java JDK, after upgrade JDK my problem resolved.
Open android studio then go to help menu > check for update > Update your Android Studio to newer version.
If u r here because of Jetpack Compose, I had the same problem, and solved it by using the Arctic Fox Canary build of Android studio: you can download it at this link: https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2020.3.1.12/android-studio-2020.3.1.12-mac.zip
This issue arises due to updates, You can resolve this by downgrading the gradle used from
com.android.tools.build:gradle:3.2.1 to a previous gradle like com.android.tools.build:gradle:3.0.0 or anything older than the current one
This usually happens when you're opening someone else's project after unzipping it. And the person has used an updated android Studio.
The way to solve it is
1.Go to Help and about to see your android studio version
2.Go to File>Project Structure> and set your Android Gradle Plugin version to your android studio version
3.Change the Gradle version to the one you usually use.(optional)
Build the project and it should run without any errors
This seems like incompatible gradle plugin vs gradle binary versions. You can find the releases here: Gradle Plugin release and compatiblity
Upgrade your grade plugin and grade binary to compatible versions and the app should start building.

Android build error: Unable to load 'javax.xml.bind.jaxbexception

I am a beginner in Android. I am not able to resolve this error in Android Studio. Whenever I run my application this error occurs. How do I fix it?
Error: Unable to load class 'javax.xml.bind.JAXBException' Possible
causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync
project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build
processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of
Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
This is my solution
Update Gradle build tool version in project-level Gradle.
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
}
And then Android Studio will download and change your gradle-wrapper.properties file.
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
Sync project, everything is OK.
My problem was resolved when I changed the JDK for each of my Android SDKs:
Project Structure -> Platform Settings\SDKs -> Android API xx Platform -> Change "Java SDK" to 1.8
This resolved the problem;
Also change that the Project SDK to 1.8.
If the problem is not resolved, Please try to run IDE under JDK 8.
This might be too late but maybe some one needs to know the reason:
If you updated android studio to v4.2 and this happened, its because it is build in java 11
You have two options:
change JDK path manually in: Project Structure -> SDK Location
you should update your gradle setting use these two versions or above them:
classpath 'com.android.tools.build:gradle:4.0.0'
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
I hope i could save some one's time
Also you can Update your gradle version in project level gradle
classpath 'com.android.tools.build:gradle:4.x.x'
and fixed this issue.
Just upgrade the Gradle version then it will fix the problem
install java 8, and set your JDK path with java 8
File- > Project structure. -> SDK location -> JDK Location
for mac os:
/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home
First check your gradle-wrapper.properties distributionUrl value and update with latest version of gradle.
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
this is the one of the possible solutions, It was worked for me.
In app build file, add the options javaCompileOptions{ ... }
android {
…
defaultConfig {
…
//add this options
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
…
}

how to import googlesource projects in to Android Studio?

I'm new to Gradle and Android Studio and I've been struggling to import any of the projects under https://android.googlesource.com/platform/packages/apps/ in to AS and successfully run it on my dev device. I'm trying to get the Launcher3 running and I get all kinds of different errors. I think I'm missing some major parts on how to configure the studio and Gradle maybe?
What is the proper procedure?
I installed Latest Gradle and AS. Cloned the project from Git. Imported to AS and then I get errors like this or that version of Gradle is required, main activity cant be found, gradle plugin can't be found etc. Tried changing Gradle version in config file. Tried setting my local Gradle download in build settings etc.
Cheers,
Hamed
Update:
I changed the version to 2.1.2 here:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.protobuf:protobuf-gradle-plugin:2.1.2'
}
and currently I get the error:
Error:Could not find com.google.protobuf:protobuf-gradle-plugin:2.1.2.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/protobuf/protobuf-gradle-plugin/2.1.2/protobuf-gradle-plugin-2.1.2.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/protobuf/protobuf-gradle-plugin/2.1.2/protobuf-gradle-plugin-2.1.2.jar
https://repo1.maven.org/maven2/com/google/protobuf/protobuf-gradle-plugin/2.1.2/protobuf-gradle-plugin-2.1.2.pom
https://repo1.maven.org/maven2/com/google/protobuf/protobuf-gradle-plugin/2.1.2/protobuf-gradle-plugin-2.1.2.jar
Required by:
:Launcher3:unspecified
I think you might have confused the build tools version for the protobuf-gradle-plugin version.
The latest protobuf-gradle-plugin version is 0.8.2, as seen here.
try changing it to:
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'

Where is build:gradle:2.1.0-alpha3?

I have Just installed Android Studio Version 2.1 Preview 3 (AI-143.2682553)
When I run my project I get an error, it says:
Could not find com.android.tools.build:gradle:2.1.0-alpha3.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0-alpha3/gradle-2.1.0-alpha3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0-alpha3/gradle-2.1.0-alpha3.jar
When I look in the Jcenter repository it only has 2.1.0-alpha1 https://jcenter.bintray.com/com/android/tools/build/gradle/
So I get why it can't find alpha3, but when I change the build.gradle to 2.1.0-alpha1 it says:
"The projects is using an incompatible version of the android Gradle plugin.
To continue opening the project, the IDE will update the Android Gradle plugin to version 2.1.0-alpha3"
which doesn't seem to exist right ?
Android Plugin for Gradle version 1.5.0 does not support Instant Run. Please update to version 2.1.0-alpha3
I had the similar problem and I fixed it by update it in android studio,just like this!
after update ,I find out the changes of gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha3'
// 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
}
buildToolsVersion '24 rc1'//buildToolsVersion "23.0.2"
I had the similar issue with 2.1.0-alpha3 .. my project cannot be complied ..I used earlier version 2.1.0-alpha1 # http://tools.android.com/download/studio/builds/android-studio-2-1-preview-1
By uninstalling and installing older version.
Hope that may help.

Resources