Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordova android 11 clean command purge resources files #1553

Closed
3 tasks done
4lyn opened this issue Jan 30, 2023 · 14 comments
Closed
3 tasks done

Cordova android 11 clean command purge resources files #1553

4lyn opened this issue Jan 30, 2023 · 14 comments

Comments

@4lyn
Copy link

4lyn commented Jan 30, 2023

Bug Report

Problem

All files listed in resource-file tag in config.xml are purged after cordova clean android

<resource-file src="res/native/android/res/values/colors.xml" target="app/src/main/res/values/colors-custom.xml" />
<resource-file src="res/native/android/res/values/styles.xml" target="app/src/main/res/values/styles.xml" />
<resource-file src="res/native/android/res/values-v21/styles.xml" target="app/src/main/res/values-v21/styles.xml" />

They are still some resources files like colors.xml / strings.xml / themes.xml
But all custom files from the config disappear. It also happens to the files in the res/native/android/res/values-v21 directory

What is expected to happen?

cordova clean android should not clean resource files
As explained in this #1551 (comment) by @breautek

What does actually happen?

After cordova prepare android these files are present, but if I run cordova clean android they disappear
And changing the target as explained in this #1461 (comment) by @erisu doesn't help

Information

Reproduce without any plugins in Cordova CLI 11.1.0 / Cordova Android 11.0.0
But also in Cordova CLI 10.0.0 / Cordova Android 10.1.1

So it might be linked to the other upgrade I had to make

  • Java 8 ==>> 11
  • Gradle 7.3.3 ==>> 7.4.2

Everything was fine before.

Command or Code

