Repository navigation
Description
-
<nsProject>/app/App_Resources/to move one directory up -><nsProject>/App_Resources- this will be 'opt-in' through a configuration file, and users would not be forced to migrate their App_Resources location should they not need or want it. - enabled through a configuration file where users can specify the path to the application resources directory (feat: make app_resources's path configurable nativescript-cli#3329) -
App_Resources/Androidto move all its files into the resources directory of a sourceset (main/src/res) - this will also be 'opt-in' through a CLI command. Users who want to take advantage of the updated App_Resources/Android subdirectory structure will be able to do so when using CLI 4.0 and the Android Runtime 4.0. - enabled through a command in the nativescript-cli (feat: introduce resources update command nativescript-cli#3347)
'--App_Resources/Android/main/assets (will allow users to include their own resources outside the javascript sources directory, which do not necessarily fall under the 'resources' category)
'--App_Resources/Android/main/java (will allow user-editable java sources to be added with no extra work)
'--App_Resources/Android/main/res (will hold all user-defined resources, icons and styles)
'--App_Resources/Android/main/res/values/
'--App_Resources/Android/main/res/drawable-hdpi/
'--App_Resources/Android/main/AndroidManifest.xml
'--App_Resources/Android/app.gradle
The changes above will allow users to customize their Android builds a lot more easily, without having to rely on before/after prepare hooks to replace code and files - see #700
- Remove flavors (F0, F1, Fx) from Android builds as a mechanism to work with plugins - this implies changes in the agreed-upon Android Nativescript plugin structure - it will no longer be allowed to just drop
AndroidManifest.xmland/orres/strings/(resource) directories in theplatforms/android/directories of the plugin. Instead plugins should only haveinclude.gradlescripts and/or.aar/.jarlibraries. Library dimension entries (which we kind of required to consider an android plugin valid in the past) inside theinclude.gradlescripts should also be removed.
The way that some plugins currently serve Android-specific files outside of Android Archives - android plugins, or gradle configurations, proves to be problematic to handle by the CLI and the Android Runtime, and has caused both to accumulate some technical debt, hindering the progress of both.
Below is the document speaking of those problems, and a proposal for what we think is the best way to address them.
Design Document - hosted in Google Drive
Activity
rosen-vladimirov commentedon Dec 11, 2017
@Pip3r4o what problem does the first part solve, i.e.
Can you give more information what's the purpose of this change, will it affect iOS resources, etc.
Plamen5kov commentedon Dec 12, 2017
@rosen-vladimirov moving the
AppResourcesone directory up is not a "must have", but it's making the project structure easier to understand. Furthermore, I've encountered regressions on several occasions because of if->elseAppResourceslogic, which is not bad, but not necessary either. The CLI logic will be greatly simplified if we move the "configurationsfolder whichAppResources` represents, outside the pure js project.Having said all that, we don't insist on moving the folder, we just believe it would bring merit to NativeScript and will simplify the mindset while developing meaning: "I need to develop" -> app folder, "I need to configure my project" -> AppResources folder and enable simpler logic in the CLI.
NathanaelA commentedon Dec 21, 2017
petekanev commentedon Dec 21, 2017
@NathanaelA I am preparing an article where I try to explain why we are making that decision, and how we can help mitigate the "extra" work for plugin developers.
The current approach has been hindering some of the platform's development, and finally getting rid of it will help the NativeScript Android Runtime move forward - with fewer dirty hacks, tricks, and improper usage of Android build tooling.
EmilStoychev commentedon Dec 21, 2017
We will schedule a call with community members to discuss the upcoming changes early in January. We will then make the meeting notes publicly available so everyone is on board with what decisions were made and how that will impact app and plugin development
[-]List of upcoming 4.0 breaking changes[/-][+][Proposal] List of version 4.0 breaking changes[/+]etabakov commentedon Jan 10, 2018
The document is added to the initial post, so you can get review it and leave your comments.
PeterStaev commentedon Jan 10, 2018
My 2 cents on the topic: I perfectly understand why you want those flavors gone and that you want to improve stability. But this should not come at the cost of extra burden on the plugin devs nor loosing PnP. So the only viable option imo is proposal 4 i.e. via post install script to automatically wrap up the manifest in an AAR.
NathanaelA commentedon Jan 11, 2018
petekanev commentedon Jan 11, 2018
@NathanaelA
It's great to see that you are so passionate about the future of the platform so thank you for your feedback. We too want to see the framework move forward, and we'll try to address all of your points below.
AndroidManifest.xmlever becomes a necessity, the user should edit out their ownApp_Resources/Android/AndroidManifest.xmlinstead, it's one way to make sure the proper settings are present in the resulting project.platforms/androidof a plugin, is not very strict, also lacks a good definition of what it should look like, and inexperienced plugin developers can easily get into the pitfalls.platforms/androidplugin directory doesn't guarantee that the sources will build, as those aren't handled by Gradle, but by our own project's build script, which we consider to be error-prone.platforms/androidplugin directory, and it will be used in the project..aarAndroidManifests.xmland stray resource directories were used previously, we do not recommend that they be part of source control, and should instead be built when preparing a package for publishing to npm. Suppose you are plugin author, we would also not recommend that you accept unverified binary files (aars for example), and rather ask for the source that you can later build, and use to publish a plugin with.20 remaining items
EddyVerbruggen commentedon Jan 29, 2018
Hey folks, leaving my $0.02 on the subject (of possibly changing the Android plugin structure).
Reading all issues, docs, discussions, whatnot, my opinion is:
It seems that:
The reasons for changing the Android build are:
Going forward, there are a few options, but ideally these criteria should be met:
Best option* IMO: Treat plugins as gradle projects:
Second best option IMO: plugins generate aar files
AndroidManifest.xmlandresfolder removed) the plugin will still be {N} 3 compatible as it currently already works with aar files just fine.nativescript-plugin-platform-artifact-generator" devDepencency to the plugin'ssrc/package.json. The ultimate goal would be: just keep the plugin as-is, add the devDependency, upon build this new generator takes whatever relevant is in src/platforms/android, and generate an aar for it (with an intermediate Android library project that's cleaned up when the aar is built).If you have any ideas that may help materialize these proposals or another one that also meets the criteria above, please don't hesitate to spill them!
Hmm, at my rate this was actually more than $0.02 🤔
[-][Proposal] List of version 4.0 breaking changes[/-][+][Proposal] List of version 4.0 (breaking?) changes[/+]NathanaelA commentedon Feb 2, 2018
Plamen5kov commentedon Feb 5, 2018
Hi @NathanaelA,
We're working towards a beneficial solution for the community. Keeping in mind what the people have voted for, we're leaning toward option 3, because it's similar to option 5, but we think we can make it more reliable inside the CLI.
We'll answer this issue as soon as we have something we can provide for the plugin authors to test out. We're working on a proposal for plugin development keeping in mind the preferences of the community. What do you think?
etabakov commentedon Feb 5, 2018
Just to mention that we are not aiming to release 4.0 mid-late Feb. The Release Candidate for 4.0 will be early-mid March. We also intent to leave the RC more time than usual so that everyone can try out the new bits.
Plamen5kov commentedon Mar 1, 2018
@NathanaelA, @PeterStaev, @sitefinitysteve, @TheOriginalJosh
Hi guys, sorry it took so long for us to respond. Know that you have been heard and we've taken the appropriate steps to alleviate your pain. Please take a look in this issue and let's continue the discussion there.
Natalia-Hristova commentedon Apr 13, 2018
Changes in the latest version of
android-runtime 4.0.0can be seen in the CHANGELOG.md