I am working on a react native application. when I try to build the applications using react-native run-android the build fails. Here is the output of the error that occurs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
253 actionable tasks: 5 executed, 248 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug
debug Error: Command failed: ./gradlew app:installDebug
at checkExecSyncError (child_process.js:607:13)
at execFileSync (child_process.js:627:13)
at runOnAllDevices (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runOnAllDevices.js:58:39)
at buildAndRun (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:142:41)
at then.result (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:104:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
The application was on a old version of react native (0.48.x) I have updated it to 0.59.10.
What I have done so far:
used jetifier to resolve issues with the plugins.
checked that the build tools version matches the compile sdk version
checked if the emulator is running.
Hence I have tried everything I could to resolve this but had no luck. Please do guide me on how to resolve this issue. Looking forward to your answers.
make sure you have followed all the necessary steps from the upgrade helper https://react-native-community.github.io/upgrade-helper/?from=0.48.0&to=0.59.10
also i would suggest you to upgrade to v0.60+ because there are breaking changes after v0.59.10.
having said that
before you run the app make sure your gradle is clean
run the following command to clean your gradle cd android && ./gradle clean
then later you can navigate back to your app folder cd .. and try and run again react-native run-android
Looks like your packages not working stable with Android side. It's better be update all packages and react native version to their last stable versions.
If you face with too much error while update, you can create fresh new react native project (with same package name with your current project), install all packages (and their dependencies) and copy your current project's source code to your new project.
Android in React Native does not allow similar packages to reside in the project.
In my case I had react-native-cookies and #react-native-cookies/cookies packages that add similar code to the Kotlin file upon build. This causes issue of similar imports in java JDK.
I removed one and it worked.
SOLVED at the same issue:
My solution was at /android/build.gradle file.
Somehow, the buildscript versions were wrong.
Follow the exact same step of RN documentation and make a totally new & clean project.
And compate the /android/build.gradle file > buildscript & dependencies part.
There should be some version differences.
It matters by your own local env settings.
After changing buildToolsVersion, ndkVersion, classpath, it worked fine again!!
also, remove duplicated libraries, as #Nimantha said.
Related
I am developing a flutter app for Android. For that I am using a realm database and I am using the realm dependency for flutter https://realm.io/realm-flutter/ to read data from it. This realm database is generated by some android library com.my_realm_generating_library.
My problem is now, that com.my_realm_generating_library imports the realm library for kotlin https://realm.io/realm-kotlin/ and because I am importing the realm library for flutter, the kotlin library is included a second time.
When I run flutter build apk I get this result:
Running Gradle task 'assembleRelease'...
Realm binaries for realm#0.8.0+rc already downloaded
Realm install command finished.
ERROR:/home/user/.gradle/caches/transforms-3/c90739e9642326489e851a982778d55f/transformed/jetified-realm-android-library-10.6.1-runtime.jar: R8: Type io.realm.BuildConfig is defined multiple times: /home/user/.gradle/caches/transforms-3/c90739e9642326489e851a982778d55f/transformed/jetified-realm-android-library-10.6.1-runtime.jar:io/realm/BuildConfig.class, /home/user/projectname/build/realm/intermediates/runtime_library_classes_jar/release/classes.jar:io/realm/BuildConfig.class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete, origin: /home/user/.gradle/caches/transforms-3/c90739e9642326489e851a982778d55f/transformed/jetified-realm-android-library-10.6.1-runtime.jar:io/realm/BuildConfig.class
* 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 8s
Running Gradle task 'assembleRelease'... 9,2s
Gradle task assembleRelease failed with exit code 1
When I remove the realm library from my pubspec.yaml, everything compiles. But I need access to my realm file from my kotlin code and my dart/flutter code. Is there some way to fix such dependency conflicts, where flutter uses a library and kotlin the same and in the end none of them work?
What I tried so far:
I removed realm: ^0.8.0+rc from the dependencies section of my pubspec.yaml. Then everything compiles. This is not an option because I need this library in my dart code.
I could also remove implementation "com.my_realm_generating_library" from android/app/build.gradle. But I also need this library in my kotlin code to generate my realm database. Therefor this is also no option.
Amazingly I was able to find an answer for my question, although I was unable to find one anywhere online so far. Hopefully this helps some people who get into the same trouble as I have.
Firstly, I navigated into my projectname/android and ran ./gradlew app:dependencies --console=rich to find all the dependencies of com.my_realm_generating_library.
In my case, the only dependency of com.my_realm_generating_library was io.realm:realm-android-library:10.13.0. I knew that this package will be provided by the realm-flutter dependency. Therefor I knew, that I can just force disable all transitive dependencies of com.my_realm_generating_library.
The code I put in my build.gradle under the dependencies section was this:
implementation("com.my_realm_generating_library") {
transitive = false
}
Now everything works. Hope this helps!
I have created a Flutter project in Android Studio (Bumblebee | 2021.1.1 Patch 3). When I open the android folder in a seperate window, when the gradle syncing is being executed, it fails with the message Gradle project sync failed. Basic functionality(e.g. editing,debugging) will not work properly. I ran ./gradlew --warning-mode all in the command line and it's output is
Configure project :app
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
at FlutterPlugin$_addFlutterTasks_closure21$_closure47.doCall(/home/sudipta/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle:863)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
at FlutterPlugin$_addFlutterTasks_closure21$_closure47.doCall(/home/sudipta/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle:864)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
> Configure project :system_alert_window
WARNING: The option setting 'android.enableR8=true' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :help
Welcome to Gradle 6.7.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see a list of command-line options, run gradlew --help
To see more detail about a task, run gradlew help --task <task>
For troubleshooting, visit https://help.gradle.org
The last warning is due to system_alert_window (flutter)plugin that I am using. But these deprecation warnings are causing issues in Android Studio editor so that I am unable to use code completion feature. I don't know why is this happening, since these are only warning messages.
My gradle version is 6.7 and android-gradle version is 4.1.0.
Can anyone please help?
TRY this steps-
Step 1:
Open the gradle.properties file same like given Image-
https://i.stack.imgur.com/S2Y0a.png
Step 2:
Disable android.enableR8=true by adding a # in front:
#android.enableR8=true
Alternatively, you can swap out the R8 for D8, The build system changed to using D8 instead of R8.
android.enableD8=true
Getting this error in my React-Native app when I run on Android using npx react-native run-android --variant=release or generate a Release Build. I tried whatever solutions I found on Stackoverflow and GitHub like - upgrading gradle build tools version, modifying babel.config.js, clean project, --reset-cache, rm -rf node_modules and reinstall, Invalidate and Restart, etc. but none of it solved. It is a blocker since I am not able to generate a build to publish.
I have provided the only stacktrace error available.
> Task :app:bundleReleaseJsAndAssets FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 executed
The system cannot find the path specified.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'cmd'' finished with non-zero exit value 1
Another information I noticed is I am getting the above stacktrace when the build execution executes :app:bundleReleaseJsAndAssets and reaches react-native-animated. I tried the solutions suggested from the similar issues reported in react-native-animated but that too didn't fix.
I am not able to find whether the issue is with the package or the local project setup.
Also I noticed that the package doesn't seem to be configured properly in Android. Screenshot attached below for reference. This package alone doesn't have the right arrow.
Library versions:
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-reanimated": "2.1.0"
Gradle info:
classpath("com.android.tools.build:gradle:4.0.1")
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip
Android Studio Version: 4.2.1
Any Suggestions?
While checking this answer I found that the below line was present in my code
project.ext.react = [
nodeExecutableAndArgs : ["/usr/local/bin/node"]
];
My other RN projects doesn't have this line but worked fine. So removing the line nodeExecutableAndArgs : ["/usr/local/bin/node"] fixed the issue.
I was getting a similar issue. After struggling with it for a few hours, realised it was due to babel.
Upgrading babel to latest version helped me resolve this issue.
Hope this helps someone.
I'm currently learning Flutter using Android Studio but I can't figure this issue help pls thank you :(
Compiler message:
../../.pub-cache/hosted/pub.dartlang.org/flutter_chips_input-1.3.1/lib/src/chips_input.dart:42:7:
Error: The non-abstract class 'ChipsInputState' is missing
implementations for these members:
- TextInputClient.connectionClosed Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class ChipsInputState extends State>
^^^^^^^^^^^^^^^ ../../flutter/packages/flutter/lib/src/services/text_input.dart:658:8:
Context: 'TextInputClient.connectionClosed' is defined here. void
connectionClosed();
^^^^^^^^^^^^^^^^ Target kernel_snapshot failed: Exception: Errors during snapshot creation: null build failed.
FAILURE: Build failed with an exception.
Where: Script '/Users/clyde/flutter/packages/flutter_tools/gradle/flutter.gradle'
line: 780
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/clyde/flutter/bin/flutter'' finished with non-zero exit value 1
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 18s Finished with error: Gradle task assembleDebug
failed with exit code 1
If you are using Flutter Form Builder, you can manually update the flutter_chips_input library to the latest version because the Flutter form builder uses an old version.
This issue was discussed in the Flutter GitHub repository Issues section here.
Adding the below dependency manually to the pubspec.yaml file solved the problem for me:
flutter_chips_input: ^1.9.4
I am guessing you are on dev or master channel (at least that is the cause in my case)...you can switch to beta or stable to get rid of the error:
flutter channel beta|stable
I have also faced the same problem and not sure how that was fixed.
I have tried the following things
Check Flutter Doctor and fix if you have any errors
Try Flutter clean
Delete pubspec.lock file and run flutter pub get or flutter pub upgrade
I Hope, that may help you guys.
What worked for me
Look for packages in your pubspec.yaml file that depend on the chips_input package, e.g. form_builder and make sure it's the latest version.
Upgrade all packages in pubspec.yaml file to be sure.
I've been stack with the same error. I've searched and tried everything and nothing works.
Based on searching, the issues may have been caused by using flutter_form_builder package on an incompatible version of flutter SDK.
What works for me (Windows user):
Tried switching to master|stable version
Deleted all flutter and pub temp directories/folders:
Navigate to C:/Users/(Current User)/AppData/Local/Temp/ and delete all directories/folders having
flutter_tool.xxx, native-platformxxx, and pubxxx
Installed the latest version of Flutter SDK.
https://storage.googleapis.com/flutter_infra/releases/stable/windows/flutter_windows_1.17.3-stable.zip
Tried Flutter clean
Deleted pubspec.lock file and run flutter pub get or flutter pub upgrade
Upon building my project, another issue pop-up, NDK version not found. Instead of downloading the required NDK, I removed/renamed the NDK directory/folder from my Android SDK directory/folder.
Hope this steps helps.
I am trying to run a Gradle Android task generated by libGDX utility (the desktop task runs fine) in IntelliJ IDEA, but I'm only getting this nonspecific error message. What is the issue, or where are the logs, or how to enabled logs?
Information:Gradle: Executing tasks: [:core:assemble, :android:assembleDebug]
Information:24. 10. 2015 16:58 - Compilation completed with 1 error and 0 warnings in 9s 415ms
Error:Gradle: Execution failed for task ':android:proguardDebug'.
> java.io.IOException: Please correct the above warnings first.
PS: Not sure if it is relevant, but I have modified build files and ProGuard file to support Scala as described there.
I did not find a way of getting any useful logs from IntelliJ IDEA. I solved the problem by running Gradle from console.
gradlew assemble --stacktrace --info
Problem was Gradle could not find tools.jar. Adding system environment variable JAVA_HOME pointing to Java SDK directory fixed the issue.