rm -rf platforms/* plugins/ node_modules/
npm install
cordova prepare android
==>> Files exist in platforms/android/app/src/main/res/values/
cordova clean android
==>> Files have been deleted in platforms/android/app/src/main/res/values/colors.xml

Environment, Platform, Device

Linux mint 19.3 (Ubuntu 18.04)

Version information

Java JDK: installed 11.0.18
Android SDK: installed true
Android target: installed android-33,android-32,android-31,android-30,android-23
Gradle: installed /opt/gradle/gradle-7.4.2/bin/gradle

Checklist

@jonathanalberghini
Copy link

Has anyone posted this error in vue cli? My problem is that I use an older version of you and for some reason I cannot update to the newest it gives me all kinds of web pack errors.

@jonathanalberghini
Copy link

jonathanalberghini commented Jan 30, 2023

@4lyn what version of the VUE CLI are you using?

@jonathanalberghini
Copy link

jonathanalberghini commented Jan 30, 2023

The other thing is that there's really no code changes except for a couple exported= true statements to support 32
I ended up pulling Cordova 10 and applying the patches from 11 and now I can use 10 and it allows me to use SDK 32
Is a stupid way to do it but I have no other solution.

#1427 feat!: API 32 support
#1410 feat!: API 31 support

@4lyn
Copy link
Author

4lyn commented Jan 30, 2023

@jonathanalberghini I'm not sure I see the link with Vue CLI here. I do cordova prepare android and then cordova clean android in the src-cordova folder and files disappear. That's all this issue is about.
Vue CLI is used in the parent folder to populate the src-cordova/www folder. It's a different matter.

@jonathanalberghini
Copy link

Maybe I'm mistaken and it's really android 11 and it's just happens I'm using the VUE CLI.

@breautek
Copy link
Contributor

cordova clean android should not clean resource files
As explained in this #1551 (comment) by @breautek

I never said cordova clean android shouldn't clean resource files. I did say at one point that clean only removes build artefacts, and then later corrected myself that clean also removes custom resources. Custom resources is still a build artefact as it gets prepared during the cordova build process, so I'm not entirely convinced this is a problem.

Can you explain why you think that custom resource files should not be cleaned? I would like to understand your perspective.

@jonathanalberghini
Copy link

In my case with cordova 11 they are cleaned before the build has completed.
see output below it is removing it before the build is complete

`$ cross-env CORDOVA_PLATFORM=android vue-cli-service cordova-build-android

⠼ Building for production...

WARNING Compiled with 2 warnings 10:06:08 AM

warning

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
js/app.cfb8c76d.js (382 KiB)
css/chunk-vendors.f5b80ee0.css (450 KiB)
js/chunk-vendors.49a6bc86.js (652 KiB)

warning

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.62 MiB)
css/chunk-vendors.f5b80ee0.css
js/chunk-vendors.49a6bc86.js
css/app.0a99e3f5.css
js/app.cfb8c76d.js

File Size Gzipped

www/js/chunk-vendors.49a6bc86.js 651.74 KiB 210.66 KiB
www/js/app.cfb8c76d.js 382.40 KiB 54.11 KiB
www/js/chunk-499abac6.03e5e054.js 3.90 KiB 1.75 KiB
www/js/chunk-2d21a5c5.a81b9a0b.js 3.00 KiB 1.38 KiB
www/js/chunk-2d0e9993.7b3657ef.js 2.75 KiB 1.33 KiB
www/js/chunk-2d0aaf94.df2a6a9b.js 2.40 KiB 1.15 KiB
www/js/chunk-2d2262ea.1c7f0404.js 2.06 KiB 1.02 KiB
www/js/chunk-95df9744.44ba7d71.js 0.98 KiB 0.59 KiB
www/js/chunk-61471f4c.d15b27b2.js 0.97 KiB 0.57 KiB
www/js/chunk-11604a98.7e1cb444.js 0.85 KiB 0.53 KiB
www/js/chunk-3ad08596.b389aa83.js 0.83 KiB 0.53 KiB
www/js/chunk-0c321ec6.dfc75661.js 0.74 KiB 0.49 KiB
www/js/chunk-2d0e8c8e.e253266c.js 0.55 KiB 0.41 KiB
www/js/chunk-2d21ad78.9c1d55ae.js 0.55 KiB 0.40 KiB
www/js/chunk-2d225232.99112fc2.js 0.54 KiB 0.40 KiB
www/js/chunk-2d208107.c114d54e.js 0.37 KiB 0.28 KiB
www/js/chunk-2d22dba2.4d1487a5.js 0.37 KiB 0.29 KiB
www/css/chunk-vendors.f5b80ee0.css 450.47 KiB 54.39 KiB
www/css/app.0a99e3f5.css 169.24 KiB 39.97 KiB
www/css/chunk-499abac6.43091943.css 0.35 KiB 0.15 KiB
www/css/chunk-0c321ec6.0e433876.css 0.00 KiB 0.02 KiB
www/css/chunk-11604a98.0e433876.css 0.00 KiB 0.02 KiB
www/css/chunk-3ad08596.0e433876.css 0.00 KiB 0.02 KiB
www/css/chunk-61471f4c.0e433876.css 0.00 KiB 0.02 KiB
www/css/chunk-95df9744.0e433876.css 0.00 KiB 0.02 KiB

Images and other types of assets omitted.

DONE Build complete. The www directory is ready to be deployed.
INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html

INFO executing "cordova clean" in folder /Users/jalberghini/src/opportunistic-trader-mobile
Checking Java JDK and Android SDK versions
ANDROID_HOME=/Users/jalberghini/Library/Android/sdk (recommended setting)
ANDROID_SDK_ROOT=/Users/jalberghini/Library/Android/sdk (DEPRECATED)
Using Android SDK: /Users/jalberghini/Library/Android/sdk

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 747ms
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app

Configure project :app
Adding classpath: com.google.gms:google-services:4.3.10

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 941ms
3 actionable tasks: 3 up-to-date
Running command: xcodebuild -project Opportunistic Trader.xcodeproj -configuration Debug -alltargets clean
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project "Opportunistic Trader.xcodeproj" -configuration Debug -alltargets clean

User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES

** CLEAN SUCCEEDED **

Running command: xcodebuild -project Opportunistic Trader.xcodeproj -configuration Release -alltargets clean
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project "Opportunistic Trader.xcodeproj" -configuration Release -alltargets clean

User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES

** CLEAN SUCCEEDED **

INFO executing "cordova build android --release" in folder /Users/jalberghini/src/opportunistic-trader-mobile
ENOENT: no such file or directory, open '/Users/jalberghini/src/opportunistic-trader-mobile/platforms/android/app/src/main/res/values/colors.xml'
✨ Done in 40.79s.`

@jonathanalberghini
Copy link

None of that outfit makes any sense why is it running Xcodebuild building iOS I'm just building the android package.
See what I bolded above.

@4lyn
Copy link
Author

4lyn commented Jan 31, 2023

@breautek ok
I actually got confused because one of my plugin was blocking the cordova prepare command so after cordova clean, theses files did not came back and that was blocking the cordova compile command
Trying to sort this out I thought theses files should not be purged but if they come back that fine by me

Reading again your #1551 (comment) I get it now

cordova prepare and cordova build will copy the resources files. cordova clean will clean some custom resource files (so I was mistaken in my past posts).
Even if you ran the cordova clean command, running cordova build implicitly does a cordova prepare which reconfigures those source files.

Sorry for wasting tour time here. I'll close this issue.
I'm sorry @jonathanalberghini but you seem to have other problems not really linked to this issue or even Cordova Android actually

@4lyn 4lyn closed this as completed Jan 31, 2023
@breautek
Copy link
Contributor

Sorry for wasting tour time here. I'll close this issue.

No worries. At the very least I think we have confirmed that the issue is not within Cordova. I'm not familiar with the Vue CLI but we have confirmed that both cordova-android@10 and 11 boths cleans and restructures the project files up appropriately, as expected.

With this information, at least it can be brought to Vue's attention, or whoever maintains the Vue CLI. Perhaps they are doing a lot of stuff manually instead of relying on the Cordova CLI.

@4lyn
Copy link
Author

4lyn commented Jan 31, 2023

In my case it has nothing to do with Vue CLI either. I just happen to use it also
It was just and old plugin (cordova-universal-links-plugin) that is not working anymore 😞

@shanlin2dltk
Copy link

@breautek I ran into the same issue as that of @4lyn
after cordova clean android (it deletes my custom resource file, which is expected per your comments), subsequent cordova build android doesn't add the custom resource file back. I am using cordova cli 11.1.0 and cordova-android 11.0.0.

What is going on?

@breautek
Copy link
Contributor

@breautek I ran into the same issue as that of @4lyn after cordova clean android (it deletes my custom resource file, which is expected per your comments), subsequent cordova build android doesn't add the custom resource file back. I am using cordova cli 11.1.0 and cordova-android 11.0.0.

What is going on?

Not sure, but I can say that I have a resource file defined by <resource-file src="./res/android/values/TotalPaveTheme.xml" target="app/src/main/res/values/TotalPaveTheme.xml" /> in my config.xml and gets cleaned on cordova clean and re-added on cordova build as expected using Cordova CLI / android 12.x (they should be added as part of the cordova prepare step which cordova build will implicitly call).

I'd suggest trying to update (you'll need cordova-android@12 for API 33/Google Play compliance anyway). If it still fails, then I'd suggest creating a support discussion at Apache Cordova Discussions.

@drpepper
Copy link

For anyone else checking here, I took the same approach of modifying the theme but directly in the config.xml file.

<platform name="android">
    <!-- ... -->
    <config-file target="app/src/main/res/values/themes.xml" parent="/resources/style">
        <item name="android:windowLayoutInDisplayCutoutMode">never</item>
    </config-file>
</platform>

Seems to work so far! Not sure if there is a disadvantage to using this approach as compared to copying the theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants