How to remedy error caused by guava: Program type already present: com.google.common.util.concurrent.internal.InternalFutures - guava

An AAR library already uses com.google.guava.
If an app includes the following in its build.gradle:
api 'com.google.guava:guava:27.0-android'
Building the app generates the following error:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: ...
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.google.common.util.concurrent.internal.InternalFutures
If I do not include "api 'com.google.guava:guava:27.0-android'", the app can be built, but it has runtime error of java.lang.NoClassDefFoundError when it reaches the point of using the Guava method: Iterables.find

I had to update to version 27.0.1, at the time of writing they still haven't updated the README with this new version.
implementation 'com.google.guava:guava:27.0.1-android'

Since Guava 27.0, ListenableFuture is located in separate artifact, see the announcement. You can try two things (one at a time):
Exclude "listenablefuture" module (group "com.google.guava") and build your project again.
I don't know the AAR specifics, but it could be that 27.0-android doesn't work with AAR, so you should try 26.0-android instead.

Related

Why is Install4j executable signing not working any more?

I'm trying to build an Install4j project that was working fine a few weeks ago, but now it's complaining about a timestamp service not being available while the executable is being signed. Is there another timestamp service we should be using or is this one only temporarily offline?
I'm using Install4j 7.0.12.
Preparing configuration
Creating media file 'Windows':
Collecting files:
Compiling launchers:
Compiling launcher 'test':
Signing executable
Build failed.
Cause: java.io.IOException
http://timestamp.globalsign.com
You can set a different timestamp signing service by setting the VM parameter -Dinstall4j.timestampUrl=http://... in bin/install4j.vmoptions
or by setting the compiler variable sys.ext.timestampUrl in your project.
Cause: java.io.FileNotFoundException
http://timestamp.globalsign.com
Adding an entry to General Settings > Compiler Variables with the following details seems to do the trick:
sys.ext.timestampUrl = http://timestamp.sectigo.com
This is probably related to http://timestamp.verisign.com/scripts/timstamp.dll not available.

Groovy:General error during semantic analysis: java.lang.NoSuchMethodError:

Imported the gradle project from the "complete" folder and received the following error:
Groovy:General error during semantic analysis:
java.lang.NoSuchMethodError: 'org.codehaus.groovy.ast.expr.Expression org.codehaus.groovy.ast.tools.GeneralUtils.propX(org.codehaus.groovy.ast.expr.Expression, java.lang.String)'
I am using the latest version of Eclipse, 2020-12, with groovy tools installed.
From grails guide
https://guides.grails.org/gorm-without-grails/guide/index.html
Downloaded code sample from github
https://github.com/grails-guides/gorm-without-grails.git
It seems likely to be a version mismatch, but I cannot determine how to correct this problem.
I have tried to delete the offending file, src/main/groovy/demo/domain/Manufacturer.groovy, and the error appears on the file in this package on line 1.
The error does not appear in any other package. I have done the usual internet searches for resolutions that apply, but have thus far been unable to find a suitable solution. I am hopeful for a suggestion?
I think this error comes from an AST transform that references the older signature of GeneralUtils#propX. This method used to return Expression and was changed to return PropertyExpression.
The bridge method for binary compatibility was missing in groovy-eclipse. https://github.com/groovy/groovy-eclipse/commit/f6f448675d95f858b4ec65b6fc8e55f27ccaaa94

Why the app produced by flutter build web sometimes doesn't work?

I have 2 issues that only appear when executing flutter build web.
Sometimes flutter build web fails complaining (wrongly) about types that were not compatible (see below).
Sometimes the build process finishes but then the web app doesn't work: doesn't display anything and there are no messages in the console.
The error I mention is something like this:
% flutter build web
Target dart2js failed: Exception: lib/main.dart:24:31:
Error: A value of type 'ApiUsersRepository' can't be assigned to a variable of type 'UsersRepository'.
- 'ApiUsersRepository' is from 'package:my_app/api_users_repo.dart' ('lib/api_users_repo.dart').
- 'UsersRepository' is from 'lib/users_repo.dart'.
final UsersRepository usersRepository = ApiUsersRepository();
^
Error: Compilation failed.
The app is working in iOS and web when developing.
The solution
I changed all imports of my files like:
import 'package:my_app/users_repo.dart';
To:
import 'users_repo.dart';
More Details
Investigating the error about types, I found this issue, where the important part is this comment: after changing every import to relative format it resolves my problem.
So I did that, and it solved the 2 issues, the compilation error, and the runtime error.
for me I had to remove a package that was corrupted. c:\src\flutter.pub-cache\hosted\pub.dartlang.org\localstorage-4.0.0+1 Apparently, a file had become corrupted by me invertly. I removed the package and did a flutter pub get then recompiled and it worked.

Merge Project: Error while building merged project with error undefined compiler variable

I am using merge project feature of install4j.
I have created sub-project with one action in it. This action uses some compiler variables which are defined in same project(sub-project).
Now I have merged this project into main project, and created the link to an action from sub-project.
But when I try to build main project it gives error that variable used in action is not defined as shown below.
Build failed.
Cause: com.exe4j.b.z
When trying to process '${compiler:RegPath}': the variable 'RegPath' has not been defined. Stack trace:
com.exe4j.a.d: com.exe4j.b.z: When trying to process
'${compiler:RegPath}': the variable 'RegPath' has not been defined.
at com.install4j.b.i.b(ejt:175) at com.install4j.gui.b.run(ejt:100)
Caused by: com.exe4j.b.z: When trying to process
'${compiler:RegPath}': the variable 'RegPath' has not been defined.
at com.install4j.config.l.a(ejt:577) at
com.install4j.config.l.a(ejt:485) at
com.install4j.config.l.a(ejt:431) at com.install4j.b.c.f.a(ejt:84)
at com.install4j.b.c.f.a(ejt:87) at com.install4j.b.c.f.a(ejt:87)
at com.install4j.b.c.a.a(ejt:1079) at com.install4j.b.c.a.a(ejt:957)
at com.install4j.b.c.a.a(ejt:943) at com.install4j.b.c.a.a(ejt:925)
at com.install4j.b.c.a.a(ejt:762) at com.install4j.b.c.a.a(ejt:721)
at com.install4j.b.c.a.k(ejt:685) at com.install4j.b.c.a.b(ejt:227)
at com.install4j.b.c.a.a(ejt:133) at com.install4j.b.b.v.a(ejt:75)
at com.install4j.b.b.c(ejt:285) at com.install4j.b.b.a(ejt:141) at
com.install4j.b.i.a(ejt:413) at com.install4j.b.i.b(ejt:156) ... 1
more
Am I missing anything?
Project Files: Sub-Project Main Project
This is a bug that will be fixed in 7.0.9. Please contact support#ej-technologies.com to get a build where this is already fixed.

Migrating to Dart 2 I get a "check imports error" that means that some templates have not been generated

I'm trying to migrate to Dart 2, I have a lot of packages and up to now I could do my job with not so much problems.
Now I'm getting a strange error bot with DDC and dart2js:
[SEVERE] build_web_compilers|entrypoint on web/main.dart (cached):
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
`import 'package:ledger_web/src/ui/components/main_selection_bar.template.dart';` from ledger_web|lib/src/ui/components/service/main_selection_bar_service.dart at 7:1
`import 'package:ledger_web/src/ui/components/main_selection_bar.template.dart';` from ledger_web|lib/src/ui/components/service/main_selection_bar_service.template.dart at 11:1
... and more
It is correct to signal that there is not the import (MainSelectionBar is an angular component), because the template has not been generated.
Now the problem is, why the template is not there?
I checked the .dart_tool/build/generated directory but the template has not been created.
I have a similar package with a similar component that works fine, so I cannot figure out what's happened.
Is there a place where there is a more detailed error list?
Interestingly enough, there is also a case in which the template exists, but it is listed like if it was not found....
Any hint?
Most likely this is related to a build failure when generating the template, which is not being properly reported on subsequent builds. This pull request should help that https://github.com/dart-lang/build/pull/1834/, but you can also try running pub run build_runner clean and then doing a new build to get the original error back.