cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

feat!: Upgrade to Gradle and AGP 8

Open jcesarmobile opened this issue 2 years ago • 9 comments

jcesarmobile avatar Apr 14 '23 08:04 jcesarmobile

@jcesarmobile try updating this line to use JDK 17. Include title change.

https://github.com/apache/cordova-android/blob/master/.github/workflows/ci.yml#L41-L45

erisu avatar Apr 14 '23 09:04 erisu

Codecov Report

Merging #1596 (468c35e) into master (7efe90f) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1596   +/-   ##
=======================================
  Coverage   71.82%   71.82%           
=======================================
  Files          23       23           
  Lines        1796     1796           
=======================================
  Hits         1290     1290           
  Misses        506      506           

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Apr 14 '23 22:04 codecov-commenter

updated gradle to 8.0.2 as gradle website recommends using that over 8.0

jcesarmobile avatar Apr 14 '23 22:04 jcesarmobile

The README should be updated to reflect the new JDK requirement.

Part of me would rather wait for AGP 8 support until we intend to support API 34, which is still in beta phase and won't be released until August at the earliest. I see no concrete date in their roadmap for the final release. The rationale for waiting is to defer the JDK 17 upgrade when it's not needed for a future cordova-android@13 release for API 34. I think Cordova should release a version supporting API 33 no later than at the end of July to give the month to users to refactor their own apps.

On the other hand, we do have an issue with M1 macs where it can be rather difficult to setup due to the current JDK 11 requirement which the only prebuilt JDK available and is provided through Android Studio Electric Eel. Now that Flamingo is released, I presume it ships with JDK 17 which I've seen reports that it doesn't work properly with the Android Tooling (however I haven't confirmed this myself). So having build tools that supports JDK 17 will now give M1 users more options as there are other prebuilt JDK environments available and would be more aligned to our existing documentation.

breautek avatar Apr 16 '23 14:04 breautek

Also related: https://docs.gradle.org/7.6/userguide/upgrading_version_7.html#configuring_custom_build_layout

We use -b flag currently to specify where our build config is. Not sure if this is even necessary however. Supposedly this flag is being removed in 8.x, according to output when using --warning-mode all

Specifying custom build file location has been deprecated. This is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: https://docs.gradle.org/7.6/userguide/upgrading_version_7.html#configuring_custom_build_layout

breautek avatar Apr 21 '23 17:04 breautek

Hello, Can't wait for the new release , good job every one ;)

I have one question : I have upgraded to AGP 8 and JDK 17 and I want to build my app to android-targetSdkVersion 33 , I had a problem :

Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl. Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

 android {
     namespace 'com.example.namespace'
 }

I tried to added it to build.gradle in app generated but no luck.

Do you recommand sir @breautek to downgrade or to wait for the new release ? (my company is in harry to deploy their first app on the store , so maybe we gonna traget sdk 32 only)

Thanks in advance for your reply.

fradali avatar May 19 '23 12:05 fradali

AGP 8 is not supported on cordova-android 11, you can try the cordova-android 12 nightly release that moved package to the namespace. While cordova-android 12 doesn't use AGP 8, I think it would still work if you configure it to use it. But still, I wouldn't recommend using AGP 8 until cordova-android officially supports it.

To install a nighly version do cordova platform add android@nightly

jcesarmobile avatar May 19 '23 12:05 jcesarmobile

@jcesarmobile Thanks for your reply

fradali avatar May 19 '23 12:05 fradali

Do you recommand sir @breautek to downgrade or to wait for the new release ? (my company is in harry to deploy their first app on the store , so maybe we gonna traget sdk 32 only)

To add to jcesar's comments, cordova-android@12 is not going to support AGP 8 or JDK 17. JDK 17 will probably still work for the most part, but it will probably be best to use the recommended JDK for AGP 7 which is JDK 11. JDK 17 may not work completely as expected when using it with AGP 7.

The namespace attribute came in AGP 7.4 or 7.5 (I forget which version exactly) but cordova-android@12 will configure the app & cordova framework to use the namespace attribute.

cordova-android@12 is currently being voted on for release (See the Vote Thread). So if you gave nightly a test, consider giving us feedback in the DISCUSS thread and maybe a +1 or a -1 in the VOTE thread.

If you need more information on how Apache voting works, see Apache Voting Process.

On AGP 8 / Gradle 8 support, as of writing I think that is planned for another major release, probably cordova-android@13.

breautek avatar May 20 '23 16:05 breautek