Flutter - Can't build apk. Execution failed for task ':app:minifyReleaseWithR8' - android

I'm trying to build the release apk of my project and stumbled on this error today:
R8: Type io.flutter.plugins.webviewflutter.GeneratedAndroidWebView$WebViewClientHostApiCodec is defined multiple times
What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /flutter/.pub-cache/hosted/pub.dartlang.org/webview_pro_android-2.8.3+3/android/build/intermediates/runtime_library_classes_jar/release/classes.jar:io/flutter/plugins/webviewflutter/GeneratedAndroidWebView$WebViewClientHostApiCodec.class
This is related to the flutter_webview_pro plugin. I'm using the 3.0.1+3 version. I've tried to open an issue on the plugin's github page, but can't find the Issue tab. Is there a better alternative to this plugin? Can't use the official one because it doesn't support opening a file chooser on Android. Thanks for the attention in advance.

Sadly I didn't find the answer to solve this problem and decided to use another plugin for the same purpose: https://github.com/pichillilorenzo/flutter_inappwebview

I believe you were probably importing another package that this webview_pro also imports, maybe even the default webview_flutter

Related

Error on converting flutter project to APK, error files coming from AppData

So I tried every possible way and ask from different people, and I also tried updating dependencies on my project but to only possible latest version since there's a version constraint. Here's the full error
https://pastebin.com/r6ZEPURC
Script 'C:\Users\Rodrigo\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\Users\Rodrigo\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
How can I fix this issue? thanks.
I tried updating my dependencies and changing some parts of my code, but it still doesn't work. I was trying to build it into an APK for a few days now, but I still get the same error.
There is a known issue with the modal_bottom_sheet package conflicting with material bottom sheet. You need to follow the recommendations there to get your app to build. See: https://github.com/jamesblasco/modal_bottom_sheet/issues/328
As a general rule, it is always a good idea to check the package's GitHub repo issues section when you see errors like this.

weird gradle warnings during react-native variant-release build

(using android,
openjdk-11.0.13_8
node v16.13.2
react-native 0.67.0)
i created a barebone react-native project with
npx react-native init testapp
then signed it according to official react-native documentation
then tried to create the release-variant with npx react-native run-android --variant=release
now i get BUILD SUCCESSFUL message and got apk, and it installs and works in my physical device...
BUT, i got a lot of gradle problem-warning ...here is one sample..
Task :app:processReleaseManifestForPackage Execution optimizations have been disabled for task ':app:processReleaseManifestForPackage' to
ensure correctness due to the following reasons:
Gradle detected a problem with the following location: 'D:\testapp\android\app\build\intermediates\merged_manifests\release'.
Reason: Task ':app:processReleaseManifestForPackage' uses this output
of task ':app:copyReleaseBundledJs' without declaring an explicit or
implicit dependency. This can lead to incorrect results being
produced, depending on what order the tasks are executed. Please refer
to
https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency
for more details about this problem.
this same problem-warning is repeated for many other tasks!!...
NB i havent added any packages or changed any source code.. its the barebone app coming with react-native!... so how do i solve this issue?.. how to fix my settings so that this warning can be removed...
(i copied one of these tasks-names and did a text-search inside all files in my project directory to find out where its mentioned...but shockingly, its not mentioned anywhere!!!...so where are all these problem-warnings coming from? and how can we get a neat gradle build?)
this same warning is repeated in lots of lines in gradle output for other tasks too, such as:
Task :app:compressReleaseAssets
Task :app:processReleaseManifestForPackage
etc.. etc..

Ignite CLI (React Native) + Facebook SDK = Android Multidex?

Alright, so really just posting as a sanity check, and making sure I'm not doing my android all wrong. Essentially, it seems needing to use multiDexEnabled true is not best practice, as it means the app is getting "big", aka bloated. But it takes very little to get there with the tools I'm using, which I'll outline below.
TL;DR: Using multidex seems to be bad practice, is there a different solution?
Starting with a vanilla Ignite CLI Bowser project, a template engine for React Native, and adding the React Native Facebook SDK according to the official guide, results in a build error for the android application.
ignite new TestApp
cd TestApp && yarn add react-native-fbsdk && npx react-native link react-native-fbsdk
Following Android Guide, make relevant changes to
TestApp/android/app/src/main/java/com/testapp/MainApplication.java and TestApp/android/settings.gradle
Then, following the linked Facebook SDK guide (auth wall), made the relevant changes to TestApp/android/app/build.gradle, TestApp/android/app/src/main/res/values/strings.xml and TestApp/android/app/src/main/AndroidManifest.xml
Then, running npx react-native run-android, results in the following build error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
More searches point to a fix of adding multiDexEnabled true to defaultConfig within the module build.gradle, which does fix the error. The issue, is most of those solutions also lead to others pointing out poor library management, importing too much, etc.
So, am I doing something wrong, or is this just the result of using Facebook SDK and Ignite CLI and there's nothing I can do about it? I just worry, as I was hoping to add more than one provider's OAuth to the application, but don't want a bloated application that never loads.
It's not related to libraries used in your project but to the number of methods used.
When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture and you have to turn on multidex to be able to support more methods.
https://developer.android.com/studio/build/multidex

