Facing issue once i run my react-native app on android - android

Once i try to run my react native app on android then it shows me an following error
i can run run the command : react-native run-android
Task :app:transformDexArchiveWithDexMergerForDebug FAILED
Any one solve my problem i will be very thankfull to you

Please check out this it might resolve yourExecution failed for task ':app:transformDexArchiveWithDexMergerForDebug'
precisely you just need to add this in android/app/build.gradle
defaultConfig{
.......
multiDexEnabled true
}
}

Related

How to fix flutter AndroidX incompatibility?

I just import webview_flutter plugin and found that the plugin has incompatible with my flutter environment. Then using Android Studio I migrate my AndroidX environment with "Migrate to AndroidX" option.
I want to use webview_flutter plugin for viewing the page. Help appreciated.
Here is the error message
Launching lib/main.dart on Andromax B26D2H in debug mode...
D8: Program type already present: android.support.v4.media.MediaBrowserCompat$ItemCallback
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/22.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/105.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/148.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/133.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/72.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/128.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/79.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/88.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/110.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/67.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/120.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/91.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/102.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/6.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/118.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/5.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/52.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/58.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/43.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/127.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/142.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/151.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/19.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/34.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/46.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/63.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/107.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/9.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/31.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/15.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/115.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/70.jar, /Users/tio/Documents/Development/firecek_2019/build/app/intermediates/transforms/dexBuilder/debug/62.jar,
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.media.MediaBrowserCompat$ItemCallback
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 4m 59s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Thanks for your suggestion,
I've fixed it by doing these steps :
1. Try adding this line In your Project folder > android > app > build.gradle, add the following Line in
multiDexEnabled true
inside defaultConfig
Then upgrade gradle dependency in the android/build.gradle file: classpath 'com.android.tools.build:gradle:3.3.1' (previously on version 3.2.1)
Run flutter clean and rebuild your project
First make sure that all your packages in the pubspec.yaml are of the latest version. Then open the android project of your flutter app with android studio, select Refactor->Migrate to Androidx(make sure that you are doing that that from the android project and not from the flutter one). Wait until android studio finishes migrating your project, rebuild your project. Hope it helps!
I found this solution on Github by #tiklupxgit, solved this issue quickly.
Update this line in [Project Directory]/android/build.gradle
classpath 'com.android.tools.build:gradle:3.5.4'
Now run these commands in your terminal under [Project Directory]
flutter clean && flutter pub get
Finally, build your project again.
It seems like you are facing issues with dex and androidX.
Follow https://stackoverflow.com/a/56490440/9236994
this answer to resolve your issue.
Create a new flutter project and move existing code to it: flutter migration
flutter create --androidx -t <project-type> <new-project-path>
eg: flutter create --androidx -t app .
I have tried the best ever possible ways to break it down. I have been trying to use youtube videos from URL using the youtube video flutter plugin and getting androidx incompatibilities plugin error. Finally, I found the result. Just update
the build.Gradle file in android - classpath
'com.android.tools.build:gradle:4.1.0'
gradle-wrapper.properties
distributionUrl=https://services.Gradle.org/distributions/gradle-6.7-all.zip
update the value as above it will work perfect, as for me.
For me, I copied settings.gradle file
to the new file settings_aar.gradle
Then Removed the following code from settings_aar.gradle:
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
Ok I finally solved the problem thanks to #Navpreet Singh
In order to fix the problem of the default grey icon of Firebase FCM (on Xiaomi devices) I added in the Manifest:
From then on, I got this error when building the application:
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Completed 20,2s
The build failed probably because of AndroidX incompatibilities in a plugin. The tool is about to
try to use Jetifier to resolve the incompatibility.
Building the cloud_firestore plugin...
Exception: The cloud_firestore plugin could not be built because of the above problem.
Running the Gradle task 'assembleAarRelease'...
When I commented out the metadata in the Manifest, the program started to compile again.
Just Enable multidex in app/build.gradle file.
defaultConfig {
....
multiDexEnabled true
}
dependencies {
.....
implementation 'com.android.support:multidex:2.0.1'
}
You just only run 'get packages' in your pubspec.yaml and the probles will be solve
you can solve this issue by following these step which is given in this link
https://medium.com/#sahaishashank2507/the-gradle-failure-may-have-been-because-of-androidx-incompatibilities-in-this-flutter-app-39b34acee40e?source=---------2------------------
You need to open your project in the android studio.
select Refactor->Migrate to Androidx(You need to migrate Android Project not
flutter one)
Android Studio finish some process you have to wait for it .
Than rebuild your project and it will work fine.
it can resolve your issue

