react-native-mauron85-background geolocation error - react-native

The following error appears when try to build my react native for production (running ./gradlew assembleRelease),
...
/node_modules/react-native-mauron85-background-geolocation/android/common/src/oreo/java/com/marianhello/bgloc/NotificationHelper.java:4: error: cannot find symbol
import android.app.NotificationChannel;
^
symbol: class NotificationChannel
location: package android.app
...
Execution failed for task ':react-native-mauron85-background-geolocation-common:compileOreoReleaseJavaWithJavac'
Anybody encountered this error before?

Just adding what solved my problem in case anyone is having the same problem.
After tearing off a lot of hairs (although I lack it) I came to a solution. Not sure whether is gonna work for others, you can give it a try.
Add following codes in android/build.gradle
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://maven.google.com" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "26.0.2"
supportLibVersion = "26.1.0"
googlePlayServicesVersion = "11.8.0"
}
And make sure the dependencies are installed.

Related

React-native Expo Build Failed : Task :app:checkDebugDuplicateClasses FAILED [duplicate]

Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.3.31 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31)
Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.3.31 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31)
**./gradlew clean **
build.gradle file:
buildscript {
ext {
buildToolsVersion = "30.0.0"
minSdkVersion = 23
compileSdkVersion = 33
targetSdkVersion = 30
googlePlayServicesAuthVersion = "16.0.1"
kotlinVersion = "1.8.0"
}
firebase: [
bom : "26.0.0"
]
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath "com.google.gms:google-services:4.3.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
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 {
repositories {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
mavenLocal()
maven {
url("$rootDir/../node_modules/react-native/android")
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
maven { url 'https://maven.google.com' }
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
I had the same problem with my app. It failed to build because of duplicate classes found in modules jetified-kotlin-stdlib-1.8.0 and jetified-kotlin-stdlib-jdk8-1.6.10
With the link, shared by Igor VANIAN : https://kotlinlang.org/docs/whatsnew18.html#usage-of-the-latest-kotlin-stdlib-version-in-transitive-dependencies
I added
dependencies {
...
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
}
to my android/app/build.gradle and Android builds fine now
I started having the same issue in react native native on the android side. I upgraded Kotlin to version 1.8.0 and built the app again and the issue was fixed. Maybe trying upgrading the kotlin version.
In android/build.gradle update the following
kotlinVersion = "1.8.0"
and add this under dependencies
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
This can happen when you're using different versions for different Kotlin dependencies.
Try to check all Kotlin dependencies. In my case, issue was with this core-ktx
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Updating to this resolved issue
implementation "androidx.core:core-ktx:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Here kotlin_version = '1.7.0'. You can use your desired version.
Hope this will help others.
I was having the same problem since yesterday.
I found that the reason behind this could be the artifact merge in Kotlin 1.8.0. Here is an issue talking about this breaking change.
So setting kotlinVersion = "1.8.0" as #Narasimha said works. But I still didn't figure out what dependency changed overnight that somehow made kotlin-stdlib:1.8.0 appear in the build logs.
Thanks all, I solve it by doing two things
In android/build.gradle update the following
kotlinVersion = "1.8.0"
In android/app/build.gradle add the following in dependencies
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
I had the same issue today and I fixed it in a different way, if it helps anyone:
When I upgraded my kotlin to version 1.8 it started happening and I had to change my hilt version to 2.44. Now it's running normally.

Execution failed for task ':app:checkDebugAarMetadata'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'

I am facing this problem, I try Multiple solutions but no luck
My build.gradle file consist
compileSdkVersion = 30
targetSdkVersion = 30
I also add following lines in build.gradle
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
also, try these
https://exerror.com/solved-execution-failed-for-task-appcheckdebugaarmetadata/
also, install node_mudule much time
also reset cache and Gradle clean but found no luck
if anyone has any solution please update me
I was also faced with this problem,When I changed position of maven { url "https://jitpack.io"} from below to up and add maven { url "https://maven.google.com"}
Then the problem disappear.
allprojects {
repositories {
mavenLocal()
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
google()
jcenter()
}
}
uninstall the last package you added to your project npm uninstall <package-name>
and then run again.

Android: AIRMap was not found in the UIManager

So i'm trying to implement a map view in my react native app, using react-native-maps. When i'm installing it with npm it's all good, and linking it makes no errors. The problem is when i try to run it, then I get the
Invariant Violation: requireNativeComponent: "AIRMap" was not fount in the UIManager.
I've narrowed it down to being on the Android side, since that's the emulator i'm running. For some reason, the gradle files seems broken and I have no idea of what it can be. I've tried most guides i've found but none seems to handle the issue. I've tried to link it manually, remove the link and so on. I've also tried adding the direct link to GitHub which doesn't solve it either.
Some build info:
React version: 0.60.0
Gradle version: 5.4.1
Emulator version: Pie API 28
settings.gradle:
rootProject.name = 'ProjectName'
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)
include ':app'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
build.gradle:
implementation 'com.facebook.react:react-native:+
implementation project(':react-native-maps')
MapView:
import MapView from 'react-native-maps'
<MapView
region={{
latitude: 42.882004,
longitude: 74.582748,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
></MapView>
Lastly, I have also created an API to Google maps in the android project.
The project is manageable to recreate by initiating a new react-native project and implementing react-native-maps
For Android
AndroidManifest.xml
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzDDDBBLn-PhCtBM1AnC_h66yH8Lw2DDD14WW0"/>
</application>
MainApplication.java
import java.util.List;
import com.airbnb.android.react.maps.MapsPackage; // <-- Add this line
...
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new MapsPackage()); // <- ADD THIS LINE
return packages;
}
android/settings.gradle
if you are not using monorepo technique
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-maps/lib/android')
android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
supportLibVersion = '28.0.0'
playServicesVersion = "17.0.0" // or find latest version
googlePlayServicesVersion = "17.0.0" // or find latest version
androidMapsUtilsVersion = "2.2.3"
}
repositories {
jcenter()
google() // keep google() at last
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../../../node_modules/jsc-android/dist")
}
jcenter()
maven { url 'https://www.jitpack.io' }
google() // keep google() at last
}
}
android/app/build.gradle
dependencies {
...
implementation project(':react-native-maps') // at last
}
Notes
I am using ../../../node_modules because I am using Monorepo technique to maintain 2 apps in one git repo
../node_modules might work for you
keep google() at last of the code-block
IOS
See this for solution in IOS https://stackoverflow.com/a/67945288/3437900

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?

How to fix missing ReactContextBaseJavaModule symbol?

I wan't to create a custom native module for my app only - so no lib. Following the docs it gives me an error:
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Cannot resolve symbol 'ReactContextBaseJavaModule'
My app's android/app/build.gradle includes this line, which is included in all react-native modules I have used so far as well.
"com.facebook.react:react-native:+" // From node_modules
My android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}
}
Below are the steps I encountered and used to solve importing all the libraries related to React Native Libraries in the Android Studio:
First when I created a brand new react native library project using react-native-create-library command, the command generated iOS and Android files.
I opened the android folder using Android Studio.
The gradle build reported some errors and fixed the gradle issue by updating some values in build.gradle and gradle-wrapper.properties.
build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile 'com.facebook.react:react-native:+'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
After adding the above 2 changes, Click Sync Now or Try again. In this step if it asks to install the build version, please install.
Now Clean and Rebuild the project, On top status bar of the Android Studio:
Click Build --> Clean Project then
Click Build --> Rebuild Project
After step #5, React Native import errors should disappear and the libraries related to React Native must be imported.
Thanks.