Really good summary / proposal Ian! Your thoughts on minSdkVersion make complete sense to me.
I'd tweak just one thing - that if minSdkVersion is provided in the top-level config.xml is less than what plugins require, or what Cordova itself requires, then we error out. To allow plugins to participate in this, I think we'll have to add a new tag / logic to plugin.xml. It doesn't fit the mould of <config-file>, since we don't actually want it to modify the platform config.xml, but rather the AndroidManifest. Maybe we just allow <preference> within plugin.xml? re: target & max sdk. I agree we don't want plugins to touch this, but I do think it's fine if we allow the user to specify it in their config.xml. The PR as-is isn't enough though, because if you remove the preferences, then I think we'd want the values to go back to their defaults (PR doesn't do this yet). Q: Where do we store the platform defaults? Extract them from the template AndroidManifest.xml and save them within android.json? On Thu, Aug 14, 2014 at 9:03 AM, Ian Clelland <iclell...@chromium.org> wrote: > I'd like to revisit this, since it's come up for me with building Crosswalk > with Gradle recently. > > Crosswalk requires a minimum API level of 14, which is specified in the > library project's AndroidManifest.xml. Gradle refuses to build a Cordova > project (Min API 10) with Crosswalk included, unless I manually edit my > projects top-level AndroidManifest.xml to match. > > In order to make the crosswalk-engine plugin automatically installable, I'd > need to either bump the minimum version in the template project in > cordova-android (seems stupid) or allow the plugin to set the minimum > version that it requires. > > And I don't think this is unreasonable; it seems like a valid use of the > minSdkVersion. If a plugin actually requires a more recent API than the > minimum specified by Cordova, then that should be okay. The developer > shouldn't be forced to litter their code with @decorations and fallback > code for earlier versions, if there's no way to provide the functionality > anyway. Doing otherwise is just fooling the compiler (and the play store) > into thinking that the resulting application will work on Gingerbread-era > devices, when it won't. > > I think that the right way forward is this: > > The cordova-android template project specifies a minSdkVersion attribute > that represents the earliest versions of android supported by a > bare-bones-no-plugins Cordova app. The targetSdkVersion is the latest > release that we've tested Cordova against, and there's no maxSdkVersion. > > The app, or any plugin, can specify a minSdkVersion, using the preference > in Sergey's pull request. This value can only increase the minimum version > in the top-level AndroidManifest.xml, never decrease it. The final value is > the largest value specified by Cordova, all of the installed plugins, and > the app itself. > > If we want to allow plugins / apps to specify targetSdkVersion or > maxSdkVersion (and I'm not sure that we do yet), the logic is reversed. In > that case, the *smallest* value would be used, since it represents the > highest version of Android that all of the code was tested against / works > with. No plugin should be able to increase that value beyond what any other > plugin, or Cordova itself, has declared. > > I'd be happy with disallowing target and max for now, or perhaps only > allowing them in the application itself (and not plugins) to prevent abuse, > but I think that setting minSdkVersion is an important and useful feature, > and I'd like to see it in cordova-lib before 4.0.x lands. > > Ian > > > > On Fri, Jul 11, 2014 at 1:27 PM, Frederico Galvão < > frederico.gal...@pontoget.com.br> wrote: > > > I'll elaborate on this topic on the next couple of days then and come > back > > with a full feedback on this and folder structure + incremental builds > next > > week. That'll give all of us time to think and get into flow again. > > > > > > 2014-07-10 23:46 GMT-03:00 Joe Bowser <bows...@gmail.com>: > > > > > On 11 Jul 2014 00:22, "Frederico Galvão" < > > frederico.gal...@pontoget.com.br > > > > > > > wrote: > > > > > > > > Are you guyus against the actual implementation being suggested or > are > > > you > > > > against the idea as a whole? > > > > > > A bit of both, assuming you didn't add this feature. See below. > > > > > > > If the answer to the above is "I +1 the idea but -1 the current > > > > implementation being suggested", then ignore the rest of this > message, > > > and > > > > I'll say that I'm looking foward to this feature being released > > (although > > > > it's not a showstopper for me, I'm used to messing with the native > > shell > > > > after Cordova has spit it out for me). > > > > > > > > First I'll state that I agree that in no reasonable situation > targetSdk > > > > should NOT be equal to the most updated(Android) and > suported(Cordova) > > > > version. > > > > > > Awesome. Can this have an error appear when users break this? Like for > > > example, target a min API below 10, or mismatch the target? > > > > > > > Unless you intercept ant/gradle at a fundamental time in the build > > > process > > > > and force a certain sdkVersion (be it min, max, or target), Cordova > > > already > > > > can't protect itself against me changing those options on my > > > > AndroidManifest.xml. By the way, this is exactly what I've been doing > > for > > > a > > > > year and a half now, even with cordova 3.x. > > > > So, if you mean a -1 to this trying to protect the app from building > > > while > > > > targetting "wrong" versions, I'll disagree with you. > > > > > > > > > > Many of our users don't fiddle with AndroidManifest.xml until they have > > to > > > release the app. > > > > > > > However, I may take the need and consequences of this feature > > differently > > > > than others because I keep and maintain the platform folders in VCS > > > > (against recommendations from the docs) and track changes to it every > > > time > > > > > > Everyone does, because the platforms aren't build artifacts yet. I see > > this > > > feature not really helping make that happen without more thought at the > > > very least. > > > > > > > a plugin is installed or a new version of Cordova is released, just > > > because > > > > the CLI alongside config.xml can't handle all the changes I need done > > on > > > > the native side as of today. > > > > > > > > > > Where does it come short? I can say where I think it does, but this > would > > > actually help us out a bit. Your feature may make sense if it was more > > > strict in how it is used, so I'm not as against it as I was initially. > > > (Remember, I'm supposed to be on PTO, and I have a prepaid with no > tether > > > and a crap WiFi connection to peck this out on.) > > > > > > > > > > > 2014-07-10 17:28 GMT-03:00 Joe Bowser <bows...@gmail.com>: > > > > > > > > > On 10 Jul 2014 19:58, bows...@gmail.com wrote: > > > > > > > > > > > > > > > > > > Completely disagree. All this will do is make things not build > and > > > > > confuse users. It's our job to try and abstract this out and when > we > > > let > > > > > users control this, their apps are terrible. This feature is > harmful > > > and > > > > > shouldn't be included. > > > > > > > > > > Decided that I should elaborate. If you see a legacy menu on a > > PhoneGap > > > App > > > > > like the Canadian Avalanche Centre, you'll notice a menu that > doesn't > > > do > > > > > anything. This is what we want to avoid. > > > > > > > > > > Apologies for singling this app out, there are others, but this is > an > > > app I > > > > > actually use occasionally. > > > > > > > > > > > > > > > > > > @purplecabbage > > > > > > > risingj.com > > > > > > > > > > > > > > > > > > > > > On Thu, Jul 10, 2014 at 11:58 AM, Joe Bowser < > bows...@gmail.com> > > > > > wrote: > > > > > > > > > > > > > > > -1 > > > > > > > > > > > > > > > > I like adding min, but max and target build can really break > > the > > > > > build, > > > > > > > > especially when we try and use newer Chromium features. PG > > Build > > > has > > > > > this > > > > > > > > only because a method that we were using was removed from > > Cordova > > > and > > > > > they > > > > > > > > have to support old versions. We want people to upgrade > > Cordova > > > and > > > > > this > > > > > > > > makes it easier for people to stick to broken versions. > > > > > > > > On Jul 10, 2014 11:40 AM, "Lisa Seacat DeLuca" < > > > ldel...@us.ibm.com > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > Sergey, this is awesome! Once we get your changes pulled > in > > we > > > > > should > > > > > > > > > also update the documentation. I can see this being a > > popular > > > > > little > > > > > > > > > feature for users. > > > > > > > > > > > > > > > > > > > > > > > > > > > Lisa > > > > > > > > > @LisaSeacat > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [image: Inactive hide details for "Sergey Grebnov > (Akvelon)" > > > > > > > > ---07/10/2014 > > > > > > > > > 04:23:07 AM---Implemented, pls take a look: > https://github.c > > > > > ]"Sergey > > > > > > > > > Grebnov (Akvelon)" ---07/10/2014 04:23:07 AM---Implemented, > > pls > > > > > take a > > > > > > > > > look: https://github.com/apache/cordova-lib/pull/56/files > > > > > > > > > > > > > > > > > > From: "Sergey Grebnov (Akvelon)" <v-seg...@microsoft.com> > > > > > > > > > To: "dev@cordova.apache.org" <dev@cordova.apache.org> > > > > > > > > > Date: 07/10/2014 04:23 AM > > > > > > > > > Subject: RE: Android: add support of min/max/target SDK to > > > > > config.xml > > > > > > > > > ------------------------------ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Implemented, pls take a look: > > > > > > > > > https://github.com/apache/cordova-lib/pull/56/files > > > > > > > > > https://issues.apache.org/jira/browse/CB-7114 > > > > > > > > > > > > > > > > > > Thx! > > > > > > > > > Sergey > > > > > > > > > -----Original Message----- > > > > > > > > > From: tommy-carlos williams [mailto:to...@devgeeks.org > > > > > > > > > <to...@devgeeks.org>] > > > > > > > > > Sent: Monday, July 7, 2014 5:33 PM > > > > > > > > > To: dev@cordova.apache.org > > > > > > > > > Subject: Re: Android: add support of min/max/target SDK to > > > > > config.xml > > > > > > > > > > > > > > > > > > +1 > > > > > > > > > > > > > > > > > > Another step towards build-artefact-land. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 7 July 2014 at 23:29:25, Andrew Grieve ( > > > agri...@chromium.org) > > > > > wrote: > > > > > > > > > > > > > > > > > > I'd love to see this added. > > > > > > > > > > > > > > > > > > > > > > > > > > > On Mon, Jul 7, 2014 at 7:29 AM, Sergey Grebnov (Akvelon) < > > > > > > > > > v-seg...@microsoft.com> wrote: > > > > > > > > > > > > > > > > > > > Propose to add support of the following Android specific > > > settings > > > > > to > > > > > > > > > > config.xml similar to PG Build[2]. Optional, could be > used > > to > > > > > override > > > > > > > > > > default template values. I think this could be very > useful > > > and > > > > > will > > > > > > > > > > implement this if we agree. Thoughts? > > > > > > > > > > > > > > > > > > > > <preference name="android-minSdkVersion" value="10" /> > > > > > <preference > > > > > > > > > > name="android-targetSdkVersion" value="19" /> <preference > > > > > > > > > > name="android-maxSdkVersion" value="20" /> > > > > > > > > > > > > > > > > > > > > [1] > > > > > > > > > > > > > > > > > http://developer.android.com/guide/topics/manifest/uses-sdk-element.ht > > > > > > > > > > ml > > > > > > > > > > [2] > > > > > > > > > > > > > > > > > http://docs.build.phonegap.com/en_US/configuring_preferences.md.html#_ > > > > > > > > > > android_only > > > > > > > > > > > > > > > > > > > > Thx! > > > > > > > > > > Sergey > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > *Frederico Galvão* > > > > > > > > Diretor de Tecnologia > > > > > > > > PontoGet Inovação Web > > > > > > > > > > > > ( +55(62) 8131-5720 > > > > > > > > * www.pontoget.com.br <http://www.pontoget.com/> > > > > > > > > > > > -- > > > > *Frederico Galvão* > > > > Diretor de Tecnologia > > > > PontoGet Inovação Web > > > > > > ( +55(62) 8131-5720 > > > > * www.pontoget.com.br <http://www.pontoget.com/> > > >