IntelliJIdea: Unable to load class 'org.gradle.api.artifacts.result.ComponentArtifactsResult' - java

When configuring project with Gradle I recieve:
Unable to load class 'org.gradle.api.artifacts.result.ComponentArtifactsResult'.
This is an unexpected error. Please file a bug containing the idea.log file.
I have same error when using either local gradle distribution option: C:/Users/user/Downloads/gradle-1.12-bin/gradle-1.12
or gradle 'wrapper' task configuration file with url: distributionUrl=https://services.gradle.org/distributions/gradle-1.12-bin.zip.
Also tried to delete .gradle folder and configure project again and use default gradle wrapper.
So, there're many examples to solve it using Android Studio but unfortunatelly none for IDEA. Is there any way to resolve this problem?
EDIT: So, it was only part of trables with Gradle. The true problem was in encache library version. It was so in my gradle.build:
module: "ehcache", version: "2.10.4"
The decision was in changing Gradle version to 4.7 and removing encache version like this:
module: "ehcache"
Now it works fine.

Related

com.gradle.enterprise requirement when compiling Java 17 with Gradle 7.3.3

I am currently trying to migrate an Project to Java 17
For this I upgraded the Gradle version to 7.3.3. Since this I get the following error when trying to build:
Plugin [id: 'com.gradle.enterprise', version: '3.7', artifact: 'com.gradle:gradle-enterprise-gradle-plugin:3.7'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.gradle:gradle-enterprise-gradle-plugin:3.7')
gradle-enterprise-gradle-plugin doesn’t seem to be referenced anywhere in the Gradle file.
Where does this come from? Why do Gradle needs this now?
Due to cooperate reasons I am currently not able to retrieve new libraries through Nexus (or Maven Central). How can I bypass this requirement or load the jar locally without the need to retrieve it via an online repository?
I tried Gradle 7.2, it seems to throw the same error.

The project uses Gradle 2.10 which is incompatible with Android Studio 2020.3

While learning android studio from udacity they asked me to download a project; I did so but while I was importing it to android studio I got an error message:
The project uses Gradle 2.10 which is incompatible with Android Studio 2020.3.
Why did I get this error?
If you did not figure this out yet, I am just starting the same project too. I changed the classpath like above. I then found a website to use the latest version of gradle and the plugin. It says "You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or by editing the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file." I did the first one.
Then, I got errors for both build.gradle files in the project and app version. I get this error: Could not find com.android.tools.build:gradle:7.0.3
If you get this error, click the link "Add google Maven repository and sync project". Then you have to click "Do refactor".
Now you come across another error in one of the build.grade files. This stackoverflow link will tell you: Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]
Finally, replace testCompile with testImplementation and then you should get BUILD SUCCESSFUL.
The project's Gradle version you're trying to clone is outdated. Change it based on your android studio version.
on your build.gradle(Project) change the version and sync
classpath "com.android.tools.build:gradle:4.1.2"
Got the solution :)
In gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
In build.gradle project level:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
In build.gradle module level:
Replace all "compile" with "Implementation" and do other suggested version updated and you are done here :)
Hope this works for you, if yes just press that up button :)
If not getting any solution, the best you can do is copy the "app" folder of your project(using file explorer) and paste it in a newly created project(should be of same name as of your project), in that way you'll get already synced gradle and newly created version of your app.
Because, every important thing in your project is present in its app folder and when you create a new project with same name and copy app folder from your older version of your project, you will have a newer version of your project with all same resources.
Note: You can't move through branches and other commits
I saw this issue several times with Android studio. Below trick worked me the best.
Android Studio suggests to upgrade to newer version, please upgrade it and let it sync
Mostly you would see error message again
Now, Go to File -> Invalidate Caches/Restart
It should work now
If it shows same error then I don't know what to do.
If it shows different error then repeat from step 1 to 3 for new error.
Hope, it helps some..

Gradle sync failed: Cause: com.android.utils.StringHelper.appendCapitalized(Ljava/lang/StringBuilder;Ljava/lang/String;)V

I have done nothing with the codebase, and I'm surprised to see the below error.
And I have tried upgrading or downgrading the Gradle wrapper and Gradle build tools.
I'm using Gradle build tools v3.2.1 with Gradle wrapper4.6-all.zip.
Note: Other projects are working fine and even I tried deleted the complete code and cloned a fresh one
Can anyone please help me
update your gradle file.
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.2.0'

Resource entry com.crashlytics.android.build_id is already defined

