-
Notifications
You must be signed in to change notification settings - Fork 1.6k
addAndroidDownloads can't recognize Android APK file #75
Comments
@siyuan , thank you for reporting this problem, I've never tried download an APK using DownloadManager, I'll do some tests about this issue. |
@siyuan , according to this post and this StackOverflow, perhaps you can not install APK in Downloads App due to some security issue, but it is possible to do it using an intent. However user still have to change their settings, otherwise it will prompt something like this I've added a new API for Android which can send an intent that opens a file in an activity correspond to its MIME type (see test cases for its usage). This API will launch in |
@wkh237 Thank you very much for your help. I clone react-native-fetch-blob to node_modules of my project, and checkout to branch 0.9.0. I got this error when compiling: JS server already running. FAILURE: Build failed with an exception.
Is there any new configuration for version 0.9.0? |
@siyuan , the error message usually means Alternatively, you can install beta version from npm
Which will install |
"$ npm install --save react-native-fetch-blob@beta", this method doesn't work. the same as before. It seems that Downloads app can't recognize the new downloaded app. |
"copy src to node_modules and rename the folder to react-native-fetch-blob" doesn't work either. I use hardware Android 6.0, Android 6.0 simulator and Android 5.1 simulator do the test. None of them work. |
@siyuan , The error message means the path it points to does not contains an Android project. did you check rootProject.name = 'RNFetchBlobTest'
include ':app'
+include ':react-native-fetch-blob'
+project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android'')
In this case, there should be an Android project in As for the installation problem, after upgrade to 0.9.0-beta.x, you should use |
Thank you for your help. upgradeApp()
{
RNFetchBlob.config({
addAndroidDownloads : {
useDownloadManager : true,
mime : 'application/vnd.android.package-archive',
mediaScannable : true,
notification : true,
}
})
.fetch('GET', 'http://x.x.x.x/doc/abc.apk')
.then((res) => {
console.log('save to ' + res.path())
let sendIntent = RNFetchBlob.android.actionViewIntent
return sendIntent(res.path(), 'application/vnd.android.package-archive')
})
.then(() => {
done()
})
} I found the console output is "save to null". I think this is the problem. Why the path is null? |
Hi, @siyuan , does this happens on Android 6.0 only or it also happens on 5.x ? |
Hi, @wkh237 |
@siyuan , thanks for your information. I think I know where the problem is, I'll publish a test version later ! |
@siyuan , please try
Thank you 😄 |
@wkh237 0.9.0-beta.5's res.path() is null. Tested on 6.0 and 6.1. |
@siyuan , Since I don't have 6.0 + devices and I can't reproduce the problem on emulator, I'd like to know more information if you can give me a hand !
It would be nice if you have an Android IDE (Android Studio), you can set break points at the following lines see if they're executed and the value of |
@wkh237 I will study how to set breakpoint in Android Studio. |
Thank you ! @siyuan , this would be helpful, you can also use |
@wkh237 use res.data still cannot install by sendIntent. I have enabled "Unknown sources, Allow installation of apps from unknown sources" |
@siyuan , does it help if you reinstall the package ?
then recompile the project |
@wkh237 I found my issue happened on When I create a new project with 'react-native init', sendIntent works fine ("react": "15.2.1", "react-native": "^0.31.0"). res.path() has right value. Do you have plan to support old react-native version? |
@siyuan , thanks for the information. I'll do some test on that version and see if I can fix it. However you can also upgrade you application if possible. |
@siyuan , it turns out that the API works properly on 0.24~0.31 environments, could you try removing the package from node_modules and reinstall it ? I think the problem might due to the inconsistency between js and native module version in your environment ? |
@wkh237 |
@siyuan , great 👍 Please feel free to ask any question anytime. |
I download an APK file using addAndroidDownloads. I click the file but can't open. This is my config.
RNFetchBlob.config({
addAndroidDownloads : {
useDownloadManager : true,
title : 'some apk',
description : 'apk install file',
mime : 'application/vnd.android.package-archive',
mediaScannable : true,
notification : true,
}
})
.fetch('GET', 'http://xxxxxxx/yyy.apk')
How to let Downloads know yyy.apk is an APK file?
The text was updated successfully, but these errors were encountered: