React-native-code-push: Android: App crash on first update

Created on 28 Mar 2017  路  15Comments  路  Source: microsoft/react-native-code-push

Android, App crashes after downloading first update. iOS everything forks great.

Update for android generated with: code-push release-react APP android
react-native-code-push: v1.17.3-beta

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                Process: com.rmt, PID: 16887
                                                                java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                    at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                    at java.lang.Thread.run(Thread.java:818)
                                                                 Caused by: com.microsoft.codepush.react.CodePushUnknownException: Error in getting binary resources modified time
                                                                    at com.microsoft.codepush.react.CodePush.getBinaryResourcesModifiedTime(CodePush.java:113)
                                                                    at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:231)
                                                                    at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:226)
                                                                    at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)聽
                                                                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)聽
                                                                    at java.lang.Thread.run(Thread.java:818)聽
                                                                 Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
                                                                    at android.content.res.Resources.getText(Resources.java:312)
                                                                    at android.content.res.Resources.getString(Resources.java:400)
                                                                    at com.microsoft.codepush.react.CodePush.getBinaryResourcesModifiedTime(CodePush.java:110)
                                                                    at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:231)聽
                                                                    at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:226)聽
                                                                    at android.os.AsyncTask$2.call(AsyncTask.java:295)聽
                                                                    at java.util.concurrent.FutureTask.run(FutureTask.java:237)聽
                                                                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)聽
                                                                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)聽
                                                                    at java.lang.Thread.run(Thread.java:818)聽
waiting-for-clarification

Most helpful comment

    productFlavors {
        staging {
            ...
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            ...
        }
        production {
            ...
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            ...
        }
    }

In /android/app/build.gradle, I added this line resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())

All 15 comments

Hi @zeljkoX, could you please verify if CODE_PUSH_APK_BUILD_TIME key value is in resources.arsc file?
You can find it like this:
image
In case you would not be able to find that value please try to re-install react-native-code-push module and then re-build your app.

Please let me know if you have any questions.

Thanks for quick answer. I have checked for CODE_PUSH_APK_BUILD_TIME and it wasn't there. Reinstalled and relinked react-native-code-push and now it works.

I'm seeing this issue when building the Android build with buck. Any idea if there's a way to fix that? CODE_PUSH_APK_BUILD_TIME is missing from the debug apk.

I've just got same issue here.
Here is my dependency :

"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-code-push": "^2.0.3-beta",
"react-native-sqlite-storage": "^3.3.1",
"react-native-macos": "0.12.0"

I don't see CODE_PUSH_APK_BUILD_TIME in my output apk. I've also tried del node_modules & npm install & clean & rerun but not work.

Hi @jsierles, sorry for late reply, do you still experiencing the issue?

Hi @youngcube, thanks for reaching us, could you please double check if codepush.gradle file inside your's node_modiles/react-native-code-push/android folder contains this line?

@sergey-akhalkov Yes.
image

I still have the issue with buck. With gradle it works fine.

@youngcube, got it. If I get it right you've created new issue here https://github.com/Microsoft/react-native-code-push/issues/873, so I was able to reproduce it using your example app and currently investigating it.

@sergey-akhalkov Right. Hope this can help. Thanks !

@jsierles, could you please create new issue and provide us more info by filling issue template or you could look at #873 and verify if you have the similar use case as there.

@jsierles, please also look at https://github.com/Microsoft/react-native-code-push/issues/873#issuecomment-306776546 - it could help.

    productFlavors {
        staging {
            ...
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            ...
        }
        production {
            ...
            resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
            ...
        }
    }

In /android/app/build.gradle, I added this line resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())

Hello @Martian2Lee I am also facing the same issue. I am getting error as 'Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition' My app is already live. I already did 4-5 times code-push to update the app functionality for Android. Now I have added auth, share functionality in the app. But currently I commented the code. But auth, share package is already there is node_modules. Is addition of new package giving me this issue ?

debug {
...
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
...
}
release {
...
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
...
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Adr1ann picture Adr1ann  路  3Comments

quanzaiyu picture quanzaiyu  路  3Comments

vira-khdr picture vira-khdr  路  3Comments

chrisjrex picture chrisjrex  路  4Comments

Fuhrmann picture Fuhrmann  路  3Comments