Unity - Gradle Build error : Could not resolve all files for configuration ':releaseCompileClasspath'

I am developing a game for Android mobile phones on Unity. I recently updated my facebook SDK , due to merge conflicts when building the app caused by the extra libraries that had to be added to the project by the Play Services Resolver I had to edit my Gradle.properties file to look like below.
org.gradle.jvmargs=-Xmx4096M
android.useAndroidX=true
android.enableJetifier=true
I did this mainly cause some of the support libraries were the cause of the merge conflicts. But now I keep getting the following error and I do not know how to fix it. I have tried reimporting the SDK several times but I still get the same problem. I have also tried asking on the Unity forums but I have received no responses yet. Any help would be appreciated.
* What went wrong:
Execution failed for task ':preReleaseBuild'.
> Could not resolve all files for configuration ':releaseCompileClasspath'.
> Failed to transform artifact 'com.android.support.support-v4-27.0.2.aar (:com.android.support.support-v4-27.0.2:)' to match attributes {artifactType=android-manifest}
> Execution failed for JetifyTransform: D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar.
> Failed to transform 'D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
go to Assets\Plugins\Android and remove all content then
in unity editor in Assets menu go to Play Service Resolver(or external play resolver) >Android Resolver>Resolve
now everyThing is oK!
I was having the same issue, I've fixed it with :
Assets
Play Service Resolver
Android resolver
force resolve
Right click on assets folder
Select Play Service Resolver
Android resolver
Resolve
It will fix the problem but make sure your java environment variable is setup otherwise it might not work

Unity 2018.3 android dex merging issue

Before you decide to dismiss this post as "duplicate" without even reading it, understand that I have looked at a TON of posts related to this topic and I can't find a solution for my instance, including all of the ones that StackOverflow suggested. Most of the posts are for Android Studio instead of unity.
My error is given in Unity when trying to build to android, it crashes here.
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"
stderr[
D8: Program type already present: com.unity3d.ads.BuildConfig
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
I've tried changing stuff with a build.gradle file like a lot of posts suggest, but I can't get anything to work.
The error didn't exist in Unity 2018.2. I checked right before I updated, but the update is now throwing this issue.
Does anyone have any UNITY specific ideas what to do here? I've tried so many things and nobody's post has been able to help me yet.
Thanks for any help
You can open the PackageManage under Window in the menu bar and remove Advertisement or you can delete the com.unity.ads file of Library/PackageCache in the project directory to resolve this issue.
This error probably happens when you add a library which is not compatible with your compileSdkVersion.
In your case you can have libs that were not imported by default by unity (and now are)
or there can be a problem with the Build Tools version. (You can try updating them)
I had similar problem a few versions ago, but I don't remember how I fixed it.
I didn't have time to upgrade to unity 2018.3 yet. (So the tips are more like guesses, but it may help you solve the issue.)
My settings (Mac):
- Android Studio 2.3
- Unity 2019.1.5f1:
- Player Settings -> Other Settings –> Scripting Runtime Version = .Net 4
- Package Manager -> Advertisement: Uninstalled
- Preferences -> External Tools -> Android: checked Installed with Unity (everything)
My solution:
- delete GoogleMobileAds from project
- delete PlayServicesResolver from project
- delete Plugins from project
- Import Package -> Custom Package -> GoogleMobileAds.unitypackage (3.15.1 in my case)
Dex Errors generally occur when you have too many methods imported in a project, not because of a specific package. I assume upgrading to new version made you import new stuff to your project.
You need to enable ProGuard.
Cause: http://twinkfed.homedns.org/Android///tools/building/multidex.html
Fix: https://www.youtube.com/watch?v=va0FQNlBUX0

Categories

Resources