RocketChat / Rocket.Chat.ReactNative

Rocket.Chat mobile clients
https://rocket.chat
MIT License
1.96k stars 1.15k forks source link

Whitelabel single-server android build fails #4838

Open victorhodi opened 1 year ago

victorhodi commented 1 year ago

Description:

I'm trying to build a whitelabel version. I've followed the instructions to build but i've ran into an error when I tried to run yarn android-whitelabel com.myapp.chat

`Error: Command failed: gradlew.bat app:installExperimentalPlayDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

2: Task failed with an exception.

BUILD FAILED in 2m 55s

at makeError (C:\Users\Admin\Desktop\app2\node_modules\execa\index.js:174:9)
at C:\Users\Admin\Desktop\app2\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Users\Admin\Desktop\app2\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\Admin\Desktop\app2\node_modules\@react-native-community\cli\build\index.js:192:9)

info Run CLI with --verbose flag for more details. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

./android/build.gradle `import org.apache.tools.ant.taskdefs.condition.Os

def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback }

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() def isPlay = !taskRequests.contains("foss") ext { buildToolsVersion = "31.0.0" minSdkVersion = 23 compileSdkVersion = 31 targetSdkVersion = 31 if (System.properties['os.arch'] == "aarch64") { // For M1 Users we need to use the NDK 24 which added support for aarch64 ndkVersion = "24.0.8215888" } else { // Otherwise we default to the side-by-side NDK version from AGP. ndkVersion = "21.4.7075529" } glideVersion = "4.11.0" kotlin_version = "1.6.10" kotlinVersion = '1.6.10' supportLibVersion = "28.0.0" libre_build = !(isPlay.toBoolean()) }

repositories {
    mavenLocal()
    google()
    maven {
        url 'https://maven.fabric.io/public'
    }
    mavenCentral()
}

dependencies {
    if (isPlay) {
        classpath 'com.google.gms:google-services:4.3.8'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
        classpath 'com.bugsnag:bugsnag-android-gradle-plugin:7.+'
        classpath 'com.google.gms:google-services:4.3.13'
    }
    classpath("com.android.tools.build:gradle:7.0.4")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("de.undercouch:gradle-download-task:4.1.2")
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

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") }

    maven {
        url "$rootDir/../node_modules/detox/Detox-android"
    }

    mavenCentral {
        content {
            excludeGroup "com.facebook.react"
        }
    }

    google()
    maven { url 'https://maven.google.com' }
    maven { url 'https://www.jitpack.io' }
}

}`

i dont need to upload my app in google play store. how can i disable this plugin?

Environment Information:

Steps to reproduce:

  1. I installed node modules yarn install
  2. yarn android-whitelabel com.custom.customchat com.myapp.chat

Expected behavior:

Actual behavior:

Additional context:

christoph2806 commented 1 year ago

I have the same / a similar problem: Build fails on a Linux 20.4 machine 1) I get this but I'm not sure if it's related:

warn Package @rocket.chat/message-parser has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /home/christoph/Documents/sandbox/rocketchat/Rocket.Chat.ReactNative/node_modules/@rocket.chat/message-parser/package.json

2) $ yarn android failed with this:

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/christoph/Documents/sandbox/rocketchat/Rocket.Chat.ReactNative/android/local.properties'.

I fixed this by setting sdk.dir = /home/christoph/Android/Sdk in /android/local.properties

3) $ yarn android failed again, this time with:

...

> Task :app:processExperimentalPlayDebugGoogleServices FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
...

* What went wrong:
Execution failed for task ':app:processExperimentalPlayDebugGoogleServices'.
> No matching client found for package name 'chat.rocket.reactnative'

(and some more errors)

UPDATE: I solved this by providing the APPLICATION_ID in the android/gradle.properties file. It has to be consistent with the android/app/google-services.json