Compile error while react-native-maps building - react-native

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?

Related

FAILURE: Build failed with an exception. Could not find com.airbnb.android:lottie:5.1.4 for rn0.70.6

FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
Could not find com.airbnb.android:lottie:5.1.4.
Required by:
My package.json
enter image description here
build.gradle
enter image description here
gradle.properties
enter image description here
I tried to build react native android apk file with command:
cd android
./gradlew clean
./gradlew build
I want to build the file android apk, Please help,
Thank you everyone.
android/build.gradle
add this line to build.gradle and try again
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
if you don't understand this here you can see all chat I have same issue but I add this line to build file and it's working for me
hope this will help you!

KMM in Android Studio build return Command PhaseScriptExecution failed with a nonzero exit code

I've just created a new KMM project through out KMM Plugin, but I can't run or even debug in Xcode iosApp part of the project. When I try to run iosApp from Android Studio, the build process fails (Command PhaseScriptExecution failed with nonzero exit code)
The final lines of building was:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':shared:compileKotlinIosX64'.
Compilation finished with errors
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
1 actionable task: 1 executed
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/tamegajr/AndroidStudioProjects/TesteKMM5/build/ios/iosApp.build/Release-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh
(1 failure)
Can anyone help to solve this problem?
I had the same issue but this solution helped me:
From KMM pluging you will obtain (on dependencies):
Change this:
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
To this:
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
What i found to be the solution was to uncomment the "iosSimulatorArm64()" in the "build.gradle.kts(:shared)".
kotlin {
android()
iosX64()
iosArm64()
iosSimulatorArm64() //sure all ios dependencies support this target
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosLink/Podfile")
framework {
baseName = "shared"
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
}
}
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosX64Test by getting
val iosArm64Test by getting
//val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
//iosSimulatorArm64Test.dependsOn(this)
}
}
}
After some code review from 2-3 months old KMM examples project and comparing them with new ones, I found out a solution for this build failure when trying to run iosApp on Ios Simulators, just apply this change to build.gradle.kts on root project:
From KMM pluging you will obtain (on dependencies):
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
Change it to:
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
And that's it, problem solve. I hope someone on Jetbrains can solve this problem in future updates of KMM plugin.
08/30/2020:
It seems that Jetbrains has correct some issues and now you can build and run a KMM project with version 1.7.10, the last stable version at this time.
By the way, if you have any trouble is worthy to check this stack overflow post about JDK version used by Android Studio : How to set or change the default Java (JDK) version on macOS?
Multiplatform error when building iosApp: Command PhaseScriptExecution failed with a nonzero exit code

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
}

Unable to delete file: androidx.databinding.library.baseAdapters--setter_store.json

What is this error with databinding in Kotlin + Android Studio?
> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :clean
> Task :app:clean FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:clean'.
> Unable to delete file: C:\MyFolder\app\build\intermediates\data_binding_dependency_artifacts\debug\dataBindingMergeDependencyArtifactsDebug\out\androidx.databinding.library.baseAdapters--setter_store.json
Ending Process in Windows resource monitor, gradlew clean, or invalidating cache and restarting clears it but it creeps right back on the second build/clean attempt.
My app build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
...
}
My project build.gradle
buildscript {
ext.kotlin_version = '1.3.21'
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}

Why am I getting this error in react native?

I am new to react native. When I run react-native run-android I get this error.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Stay Hungry\app developement\Aarogya\node_modules\react-native-share\android\build.gradle' line: 53
* What went wrong:
A problem occurred evaluating project ':react-native-share'.
> Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7 mins 24.686 secs
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
I traced the path to the error location and my build.gradle is below:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet('compileSdkVersion', 27)
buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 27)
versionCode 1
versionName "1.0.0"
}
lintOptions {
abortOnError false
warning 'InvalidPackage'
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
jcenter()
}
dependencies {
compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '27.1.0')}"
}
I have no idea what is wrong here. I have not even started writing code in app.js yet. I am using a physical device to run the code with an adb device.
The error you are getting is from the library react-native-share.
Did you follow the instructions to installing it right?