Why is Android Studio failing to build, with an AAPT2 error on images? - image

After a recent update, Android Studio fails to build an unmodified project with errors along these lines:
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.1-6503028-linux Daemon #0: Unexpected error during compile '/path/to/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
Notice that it's failing on an image supplied by Android Studio itself!
What can I do to fix it?

This seems to be an error in the newest (newer?) Gradle plugin(s) when it comes to PNG images; Google's IssueTracker lists several newly reported bugs along these lines. One of them mentions that it's a Gradle issue; I made mine work by reverting to a previous version: Gradle Plugin 4.0.1 and Gradle version 6.1.1 work fine.
It will be necessary to ignore AS' nagging about a newer version until this gets fixed.
[Added at the request of #YinOrYan]
To revert to an older version of Gradle:
In the menu, select "Files", then "Project Structure..."
In the dialog that pops up, select "Project" (first item in my version).
You can select the desired versions of the Gradle plugin and of Gradle from the drop-down menus.
This should not lose any system calls, as this is different from the SDK or API versions. However, it's not independent of them, so there is probably a limit to where you can set them.
As usual you will want to be online when you first build, or whenever you have to import a dependency, but otherwise it should be possible to work offline.

Sadly, it looks like an issue with older architectures. While the team at Google is looking into fixing it, in the meanwhile you can still use the new Android Studio and AGP, but temporarily revert to using an older version of AAPT2:
Try locating the old aapt2 executable in your gradle cache, e.g.:
~/.gradle/caches/<subdirectories, hashes
etc>/aapt2-4.1.0-alpha03-6246747-/aapt2(.exe)
Once you have the path you can add to your gradle.properties file:
android.aapt2FromMavenOverride=path/to/old/aapt2
To make this a little bit more robust you can actually copy that executable to a non-cache location, in case you clean your caches and it dissapears.
Hope this helps! Keep an eye on the Issue Tracker bug for updates.

I also had the same problem with AAPT2 errors and I have got over it.
First, downgrades Gradle to version 4.0.1, or
Second, I have done is upgrading the AMD Athlon processor to AMD FX-4300 without downgrading the gradle plugin version.

Wow, that's a real show-stopper! Can you explain how you reverted to an older gradle in Android Studio. Is it possible to work offline after doing this. And, did you lose any of the new system calls as a result? All this going on after finally getting my code working with the new AR Core stuff...

Related

Unable to find Groovy method when building Rhino with Intellij IDEA

While trying to build https://github.com/mozilla/rhino, I'm getting Unable to find method on org.codehaus.groovy.runtime.StringGroovyMethods.
so the build fails, and I'm unable to test Rhino built from source code, which is the goal.
Steps Taken
From the opening screen in IntelliJ, I check out the project:
I get this error Unable to find method ''java.lang.String org.codehaus.groovy.runtime.StringGroovyMethods.capitalize(java.lang.String)'' right away, which I have not been able to fix:
There are two suggestions in the above Re-download dependencies and sync project and Stop Gradle build processes. I have tried both with no improvement.
When I look at the build.gradle file, I see another suggestion ...configure Gradle wrapper to use distribution with sources.... This also does not get past the missing Groovy method problem.
I have looked on S.O. for similar issues and tried various things under File > Settings > Build, Execution, Deployment, but I realized I'm over my head since, conceptually, I'm not sure what I need and where that would go in the settings.
The command line items from the readme work as expected, but going back to File > Build still fails (added after tim_yates comment).
What changes are required to the IDE or to the build definitions to allow Mozilla Rhino to build properly?
I installed the latest (2022.1) version of IntelliJ IDEA Community Edition. During the install, it asked if you wanted this IDE to be associated with Groovy file types, and I answered in the affirmative.
On this new install, the Unable to find method on org.codehaus.groovy.runtime.StringGroovyMethodserror did not appear, so the problem was solved by upgrading the IDE (and also that required updating GIT).

Netbeans 11 Gradle Project does not run gradle on save

I have just installed Netbeans 11.1 and when I save one of my Java files, Netbeans does not start a gradle build automatically. This used to work in Netbeans 8.2.
I have installed nb-javac and have also tried the newest Beta version to no avail.
Is this a known bug or do I need to reconfigure something when going from NB 8.2 to 11.1?
(This is only an explanation rather than a solution to your problem.)
First, Compile on Save is an option which is set or unset at the individual project level, rather than at the global level. So for a NetBeans Gradle project, select Properties > Build > Compile to view the setting for the Compile on Save checkbox. For that checkbox, note that:
It is unchecked by default, so there will not be an automatic Gradle build when you save a project file.
It is disabled, so you cannot trigger a build whenever you save a project file.
The problem persists in the latest beta of NetBeans 11.2.
I don't see a bug report for this issue, so perhaps you can raise one? Click the Log In button to sign up first if necessary.
That said, there is a related issue which may explain why the check box cannot be enabled. See closed bug NETBEANS-680 Erroneous Gradle Compile-on-Save activity which relates to Gradle projects using version 9.0 of NetBeans. Apparently there were spurious and unwanted compile-on-save runs being triggered even though Compile on Save was unchecked. Perhaps the feature has been deliberately disabled for Gradle projects because of that issue, though that is just speculation on my part.
Also see the GitHub page for the Gradle plugin. Comments from the NetBeans team for NETBEANS-680 suggest that the problem was with the plugin rather than NetBeans. That said, if NetBeans is offering functionality that cannot be enabled (i.e Compile on Save), it is definitely a NetBeans issue regardless of the underlying cause.
Finally, note that you can configure the Gradle plugin using Tools > Options > Java > Gradle, but I dodn't see any options there that would help with this issue.

Personal workspace was overwritten after upgrading to Eclipse Oxygen.1

I have just proceed to update my current Eclipse Oxygen installation to the latest versions (including Oxygen.1). As I did before (with previous Neon iterations for example), I have launched Eclipse using the administrator mode on Windows.
After updating all the componants, when I restart using the normal mode, all the settings I have made in my own workspace seems to have be fully overwritten: it now looks like the default workspace.
I don't understand if I have made something wrongly or if there have been a bug during the upgrade process, but I would want to know if there is a way to retrieve my previous workspace and to prevent this kind of behaviour.

IntelliJ 2017.2 stuck on `Loading archetype list` for `New Project` > `Maven`

When choosing the Create New Project option after launching IntelliJ 2017.2, I get this endlessly spinning wheel on the Maven tag, saying “Loading archetype list…”.
Any way to get to a Maven archetype?
I just hit this on 2017.2.3 (just updated now) on Fedora 24 (oops time to upgrade)
The immediate solution was to change the Maven settings (File > Settings > Maven) to use my on-machine Oracle JDK 1.8.0_144 instead the default "internal JRE" 1.8.0_152. Btw, the importer uses JVM option -Xmx768m by default.
And we go on...
Wait
Loading the full list of Maven archetypes seems to be quite an exertion for IntelliJ. Surprising, as I don't recall any such long delays in NetBeans.
So wait, be patient. May take a couple minutes. Make tea, pat the dog. Wait for the fan on your computer to spin up and then quiet again.
Use more memory
I currently have VM options for importer set to -Xmx2048m as shown in the Answer by Tonhofer.
I do not know if this point was key, but my problem has gone away «knock-on-wood». So this might be helping.
FYI… I have a 16-gig MacBook Pro (Retina, 15-inch, Late 2013) running Sierra 10.12.6 with two Java implementations, Java 8 Update 144 from Oracle and Java 9 beta jdk-9+181 from OpenJDK.
Quit, update repositories
While I do not understand what all is going on, it seems like this has been a workaround for me.
Quit IntelliJ, then launch again.
In Preferences/Settings, go to Build, Execution, Deployment> Build Tools > Maven > Repositories. Click each of the listed repositories, and click the Update button. A spinning wheel appears for the duration of the update.
A copy of each repository’s data is being downloaded and parsed on your local machine, descriptions of all the libraries known by that repository. Some of the repositories may be quite large with many listed projects. So this process may take a while, possibly more than several minutes.
When the updates are complete, try the New Project feature again.
Add more memory
Settings > Maven > Importing
VM options for importer -Xm1024m (or more)
Closing out of IntelliJ and creating the project from this window helped:
IntelliJ Welcome Screen
I managed to solve the issue by updating the NVIDIA driver, based on IntelliJ logs. Anything else did not work for me. The list loads now in a few seconds..finally.
Edit:
as Basil suggested, here are some clarifications. I am on Windows 10 Home Edition 64b, and I have IntelliJ 2017.2 with Java 1.8.0_152. I checked IntelliJ logs and followed a standard procedure: I went on Google and I searched by that exception (I can't remember what and where) and found a site where someone suggested to update my nVidia drivers. For the update, you only need to go to nVidia site and from that on it should be easy. I was on a 2016 driver and got to 2018 version after the update. I also have the previously added configurations from other comments.

TeamCity - Behind Proxy causing build failure

Below is an error message I am getting trying to build a current project,
I am behind an enterprise proxy but this has only happened this morning after building fine for the past couple of months.
the current installed version of nuget is 2.8.3 and nuspec is 3.0.0.
I see it says it needs credentials but this has never happened before and i am not sure how to get around this in Teamcity.
Also all my other solutions are building fine so it makes it even more confusing as they are all built on the same template.
Okay, if I were less impatient and did some back tracking on my check-ins, I would have noticed that I had checked in .nuget/packages.config. which had dependencies on these packages above.
I removed these from the .nuget/packages.config and this resolved the issue.
Hope if anyone in the future is having the similar issues that this will help you too.

Resources