Flutter app doesn´t compile in android after adding dependency to pubspec.yml

I have added the simple_permissions dependency to a flutter app i'm developing, but after adding it the app wont build with the next error:
Launching lib\main.dart on LG M700 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
I already had this dependencies:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
path: ^1.6.2
path_provider: ^0.5.0+1
open_file: ^1.2.2+2
This compiles fine, but after adding simple_permissions: ^0.1.9 the app wont compile. I have already tried some solutions that required changes in the build.gradle file but they havent worked either, like changing the sdk version from 27 to 28 and adding this piece of code:
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
As the build fails generating the dex list.
I'm developing the app using vscode and running the app in my smartphone.
I would be really grateful if you could help me with this.
I had a lot problem with the simple_permissions.
I ended up to use permission_handler
Try changing buildToolsVersion to "23.0.3" (old, but stable), and then go to File > Invalidate Caches/Restart and select Restart.
If that doesn't work, delete your "build" folders (if they exist), and then retry.
If both fails, you can just enable multidex. But this is a bad approach and should not be done under normal circumstances.
In my case I upgraded my flutter sdk then this problem had been solved ...
It happens because some packages of Flutter make conflict with Androidx LifeCycle. So you need to upgrade the Flutter then run your app.... I think then there should not be no Errors like this...
For Flutter type "flutter upgrade" in your terminal...
1st Solution
You need to update your flutter sdk to the latest version. On the recent flutter stable release (2.10) they have automatically enabled Multidex. So you will have no problem to run it.
To upgrade to latest stable release visit documentation
2nd Solution
If you build your project with older versions (below 2.10), check this question

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. Flutter

I am trying to debug my Flutter application on Pixel 1 and getting this error:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
I've read up on it and have implemented the suggested changes such as adding:
multiDexEnabled true to defaultConfig.
Any thoughts on how to go about debugging this?
Resolved by downgrading cloud_firestore dependency in pubspec.yaml to ^0.7.0

Execution failed for task ':react-native-youtube:verifyReleaseResources'

While making build of react native app I get the following error.
* What went wrong:
Execution failed for task ':react-native-youtube:verifyReleaseResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
And after this the build is failed.Why this came and what is the possible solution for this problem?
Reason for the error:
You have installed react-native-youtube as a dependency, And the reason for this error is that the configurations of your android/app/build.gradle and node_modules/react-native-youtube/android/build.gradle mismatch.
Solution
Navigate to node_modules/react-native-youtube/android/build.gradle
Edit and keep the compileSdkVersion buildToolsVersion minSdkVersion
targetSdkVersion same as you have in android/app/build.gradle
Sync the project again.
Run ./gradlew assembleRelease from the terminal.
Edit your node_modules/react-native-youtube/android/build.gradle file like this:
https://github.com/hwjfordev/react-native-youtube/commit/606401aa236e94394736fcc43ce9a4e29bf6a129

Facing an error when running my android app on an emulator

Hi I'm just starting to learn how to code on android studio.
After running npm run android on my terminal, I've faced some errors which I could not solve.
The error message is as follows :
XXXX-MacBook-Pro:first-app XXXX$ npm run android
first-app#0.1.0 android /Users/XXXX/Desktop/React Native/first-app
react-native run-android
Scanning folders for symlinks in /Users/XXXX/Desktop/React
Native/first-app/node_modules (8ms) Starting JS server... Building and
installing the app on the device (cd android && ./gradlew
installDebug)...
FAILURE: Build failed with an exception.
What went wrong: Could not resolve all files for configuration
':app:_internal_aapt2_binary'. Could not find
com.android.tools.build:aapt2:3.2.0-4818971. Searched in the
following locations:
file:/Users/XXXX/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/.m2/repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/.m2/repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/Desktop/React Native/first-app/node_modules/react-native/android/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Desktop/React Native/first-app/node_modules/react-native/android/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
Required by:
project :app
BUILD FAILED in 3s 11 actionable tasks: 1 executed, 10 up-to-date
Could not install the app on the device, read the error above for
details.
I hope you guys can help me with it.
I managed to fix this issue by adding a line google() to ~/my-app/android/build.gradle in the following section:
allprojects {
respositories{
google() //right here
}
}
Just a guess, but I believe it is a regression to do with the new Android Studio 3.2.0 release.
This is in react native which in fact i never used, this isn't an answer but i cant comment as my reputation is too low for that(pardon me). Have you installed android build tools? The ':app:_internal_aapt2_binary' is a configuration file that the system needs to compile the application which is a part of build tools.
If you are using android studio 3.0, then in gradle , change the dependency from
compile files('xyz')
to
implementation files('xyz')

Categories

Resources