@bradmartin commented on Thu Feb 02 2017
Trying to build a plugin which is calling the following code:
public static Cancellable fromAssetFileName(Context context, String fileName, OnCompositionLoadedListener loadedListener) {
InputStream stream;
try {
stream = context.getAssets().open(fileName);
} catch (IOException e) {
throw new IllegalStateException("Unable to find file " + fileName, e);
}
return fromInputStream(context, stream, loadedListener);
}
The 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 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 馃槃
Yes.
Android
NS 2.5 everything - just updated.
Create an app, try to create an .apk with a file located in app/src/main/assets at the output I suppose.
No, just wrapping a lib.
@bradmartin commented on Thu Feb 02 2017
There is another method to go about, but was hoping to access the simplest of them with just passing the file name 馃憤
@bradmartin commented on Thu Feb 02 2017
And opening up platforms/android/src/main/assets and placing the .json file isn't really a good solution for new NS devs or anyone since it'll be blasted during a build/platform clean. Doing this does work, so the native lib is expecting the file to be located in the assets folder.
Any news on this?
Hi @vjoao
This is part of a more complex task that we need to resolve (https://github.com/NativeScript/android-runtime/issues/561) At this moment, only resource files in App_Resources/Android will be copied in src/main/res.
The feature however won't be available in the upcoming 3.0 release. I'll let you know if there are news around it.
@vjoao , @Pip3r4o ,
I created a small hook to avoid this issue:
https://github.com/rhanb/nativescript-dev-assets/
Hope it can help 馃槃
Addressed by introducing the tns resources update command in the CLI that will migrate the App_Resources/Android subdirectory structure to support user-defined assets, java classes and resources - https://github.com/NativeScript/nativescript-cli/pull/3347
Most helpful comment
@vjoao , @Pip3r4o ,
I created a small hook to avoid this issue:
https://github.com/rhanb/nativescript-dev-assets/
Hope it can help 馃槃