My project was working and everything was fine but have no idea what happened suddenly that I'm getting error when I want to build my project. This is Gradle output:
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/values.xml:265: error: Resource entry com.crashlytics.android.build_id is already defined.
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/com_crashlytics_build_id.xml:9: Originally defined here.
Since both of these files are auto generated I cannot do anything :(
I tried to clean project by Build>"Clean project" but nothing happened.
I tried to clean project by ./gradlew clean assembleDebug but nothing happened.
I tried to invalidate cache of Android Studio by File>"Invalidate caches / Restart" but nothing happened.
I even restarted my f.laptop but still same problem displays when I build the project.
I have this classpath in my build script but as mentioned it was working...
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
Any suggestion would be appreciated. Thanks.
I have an app of two flavors: Debug and Release, with two manifests and two distinct packages com.myapp.release and com.myapp.debug for each flavor, respectively.
After migration from Fabric.io to Firebase Crashalytics, a Gradle warning
appeared about duplicate com_crashlytics_build_id.xml:
/home/.../app/build/generated/fabric/res/flavor1/debug/values/com_crashlytics_build_id.xml [string/com.crashlytics.android.build_id] /home/.../app/build/generated/crashlytics/res/flavor2/debug/values/com_crashlytics_build_id.xml: Error: Duplicate resources
Fix:
in build.gradle
remove
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
remove
apply plugin: 'io.fabric'
I had the same problem.
My mistake is I add fabric plugin and firebaseCrashlytics plugin on my gradle.
(reason : plugin build id duplicate crash)
You must fix select A and B plugin.
A : apply plugin: 'com.google.firebase.crashlytics
B : apply plugin: 'io.fabric
I had the same problem, one of my dependencies had mistakenly added the com.crashlytics.android.build_id via craslytics's auto genereted xml file.
It was a library project and deleting :
library/src/main/assets/crashlytics-build.properties
library/src/main/res/values/com_crashlytics_export_strings.xml
fixed it for me.
Fix different io.fabric.tools:gradle versions
Different io.fabric.tools:gradle versions in the app and library caused this for me.
I'd the following in the app's build.gradle:
classpath 'io.fabric.tools:gradle:1.19.2'
And the following in the library's build.gradle:
classpath 'io.fabric.tools:gradle:1+'
I changed both to following to fix it:
classpath 'io.fabric.tools:gradle:1.19.2'
PS: We need better error messages. As programmers we waste of lot of time when the error messages are not only bad, but as in this case, downright misleading.
remove this also besides fabric
crashlytics {
enableNdk true
}

Dalvik VM error: Exception found "Javax.xml.namespace.QName.class"

This isn't intended to be a question. Rather, an observation which is a common problem found in Android when you use external APIs for development and android.jar isn't duplicated into your project!
After searching through various forums, Google and stackoverflow, I seem to get a solution by myself and thought of sharing it.
Whenever you are linking external libraries, better link it by creating a /lib folder and dump those .jars there(means to COPY the files and NOT linking them). Link them using Eclipse -> Build Properties -> Configure Build path -> Library tab -> Add external Jars. Add the required .jars saved in /lib folder in this. (Note that, the jar included as a "Referenced Library" in Eclipse will disappear in /lib folder! But, not to worry as proper linking has happened. Another note is to check that the /lib jar that was referenced should NOT be visible in Libraries tab of Build Properties as it will be inherited.)
Another major problem was when Google APIs are being used. Specially the ones, which use some core library functions of java/javax. Be very careful of this. The error is that, the DalvikVM tries to link these but fails as there is a duplication found and is unable to decide which one to refer to. Below is the error.
Dx trouble processing "javax/xml/namespace/QName.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
In such cases, what I have observed is that, this class is used in xpp3-1.1.4c.jar. If you've copied this into your /lib folder, PLEASE REMOVE IT. Then clean the project, and give a fresh build. And the ship sails smoothly thereafter.
Do this for other referenced .jars if such duplication exists.
Cheers!
This worked for me. I'm using maven, and the xpp3-1.1.4c dependency shows up under "Maven Dependencies"; I had to exclude it using (right click the dependency) Maven-> "Exclude Maven Artifact...". Thanks a bunch -- this was really obscure.
This error show only when you trying to generate signed APK.
There are 2 ways to fix this.
1. As commented Amira Elsayed Ismail in this post this
we should revert to gradle 2.3.3.
To do this you should also download Android Studio 2.3.3 because studio 3.0.1 require gradle plugin 3.0+
This was the first solution. But reverting Android Studio and gradle plugins is a painful solution.
2. Resolve all dependency conflicts.
When i revert gradle, Studio 2.3.3 showed we interested warnings(i do not know why studio 3.0.1 don't show dependency conflict warnings)
Warning:WARNING: Dependency xpp3:xpp3:1.1.4c is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
So these dependencies are ignored for debug but NOT FOR RELEASE.
I fixed this by excluding these dependencies.
configurations {
all*.exclude group: 'xpp3', module: ['xpp3' ,'httpclient']
}
After this, i successfully generated signed APK using gradle 3.0.1.(without reverting).

Categories