Title: Adding file to Android build at app/src/main/assets for `getAssets()` · Issue #3560 · NativeScript/NativeScript · GitHub
Open Graph Title: Adding file to Android build at app/src/main/assets for `getAssets()` · Issue #3560 · NativeScript/NativeScript
X Title: Adding file to Android build at app/src/main/assets for `getAssets()` · Issue #3560 · NativeScript/NativeScript
Description: Dear friend, we, the rest of the NativeScript community really appreciate your feedback! While we are doing all we can to take care of every issue, sometimes we get overwhelmed. Because of that, we will consider issues that are not const...
Open Graph Description: Dear friend, we, the rest of the NativeScript community really appreciate your feedback! While we are doing all we can to take care of every issue, sometimes we get overwhelmed. Because of that, we...
X Description: Dear friend, we, the rest of the NativeScript community really appreciate your feedback! While we are doing all we can to take care of every issue, sometimes we get overwhelmed. Because of that, we...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/3560
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding file to Android build at app/src/main/assets for `getAssets()`","articleBody":"Dear friend, we, the rest of the NativeScript community really\r\nappreciate your feedback! While we are doing all we can to take care of every\r\nissue, sometimes we get overwhelmed. Because of that, we will consider issues\r\nthat are not constructive or problems that cannot be reproduced \"dead\".\r\nAdditionally, we will treat feature requests or bug reports with unanswered\r\nquestions regarding the behavior/reproduction for more than 20 days \"dead\". All\r\n\"dead\" issues will get closed.\r\n\r\n## Please, provide the details below:\r\n\r\nTrying to build a plugin which is calling the following code:\r\n\r\n```\r\n public static Cancellable fromAssetFileName(Context context, String fileName, OnCompositionLoadedListener loadedListener) {\r\n InputStream stream;\r\n try {\r\n stream = context.getAssets().open(fileName);\r\n } catch (IOException e) {\r\n throw new IllegalStateException(\"Unable to find file \" + fileName, e);\r\n }\r\n return fromInputStream(context, stream, loadedListener);\r\n }\r\n```\r\n\r\nThe public method to get to that ^^^ is just accepting a string for the `fileName` argument. The README for the android lib says to put the file at `app/src/main/assets`. I've tried creating an `assets` folder in app_resources which obviously doesn't package up there. I've tried at the root of the `app` folder and no good. So is there some way to add files (this is a .json file) to that location for an android build with NS. The android code calling `getAssets()` returns the [AssetManager](https://developer.android.com/reference/android/content/res/AssetManager.html) and is calling `open()` with the given file name. So how do we get files to be accessible with this in a NS app is the question now that I think about it 😄 \r\n\r\n\r\n### Did you verify this is a real problem by searching [Stack Overflow](http://stackoverflow.com/questions/tagged/nativescript) and the [other open issues in this repo](https://github.com/NativeScript/nativescript/issues)?\r\n\r\nYes.\r\n\r\n### Which platform(s) does your issue occur on?\r\n\r\nAndroid\r\n\r\n### Please provide the following version numbers that your issue occurs with:\r\n\r\nNS 2.5 everything - just updated.\r\n\r\n### Please tell us how to recreate the issue in as much detail as possible.\r\n\r\nCreate an app, try to create an .apk with a file located in `app/src/main/assets` at the output I suppose.\r\n\r\n### Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.\r\n\r\nNo, just wrapping a lib.\r\n\r\n","author":{"url":"https://github.com/bradmartin","@type":"Person","name":"bradmartin"},"datePublished":"2017-02-02T06:33:15Z","url":"https://github.com/NativeScript/NativeScript/issues/3560"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b5d0ba4b-bf8b-a47d-3988-d443791dcf96 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B58C:1F65:3A4A03:49BADC:6B012416 |
| html-safe-nonce | 5289587988dc9786be87bd9a595bf11358512a9089fcae753a1c90a384ddf157 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNThDOjFGNjU6M0E0QTAzOjQ5QkFEQzo2QjAxMjQxNiIsInZpc2l0b3JfaWQiOiIzODYxMzE3ODExNTYxMzc0NzQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6863aebffe96084d82f6283667deb4fdae01c4ff5688fa23ef5ccfa4bccac990 |
| hovercard-subject-tag | issue:204793428 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/NativeScript/3560/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5541e965714daad4254bd6df731760c4badb056e3a303d42397676bf7e848814/NativeScript/NativeScript/issues/3560 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5541e965714daad4254bd6df731760c4badb056e3a303d42397676bf7e848814/NativeScript/NativeScript/issues/3560 |
| og:image:alt | Dear friend, we, the rest of the NativeScript community really appreciate your feedback! While we are doing all we can to take care of every issue, sometimes we get overwhelmed. Because of that, we... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bradmartin |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width