flexn-io / renative

🚀🚀🚀 Unified Development Platform for iOS, tvOS, Android, Android TV, Android Wear, Web, Tizen TV, Tizen Watch, Tizen Mobile, LG webOS, macOS/OSX, Windows, KaiOS, FirefoxOS Firefox TV platforms
https://renative.org
MIT License
1.82k stars 180 forks source link

How to alter settings.gradle through renative.json #1247

Closed VMBindraban closed 2 months ago

VMBindraban commented 11 months ago

I am trying to add codepush but it requires some install steps. The documentation doesn't state anything about altering the settings.gradle and the existing plugins don't alter the settings.gradle to act like an example.

        "react-native-code-push": {
            "android": {
                "app/build.gradle": {
                    "apply": [
                        "from: \"{{PLUGIN_ROOT}}/codepush.gradle\""
                    ]
                },
                "settings.gradle": {
                    "project": [
                        "project(':react-native-code-push').projectDir = new File(\"{{PLUGIN_ROOT}}/android/app\")"
                    ],
                    "include": [
                        "':react-native-code-push'"
                    ]
                },
                "package": "com.microsoft.codepush.react.CodePush",
                "path": "{{PLUGIN_ROOT}}/android",
                "projectName": "react-native-code-push"
            },
            "version": "^8.1.0"
        },
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 resolve project :react-native-code-push.
     Required by:
         project :app
      > No matching configuration of project :react-native-code-push was found. The consumer was configured to find a component for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2' but:
          - None of the consumable configurations have attributes.
RicardasN commented 5 months ago

Hello, sorry for the somewhat late response, but the feedback was noted. We will add this functionality in release 1.0 of renative in a similar way to what was suggested - https://github.com/flexn-io/renative/pull/1563

However, if for any reason a newer version of the project cannot be used, I'd recommend using overrides to inject the needed functionality manually. More specifically you can create a settings.gradle file in appConfigs/base/builds/android. That will override anything renative tries to generate on a recreation of the project. However, do be aware, that in such case if you will plan to opt for a newer version of renative or change anything else, the newer changes will not be propagated and your provided settings.gradle will be used.