Closed zoolle closed 3 years ago
@zoolle I was experiencing the same behavior when upgrading my app from rn0.61.0 to rn0.64.1
After some hours I've found here that From Android studio 3.3+ there is no need to add the code below to "gradle.properties" file.
android.enableUnitTestBinaryResources=true
So, I looked on the lib files and found that @mauron85/react-native-background-geolocation/android/common/gradle.properties
file has the following content:
android.enableUnitTestBinaryResources=true # our little monster breaking things here
android.builder.sdkDownload=true
To see if the error would go away I removed android.enableUnitTestBinaryResources=true
from the lib file on node_modules/@mauron85/react-native-background-geolocation/android/common/gradle.properties
and it worked!
I tried to fork and open a PR with that fix but got lost in how to build, test and contribute. There is no clear documentation of the process.
So, I wrote a bash script to remove that deprecated code:
# mauronAndroidFix.sh
# utility variables
gradlePropertiesWithDeprecatedOptionFile="node_modules/@mauron85/react-native-background-geolocation/android/common/gradle.properties"
deprecatedOptionOnNewerAndroidGradle="android.enableUnitTestBinaryResources=true"
newGradleContent="android.builder.sdkDownload=true"
echo "@mauron85/react-native-background-geolocation"
echo "starting hotfix script to correct Fail to build on Android with RN 0.64.1"
# Test if the deprecated command is still on that file
# in future releases this may be fixed and then the script does nothing
if grep -q 'android.enableUnitTestBinaryResources=true' "$gradlePropertiesWithDeprecatedOptionFile"; then
echo "The option 'android.enableUnitTestBinaryResources' is deprecated"
echo "It has been removed from the current version of the Android Gradle plugin"
echo "Removing deprecated instruction..."
# remove the deprecated option from commom/gradle.properties
echo $newGradleContent > $gradlePropertiesWithDeprecatedOptionFile
exit 0;
fi
Then, on package.json
set the script to run every time someone installs the projects dependencies:
// In package.json define postinstall
...
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"mauron-postinstall": "./mauronAndroidFix.sh", // add this line
"postinstall": "yarn mauron-postinstall", // and this line
"reset-cache": "react-native start --reset-cache"
}
...
I hope this helps! I would be nice if someone releases this fix or write some docs on how to contribute.
Thanks @quixote15 Your script can fix the problem. I hope maintainers remove deprecated codes and make a new release.
@quixote15 You are a legend. It's working perfectly. I will close this now and hope someone will make an update in a new version
On iOS everything works fine but while I am trying to build in Android following the documentation I get the following
Your Environment
Context
In android/settings.gradle
In android/app/build.gradle
in MainApplication.java
Expected Behavior
Actual Behavior