Skip to content

[Proposal] List of version 4.0 (breaking?) changes #890

Closed

Description

@petekanev
  • <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/Android to 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.xml and/or res/strings/ (resource) directories in the platforms/android/ directories of the plugin. Instead plugins should only have include.gradle scripts and/or .aar/.jar libraries. Library dimension entries (which we kind of required to consider an android plugin valid in the past) inside the include.gradle scripts 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

  1. added this to the milestone on Dec 7, 2017
  2. rosen-vladimirov commented on Dec 11, 2017

    @rosen-vladimirov
    Contributor

    @Pip3r4o what problem does the first part solve, i.e.

    <nsProject>/app/App_Resources/ to move one directory up -> <nsProject>/App_Resources - should allow us to remove excess error-prone logic from the CLI (livesyncing and building the projects)
    

    Can you give more information what's the purpose of this change, will it affect iOS resources, etc.

  3. Plamen5kov commented on Dec 12, 2017

    @Plamen5kov
    Contributor

    @rosen-vladimirov moving the AppResources one 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->else AppResources logic, 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.

  4. NathanaelA commented on Dec 21, 2017

    @NathanaelA
  5. petekanev commented on Dec 21, 2017

    @petekanev
    ContributorAuthor

    @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.

  6. EmilStoychev commented on Dec 21, 2017

    @EmilStoychev
    Contributor

    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

  7. changed the title [-]List of upcoming 4.0 breaking changes[/-] [+][Proposal] List of version 4.0 breaking changes[/+] on Jan 8, 2018
  8. etabakov commented on Jan 10, 2018

    @etabakov
    Contributor

    The document is added to the initial post, so you can get review it and leave your comments.

  9. PeterStaev commented on Jan 10, 2018

    @PeterStaev

    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.

  10. NathanaelA commented on Jan 11, 2018

    @NathanaelA
  11. petekanev commented on Jan 11, 2018

    @petekanev
    ContributorAuthor

    @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.

    ... viable option not mentioned -- is not to mess with it. It works

    • Because of the way flavors are abused in the build scripts we currently provide, users cannot take advantage of product flavors in their applications. This is especially critical for enterprise applications.
    • As outlined in the design document - it doesn’t allow the framework to progress significantly without sacrificing code quality. We consider these reasons to be significant enough, to make the option you are proposing not viable.

    .. and the majority of plugin authors like it the way it is

    • During the NativeScript Dev Days in Rotterdam, we spoke to a couple of plugin authors that wouldn't mind the change keeping in mind the benefits outlined in the design document.

    easy manifest editing and fixing

    • If editing an extraneous plugin's AndroidManifest.xml ever becomes a necessity, the user should edit out their own App_Resources/Android/AndroidManifest.xml instead, it's one way to make sure the proper settings are present in the resulting project.
    • If while developing a plugin you need to make quick changes to a user-permission, or another AndroidManifest setting, you can address it by automating the build process - using npm scripts, or another custom solution. Our team can help with that, the workflow for the plugin developer should not change drastically, if at all. (cc @radeva)
    • If it's another development issue for the plugin author we can work something out

    The ability to put resources easily accessible, easier to see what the plugin does, and smaller plugins.

    • The structure that we currently support - dropping directories within platforms/android of 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.
    • If a plugin user is curious about the contents of a plugin, they can find the source on Github, or decompile the plugin to look through its contents - just like with any Android library (aar or otherwise) currently available for Android development.
    • Furthermore, you can use Android Studio to further inspect an aar (Build->Analyze APK):
      inspect-aar
    • Dropping arbitrary resources in the platforms/android plugin 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.

    You eliminate easy to use jar usage

    • Consuming jars will not change - you can still drop yours in the platforms/android plugin directory, and it will be used in the project.
    • The Jar contents can be inspected similarly to how you would inspect an .aar

    and it is a very easy simple security failure point where people WON'T pay attention to them

    • Unfortunately, due to Android's nature, if you wished you could achieve this using JARs as well
    • As mentioned earlier, if using plugins from unverified sources is a concern, you could inspect them additionally when you have doubts about a plugin's integrity.

    and completely outside of "my" (the plugin author's) control.

    • The developer (plugin user) always has control over what plugin to use - they can, of course, use it, or choose not to.

    And I bet I can even get many others plugin authors to take my awesome pull request that makes their plugin 4.0 compatible. After all, it is just a simple .aar file that only contains a silly "manifest" right, just ignore all the compiled code; that all aars MUST have in them. :-)

    • While plugins should ship with .aars, according to the proposal, where AndroidManifests.xml and 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.
  12. 20 remaining items

  13. EddyVerbruggen commented on Jan 29, 2018

    @EddyVerbruggen
    Contributor

    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:

    • Everybody wants as little as possible impact on current workflows (of course!).
    • We all want NativeScript to succeed (why else would you read this at all?).
    • We're lucky this project is Open Source, otherwise, we would just get a new version without having a say at all.
    • The NativeScript team needs help and wants help on this complex topic, but it's hard for everybody to sync on everything.
    • The initial communication could have been better because (also to me) it wasn't abundantly clear that the team is actively looking into automating the migration.

    The reasons for changing the Android build are:

    • Maintenance debt. Having worked in a few bigger companies and projects I know that's a real problem. Mostly upper management ignores the problem completely until there's a point that a project becomes unmaintainable and you need to start from scratch to be able to actually add new business logic. Without a budget for maintenance, developers start applying patch upon patch and build proprietary tools to keep everything working. I'm happy to learn things like these are flagged and acted upon with NativeScript.
    • Allow developers to support multiple flavors in the way Android intended. I don't have this need and I doubt I'll ever will, but I'm sure there are folks wanting to support fi. a Free and Paid version of their app in this way. Especially former native Android developers would appreciate the feature.
    • Oh, and I often open a NativeScript project in Xcode to run and debug stuff. Doing this in Android Studio is a big fail because plugins screw up the project (because of the flavors, as I learned).

    Going forward, there are a few options, but ideally these criteria should be met:

    • If plugins need to be updated, they need to be backward compatible with {N} < 4.
    • Works with or without the official NativeScript plugin seed.
    • No maintenance of an Android library project.
    • No impact on cloud build times.
    • If you need something funky, additional work is OK.. but the 90-95% case should be covered.

    Best option* IMO: Treat plugins as gradle projects:

    • PRO: No changes to the current src/platforms/android structure.
    • CON: Slower cloud builds (~4s per plugin that has static files in src/platforms/android), which we have to take seriously because we're not only wasting CPU cycles but also, you have to wait longer for your build to complete (time === money, folks!).
    • *POSSIBLE SOLUTION: So I only see this as the 'best option' if there is a way to cache the generated .aar artifacts in a central cloud build repository (not on the internet, but on the Telerik infrastructure, accessible to all build servers) so build times are only marginally affected.

    Second best option IMO: plugins generate aar files

    • PRO: No changes to the current src/platforms/android structure.
    • CON: To be {N} 4 compatible, the plugin needs to be updated as the npm package should contain an aar. Note that with the aar added (and fi. an AndroidManifest.xml and res folder removed) the plugin will still be {N} 3 compatible as it currently already works with aar files just fine.
    • POSSIBLE SOLUTION: As having/creating/maintaining a library project is alien to most developers, we could add a "nativescript-plugin-platform-artifact-generator" devDepencency to the plugin's src/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 🤔

  14. changed the title [-][Proposal] List of version 4.0 breaking changes[/-] [+][Proposal] List of version 4.0 (breaking?) changes[/+] on Feb 2, 2018
  15. NathanaelA commented on Feb 2, 2018

    @NathanaelA
  16. Plamen5kov commented on Feb 5, 2018

    @Plamen5kov
    Contributor

    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?

  17. etabakov commented on Feb 5, 2018

    @etabakov
    Contributor

    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.

  18. Plamen5kov commented on Mar 1, 2018

    @Plamen5kov
    Contributor

    @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.

  19. Natalia-Hristova commented on Apr 13, 2018

    @Natalia-Hristova

    Changes in the latest version of android-runtime 4.0.0 can be seen in the CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions