I am using Android Studio & Gradle build script.
Under the root of my Android project, there is a folder named 'other', inside 'other' folder, there is a properties file my.properties.
-MyApp/
…
-other/
-my.properties
-build.gradle
In my build.gradle, I try to access my.properties :
task accessMyProperties {
def folderName = 'other';
//Gradle complains this line
def file = new File("$folderName/my.properties");
...
}
But gradle complains that:
* What went wrong:
A problem occurred evaluating project ':MyApp'.
> other/my.properties (No such file or directory)
Why gradle arises the above error? How to get rid of it?
The Wrapper shell script and batch file reside in the root directory of a single or multi-project Gradle build. You will need to reference the correct path to those files in case you want to execute the build from a subproject directory e.g. ../../gradlew tasks .
To clean cache in react native, open terminal, go to your project android folder, and run gradlew clean command it will clear react native cache.
Be careful about using pure relative paths in Gradle build scripts; those rely on the working directory at the time the build is invoked, which isn't something you should depend on. It's much better to ground your paths against $projectDir
or $rootDir
. Try something like this:
def file = new File("$projectDir/$folderName/my.properties");
See http://www.gradle.org/docs/current/dsl/org.gradle.api.Project.html for a list of variables you can use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With