React native Android Generate Signed APK giving Resource error - javascript

I have completed my android project on React Native and finding this error while compiling the project for Signed Apk.
> Task :react-native-video:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
/Users/kedardave/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/e10f37597a16932be24db019d75c890a/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
/Users/kedardave/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/e10f37597a16932be24db019d75c890a/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.
/Users/kedardave/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/e10f37597a16932be24db019d75c890a/res/values-v26/values-v26.xml:17:5-93:AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
/Users/kedardave/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/e10f37597a16932be24db019d75c890a/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontStyle not found.
/Users/kedardave/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/e10f37597a16932be24db019d75c890a/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/font not found.
/Users/kedardave/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/e10f37597a16932be24db019d75c890a/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontWeight not found.
error: failed linking references.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-keep-awake:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* 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 2m 42s
132 actionable tasks: 100 executed, 32 up-to-date
These are the problems I am getting, these are about resources and I don't know how to resolve it. It seems like Version issue with targetSDK but can't figure out

Change supportLibVersion of build.gradle of your project to 27.1.1
Edit
How about adding below code to build.gradle of project,
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion "27.1.1"
}
}
}
}

Related

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception

How can i fix this issue in my code? does anyone can help me how can I fix this error I am using latest version of react native I installed the project yesterday only but still its giving me this error came after i installed a package called "react-native-vision-camera" you can check that here https://mrousavy.com/react-native-vision-camera/docs/guides/ i followed every step but still this error came.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
project ':react-native-vision-camera' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30
* 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.
BUILD FAILED in 36s

React Native Task :app:installDebug FAILED [duplicate]

This question already has answers here:
react-native :app:installDebug FAILED
(35 answers)
Closed 8 days ago.
i'm trying to create a new app with react native. i was using android studio emulator and now i installed genymotion. whatever when i started the app i encounted an error. react native version is 0.69.4.
> Task :app:installDebug FAILED
Skipping device 'Custom - 4.4.4' for 'app:debug': minSdkVersion [21] > deviceApiLevel [19]
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
147 actionable tasks: 2 executed, 145 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to install on any devices.
* 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
BU?LD FAILED in 31s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to install on any devices.
* 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
BU?LD FAILED in 31s
at makeError (C:\Users\Egehan Berker\Desktop\poemtra\poemtra\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Egehan Berker\Desktop\poemtra\poemtra\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\Egehan Berker\Desktop\poemtra\poemtra\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\Egehan Berker\Desktop\poemtra\poemtra\node_modules\#react-native-community\cli\build\index.js:192:9)
min sdk version is 21 and compileSdkVersion is 31. what should i do?
The minSdkVersion of your app is API Level 21 ( Android 5.0 ). It caused an error because you are trying to install the app on a device with API Level 19 (Andriod 4.4.4)
You can try to lower your minSdkVersion to API Level 19 (Android 4.4.4) on android/build.gradle or install your app on the emulator Android > 5.0.

Does react-native support jdk 17?

So I have been having some problems with launching the initial react-native template project on android. And after consulting someone I was told that jdk 17 is not supported. But I really don't want to downgrade as this could break other things that I already have and work with. To be specific this is the error I get:
> Task :app:processDebugMainManifest FAILED
11 actionable tasks: 2 executed, 9 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #7ec6bc9b
* 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 20s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #7ec6bc9b
* 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 20s
at makeError (C:\Users\karti\Desktop\ShoppingList\node_modules\execa\index.js:174:9)
at C:\Users\karti\Desktop\ShoppingList\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\karti\Desktop\ShoppingList\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid at async Command.handleAction (C:\Users\karti\Desktop\ShoppingList\node_modules\#react-native-community\cli\build\index.js:192:9)
I have looked at this already and nothing worked.
Gradle: Execution failed for task ':processDebugManifest'
So I solved this issue by installing JDK 16 on my system and everything is solved and running fine. I don't know if the problem was with Gradle or JDK or react-native but hope that in the future jdk 17 is supported.
If you have the same issue then you can go to:
jdk 16
1)Download and Install the JDK 16.
2)Add the path to your jdk in the PATH in your system environment variable.
3)Open cmd and do java -version you should see something like
java version "16.0.2" 2021-07-20
Java(TM) SE Runtime Environment (build 16.0.2+7-67)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)
To know if this is a java version-related issue, You need to check your Gradle version.
currently only Gradle version 7.3 support java 17.
You can check gradle compatibility matrix to check.
you can check your version with the command line by typing gradlew.bat -version
If your Gradle is version 7.3 then it has nothing to do with the JDK version.

Could not build project

When I tried to build this project, I get this error printed in my console.
But, when I try building other projects, no error happens. Why is that?
Everything was working fine 2 days ago.
Here is the error,
unning "flutter pub get" in SampleApp...
Launching lib\main.dart on Android SDK built for x86 in debug mode...
/E:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.0/lib/src/top_level.dart:1:8: Error: Not found: 'dart:html'
import 'dart:html';
^
/E:/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/js.dart:8:1: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;
^
/E:/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/js_util.dart:8:1: Error: Not found: 'dart:js_util'
export 'dart:js_util';
^
/E:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {
^^^^^^^^^^^^^^^^^^^
/E:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found.
abstract class PictureStreamCompleter with DiagnosticableMixin {
^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'E:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 896
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'E:\flutter\bin\flutter.bat'' 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 4m 13s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I tried running flutter clean, but it didn't help.
It happened because of the 'firebase' package.
i think there are some errors in it.

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

I had a third-party dependency (react-native-admob) which specified in its build.gradle file the following: com.google.android.gms:play-services-ads:+. Taking a look over at the Google Android APIs release notes page, there were breaking updates to the whole com.google.android.gms group of APIs on 17th June 2019.
I run './gradlew assembleDebug' got error:
/Users/yons/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/8cb1ac92f08bb5fb26b003aaf1d22a69/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/yons/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/8cb1ac92f08bb5fb26b003aaf1d22a69/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/ttcIndex not found.
To fix my issue, I added the following to my android/app/build.gradle file:
configurations.all {
resolutionStrategy.force 'com.google.android.gms:play-services-ads:17.2.1'
}
Now, I run './gradlew assembleDebug' works fine.
But I run './gradlew assembleRelease' got an error:
/Users/yons/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/8cb1ac92f08bb5fb26b003aaf1d22a69/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/yons/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/8cb1ac92f08bb5fb26b003aaf1d22a69/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-admob:verifyReleaseResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
How can I solve it?
The root cause is related migration to Androidx, google play service updated to androidX
This problem belongs to react-native-device-info? best option is to upgrade react-native-device-info using
yarn upgrade react-native-device-info#2.1.2
cd android && gradlew clean
react-native run-android
After which you either change it like explained in the answer above. like so
implementation(project(":react-native-admob"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-ads:16.0.0"

Categories