using react-native build android apk - react-native

i build react-native for android apk has error, need you help!
error info:
C:\Users\Chris.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\5934c37098d7fc1d388cdfd621f50e8f\res\values-v24\values-
v24.xml:3:5-157: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Mater
ial.Widget.Button.Borderless.Colored'.
C:\Users\Chris.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\5934c37098d7fc1d388cdfd621f50e8f\res\values-v24\values-
v24.xml:4:5-135: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Mater
ial.Widget.Button.Colored'.
C:\Users\Chris.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\5934c37098d7fc1d388cdfd621f50e8f\res\values-v26\values-
v26.xml:13:5-16:13: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processReleaseResources'.
Failed to process resources, see aapt output above 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 ge
t full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1m 50s
94 actionable tasks: 2 executed, 92 up-to-date
config info :
...
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.helloworld"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
manifestPlaceholders = [
JPUSH_APPKEY: "01e91c7c174c2c6888228f25",
APP_CHANNEL : "default"
]
...
ndk {
abiFilters "armeabi-v7a", "x86"
}
}

Related

Getting an error with react-native-safe-area-context build.gradle file and compileSdkVersion is not specified

I am getting this Error message while building my react native project.
BUILD FAILED in 4s
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 completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\sawan\OneDrive\Desktop\Unsplash\app\node_modules\react-native-safe-area-context\android\build.gradle' line: 28
* What went wrong:
A problem occurred evaluating project ':react-native-safe-area-context'.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-safe-area-context'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
* 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.
==============================================================================
Its saying error is in this file:
C:\Users\sawan\OneDrive\Desktop\Unsplash\app\node_modules\react-native-safe-area-context\android\build.gradle
//rest of the code ...
android {
compileSdkVersion getExtOrDefault('compileSdkVersion', 30)
// Used to override the NDK path/version on internal CI or by allowing
// users to customize the NDK path/version from their root project (e.g. for M1 support)
if (rootProject.hasProperty("ndkPath")) {
ndkPath rootProject.ext.ndkPath
}
if (rootProject.hasProperty("ndkVersion")) {
ndkVersion rootProject.ext.ndkVersion
}
defaultConfig {
minSdkVersion getExtOrDefault('minSdkVersion', 16)
targetSdkVersion getExtOrDefault('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
ndk {
abiFilters (*reactNativeArchitectures())
}
}// rest of the code ....
Here is my build.gradle file from \android
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
// kotlin_version = '1.5.20' //
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") //
}}
Don't know if error is in this path or the build.gradle file

Expo Eas: fail exporting

I have resumed a project that I started a few months ago, an app that I am building in react native. The problem is that when going to compile it told me that I had to update to eas. I have updated and now when trying to do a build it tells me:
[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/node_modules/#unimodules/core/android/build.gradle' line: 3
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':unimodules-core'.
[stderr] > Plugin with id 'maven' not found.
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] A problem occurred configuring project ':expo'.
[stderr] >
[stderr] compileSdkVersion is not specified. Please add it to build.gradle
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 1m 43s
my code in build.gradle is the following (I've already changed the maven call to maven-publish but it's still the same):
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
group = 'org.unimodules'
version = '6.7.1'
buildscript {
// Simple helper that allows the root project to override versions declared by this library.
ext.safeExtGet = { prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:6.7.1'
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
}
}
//Upload android library to maven with javadoc and android sources
configurations {
deployerJars
}
//Creating sources with comments
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
//Put the androidSources and javadoc to the artifacts
artifacts {
archives androidSourcesJar
}
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: mavenLocal().url)
}
}
}
android {
compileSdkVersion safeExtGet("compileSdkVersion", 30)
buildToolsVersion safeExtGet("buildToolsVersion", 30)
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 21)
buildToolsVersion "30.0.1"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
compileSdkVersion 30
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 30)
consumerProguardFiles 'proguard-rules.pro'
versionCode 20
versionName "7.1.2"
minSdkVersion 21
targetSdkVersion 30
buildToolsVersion "30.0.1"
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
}
Do you know how I can solve it? Thanks.

Execution failed for task ':app:bundleReleaseJsAndAssets'. when running expo EAS services

When I try to build my expo react native app using expo EAS services I get this error as follows,
Please consult deprecation warnings for more details.
426 actionable tasks: 426 executed
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:bundleReleaseJsAndAssets'.
[stderr] > Process 'command 'node'' finished with non-zero exit value 1
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 3m 8s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
my eas.json looks like this,
{
"cli": {
"version": ">= 2.4.1"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"android": {
"image": "ubuntu-18.04-jdk-11-ndk-r19c"
}
},
"preview": {
"distribution": "internal"
},
"production": {
"android": {
"buildType": "apk"
}
}
},
"submit": {
"production": {}
}
}
my app configuration is as follows,
minSdkVersion = '21'
buildToolsVersion = '31.0.0'
compileSdkVersion = '33'
targetSdkVersion = '33'
I'm trying to generate an apk here.
Can someone help, please
The real cause of the issue should be logged somewhere above

Cannot compile react-native-expo project

So i have a bare react-native application wherein i am using expo modules.
I am using the expo location module and getting the following error.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:361: error: cannot find symbol
new Permissions.PermissionsRequestListener() {
^
symbol: class PermissionsRequestListener
location: interface Permissions
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:502: error: cannot find symbol
mPermissions.getPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
^
symbol: method getPermission(String)
location: variable mPermissions of type Permissions
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:503: error: cannot find symbol
&& mPermissions.getPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
^
symbol: method getPermission(String)
location: variable mPermissions of type Permissions
Note: /home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/taskConsumers/GeofencingTaskConsumer.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':expo-location: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
BUILD FAILED in 16s
at checkExecSyncError (child_process.js:607:13)
at execFileSync (child_process.js:627:13)
at runOnAllDevices (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at buildAndRun (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7);
So my best guess is there is an error while importing stuff from permission module.
So i have these lines in expo-permissions app level build.gradle file.
compileOnly('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
I am also using jettifier, i am guessing there is some issue with respect to transpiling code to android x.
I changed this
compileOnly('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
to
implementation 'com.facebook.react:react-native:+'
and everything works fine.
I would like to know exactly what is happening and if this deserves a pull request.
Any help on the same would be highly appreciated thanks.
ok, in my case I needed to raise the following versions from android/build.grade:
buildscript {
ext {
buildToolsVersion = "28.0.3" -> "29.0.2"
minSdkVersion = 21
compileSdkVersion = 28 -> 29
targetSdkVersion = 28 -> 29
}

Compile error while react-native-maps building

I'm new to react-native and I'm keeping getting an error while trying to build with react-native-maps.
Steps I made:
react-native init --version="0.57.4" <my_app_name>
cd <my_app_name>
react-native install react-native-geocoder
react-native install react-native-maps
react-native run-android
Error message:
> Task :react-native-maps:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.v4.app.ActivityCompat
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
Following instructions from #samitha-nanayakkara, I've reached this issue, I did try to delete the build directories each time and edit android/app/build.gradle like:
defaultConfig {
...
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
That give me the error message:
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.v4.app.ActivityCompat
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
Also, trying Java 8 give me the same result:
defaultConfig {
...
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Adding multiDexEnabled true to android/app/build.gradle give me another error message:
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.
How could I solve this?