Codepush was working until recently. Seems it was likely the update to RN 0.63.3 or Android Gradle plugin 4.1+.
What actually happens?
2020-10-16 18:10:51.465 21369-21437/com.whetware.taskhero E/ReactNative: [CodePush] Exception
com.microsoft.codepush.react.CodePushUnknownException: Error in getting binary resources modified time
at com.microsoft.codepush.react.CodePush.getBinaryResourcesModifiedTime(CodePush.java:207)
at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:289)
at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:284)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:444)
at android.content.res.Resources.getString(Resources.java:537)
at com.microsoft.codepush.react.CodePush.getBinaryResourcesModifiedTime(CodePush.java:204)
at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:289)Â
at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:284)Â
at android.os.AsyncTask$3.call(AsyncTask.java:394)Â
at java.util.concurrent.FutureTask.run(FutureTask.java:266)Â
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)Â
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)Â
at java.lang.Thread.run(Thread.java:923)Â
Will update with repro when available
I added the following to my android/app/build.gradle and it work as a workaround. I'm guessing this is likely an android gradle plugin issue. There seem to be a bunch of undocumented breaking changes in AGP 4.1+ that affect React Native.
under android { defaultConfig { I added
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
Hi @AndrewMorsillo ,
Thanks for reporting!
Could you please provide a demo project?
Sorry but I likely won't have time to make a reproduction anytime soon.
I think this is probably reproducible by upgrading any react native project with codepush to android gradle plugin 4.1+.
Hi @AndrewMorsillo could you please double-check that the following step is performed in your app:
- In your
android/app/build.gradlefile, add thecodepush.gradlefile as an additional build task definition underneathreact.gradle:... apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/react-native-code-push/android/codepush.gradle" ...?
Also please take a look at this issue: #1046
@ruslan-bikkinin Yes, I have the gradle plugin applied correctly. I had been using code push without issue for many months in my app. This suddenly broke when I updated to Android gradle plugin 4.1+. I did not change anything related to my code push configuration. I suspect you can reproduce this issue by upgrading any react native app to android gradle plugin 4.1+.
I found the workaround in this old issue: https://github.com/microsoft/react-native-code-push/issues/771
@AndrewMorsillo got it. Thanks for the info, we'll check it out.
Hi @AndrewMorsillo unfortunately, I couldn’t reproduce your issue on my side.
What I did:
build.gradle to enable 4.1.0 Android pluginbuildscript {
ext {
// ...
dependencies {
classpath(‘com.android.tools.build:gradle:4.1.0’)
}
}
distributionUrl in gradle/wrapper/gradle-wrapper.properties to use Gradle 6.5 (as it is minimum supported version for gradle plugin 4.1.0 as said in Android Plugin documentation page):distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
react-native run-androidDid you do any extra steps aside mine to migrate to Android Gradle plugin 4.1.0?
Also, you can try to reinstall and reconfigure react-native-code-push plugin.
I have the same issue after updating to com.android.tools.build:gradle:4.1.0 and gradle-6.5-all.zip.
Reverted to com.android.tools.build:gradle:3.6.3 and gradle-6.3-all.zip and will get back here after I'm sure this was the issue.
It work for me by reverting the gradle version.gradle-6.2-all.zip & com.android.tools.build:gradle:3.5.3
I confirm that the downgrade solved the issue.
@ruslan-bikkinin - in order for this to reproduce, I believe, you need to follow these steps:
What happened in our case is that we had version 1.1.6 live on the store (with the old gradle version plugin), which also had a codepush.
Then we released a new version (1.1.7), which included an update of the gradle plugin.
After the update, the app crashed immediately on pressing the app icon. We submitted a new 1.1.7 build, with the old gradle version, and this fixed the issue.
Hi @andiradulescu ,
It depends on target binary version of your update. If you have as 1.1 then it will be installed for all binary versions like 1.1.X. Could you please share your target binary version for your update?
Hi, we are planning to release a new version of our app and upgraded all the dependencies.
Gradle: 4.1.0
Codepush: 6.4.0
RN: 0.63.4
We decided to test the codepush before the release and getting the same error:
ReactNative: [CodePush] Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition.
ReactNative: com.microsoft.codepush.react.CodePushUnknownException: Error in getting binary resources modified time
ReactNative: at com.microsoft.codepush.react.CodePush.getBinaryResourcesModifiedTime(CodePush.java:207)
ReactNative: at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:289)
ReactNative: at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:284)
ReactNative: at com.microsoft.codepush.react.CodePush.getBinaryResourcesModifiedTime(CodePush.java:204)
Our version of the app: 2.0.0 and the target version is 2.0.0.
I can confirm that this works:
I added the following to my android/app/build.gradle and it work as a workaround. I'm guessing this is likely an android gradle plugin issue. There seem to be a bunch of undocumented breaking changes in AGP 4.1+ that affect React Native.
under
android { defaultConfig {I addedresValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
e.g.
defaultConfig {
.....
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}
Most helpful comment
I added the following to my android/app/build.gradle and it work as a workaround. I'm guessing this is likely an android gradle plugin issue. There seem to be a bunch of undocumented breaking changes in AGP 4.1+ that affect React Native.
under
android { defaultConfig {I added