Closed christian-hess-94 closed 3 months ago
post your two gradle files:
android/build.gradle
android/app/build.gradle
android/app/build.gradlew
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
// background-geolocation
Project background_geolocation = project(':react-native-background-geolocation-android')
apply from: "${background_geolocation.projectDir}/app.gradle"
/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
}
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:'
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "com.pocbackgroundlocation"
defaultConfig {
applicationId "com.pocbackgroundlocation"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion= "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
appCompatVersion = "1.4.2"
googlePlayServicesLocationVersion = "20.0.0"
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
allprojects {
repositories{
// Required for react-native-background-geolocation
maven { url("${project(':react-native-background-geolocation').projectDir}/libs") }
maven { url 'https://developer.huawei.com/repo/' }
// Required for react-native-background-fetch
maven { url("${project(':react-native-background-fetch').projectDir}/libs") }
}
}
maven { url("${project(':react-native-background-geolocation').projectDir}/libs") }
If you're installing from the private repo react-native-background-geolocation-android
, then that maven url needs to have -android
appended to it.
Also, why does your app/build.gradle
contain no references to background_geolocation
, as prescribed in the Setup Instructions linked in the README.
I suggest you go have a close look at the Android Setup Instructions.
Also, why does your app/build.gradle contain no references to background_geolocation
Correction, there it is. However, you're still missing entries prescribed by the Setup Instructions (eg: proguard-rules)
// background-geolocation Project background_geolocation = project(':react-native-background-geolocation-android') apply from: "${background_geolocation.projectDir}/app.gradle"
Your build.gradle files are confused between references to react-native-background-geolocation
(the public version from npm) and react-native-background-geolocation-android
(the private version).
They all need to match.
thanks I will give those a look. I had copied the setup from this section of the docs:
I don't think I'm installing it from the private repo, so I would have to change it in the
Project background_geolocation = project(':react-native-background-geolocation-android')
To
Project background_geolocation = project(':react-native-background-geolocation')
Also not sure if it's relevant but I don't have a license yet
This page https://github.com/transistorsoft/react-native-background-geolocation/blob/master/help/INSTALL-ANDROID-AUTO.md has instructions to add:
Project background_geolocation = project(':react-native-background-geolocation-android')
to android/app/build.gradle
If this is wrong, then the documentation needs to be updated.
Fixed;
include ':react-native-background-geolocation' project(':react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-geolocation/android')
include ':react-native-background-fetch' project(':react-native-background-fetch').projectDir = new File(rootProject.projectDir , './node_modules/react-native-background-fetch/android')
add this line in setting.gradle @christian-hess-94
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Your Environment
react-native -v
): 11.3.6Expected Behavior
The app should run after doing the installation according to the docs
Actual Behavior
App fails when executing
yarn start + A
oryarn android
with the following error:I have already triple checked the build.gradle files and they all seem to be correct. The project is not able to execute line 5 of app/build.gradle:
project(':react-native-background-geolocation-android')
I have checked inside the node_modules folder and the .iml file exists in there as per this screenshot
Steps to Reproduce
yarn start + A
(npm run start + A) oryarn android
(npm run android)Context
I was creating a POC to see if the plugin is easy to configure and install in the project I'm currently working at. Created a brand new RN project with
npx react-native init AppName --template react-native-template-typescript
and installed only itDebug logs (no logs were generated)
Logs
``` No logs are generated ```