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

SDK 34 adaptations #4215

Open
wants to merge 6 commits into
base: release/4.0
Choose a base branch
from

Conversation

TranceLove
Copy link
Collaborator

Description

On Google Play store's requirements. Inevitably support for Kitkats must be dropped.

  • Minimum version requirement set to LOLLIPOP, required after SDK upgrade and future Billing library upgrade to 7.0.0 as well
  • Compile with JDK 17, for future compatibility with sardine-android (WebDAV browsing (and uploading?) support. #376)
  • Code adaptations to remove switch cases to resource IDs, as mandated since Gradle 8.0
  • Fix import of resource IDs from library level resources
  • Fix bad programming habits in test cases

Automatic tests

  • Added test cases

Manual tests

  • Done

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

@TranceLove
Copy link
Collaborator Author

TranceLove commented Jul 8, 2024

Pending tasks:

  • Fix Jacoco report stopped working - currently stub task only
  • Test on devices

@Bambooin
Copy link
Contributor

Bambooin commented Jul 9, 2024

Found one issue during local build(./gradlew assembleFdroidRelease).

> Task :app:minifyFdroidReleaseWithR8 FAILED
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in ~/github/amaze/app/build/outputs/mapping/fdroidRelease/missing_rules.txt.
ERROR: R8: Missing class com.amaze.filemanager.fileoperations.exceptions.CloudPluginException (referenced from: androidx.core.util.Pair com.amaze.filemanager.asynchronous.asynctasks.LoadFilesListTask.doInBackground(java.lang.Void[]) and 7 other contexts)
Missing class com.amaze.filemanager.fileoperations.exceptions.ShellNotRunningException (referenced from: void com.amaze.filemanager.application.AppConfig.lambda$getTrashBinInstance$2(java.lang.String) and 11 other contexts)
Missing class com.amaze.filemanager.fileoperations.exceptions.StreamNotFoundException (referenced from: void com.amaze.filemanager.asynchronous.asynctasks.texteditor.read.ReadTextFileTask.onError(java.lang.Throwable) and 2 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.FolderState (referenced from: java.lang.Integer com.amaze.filemanager.filesystem.ftp.NetCopyClientUtils$checkFolder$template$1.execute(net.schmizz.sshj.sftp.SFTPClient) and 3 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.OpenMode (referenced from: com.amaze.filemanager.fileoperations.filesystem.OpenMode com.amaze.filemanager.adapters.data.LayoutElementParcelable.mode and 208 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.StorageNaming$DeviceDescription (referenced from: java.lang.String com.amaze.filemanager.ui.strings.StorageNamingHelper.getNameForDeviceDescription(android.content.Context, java.io.File, int))
Missing class com.amaze.filemanager.fileoperations.filesystem.StorageNaming (referenced from: java.util.ArrayList com.amaze.filemanager.ui.activities.MainActivity.getStorageDirectoriesLegacy())
Missing class com.amaze.filemanager.fileoperations.filesystem.cloud.CloudStreamer (referenced from: com.amaze.filemanager.fileoperations.filesystem.cloud.CloudStreamer com.amaze.filemanager.filesystem.ssh.SshClientUtils$launchFtp$1.$streamer and 5 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.compressed.ArchivePasswordCache (referenced from: void com.amaze.filemanager.asynchronous.asynctasks.compress.SevenZipHelperCallable.addElements(java.util.ArrayList) and 9 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.root.NativeOperations (referenced from: boolean com.amaze.filemanager.filesystem.HybridFile.isDirectory(android.content.Context) and 1 other context)
Missing class com.amaze.filemanager.fileoperations.filesystem.smbstreamer.Streamer (referenced from: com.amaze.filemanager.fileoperations.filesystem.smbstreamer.Streamer com.amaze.filemanager.filesystem.files.FileUtils$5.val$s and 3 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.usb.SingletonUsbOtg (referenced from: void com.amaze.filemanager.ui.activities.MainActivity$2.onReceive(android.content.Context, android.content.Intent) and 8 other contexts)
Missing class com.amaze.filemanager.fileoperations.filesystem.usb.UsbOtgRepresentation (referenced from: void com.amaze.filemanager.ui.activities.MainActivity$2.onReceive(android.content.Context, android.content.Intent) and 2 other contexts)
Missing class com.amaze.filemanager.fileoperations.utils.OnLowMemory (referenced from: void com.amaze.filemanager.asynchronous.services.CopyService$DoInBackground$Copy.copyFiles(com.amaze.filemanager.filesystem.HybridFileParcelable, com.amaze.filemanager.filesystem.HybridFile, com.amaze.filemanager.utils.ProgressHandler) and 2 other contexts)
Missing class com.amaze.filemanager.fileoperations.utils.UpdatePosition (referenced from: com.amaze.filemanager.fileoperations.utils.UpdatePosition com.amaze.filemanager.asynchronous.management.ServiceWatcherUtil.UPDATE_POSITION and 27 other contexts)
Missing class com.amaze.filemanager.filesystem.compressed.sevenz.SevenZArchiveEntry (referenced from: void com.amaze.filemanager.asynchronous.asynctasks.compress.SevenZipHelperCallable.addElements(java.util.ArrayList) and 2 other contexts)
Missing class com.amaze.filemanager.filesystem.compressed.sevenz.SevenZFile (referenced from: void com.amaze.filemanager.asynchronous.asynctasks.compress.SevenZipHelperCallable.addElements(java.util.ArrayList) and 2 other contexts)
Missing class org.bouncycastle.asn1.ASN1ApplicationSpecific (referenced from: void jcifs.spnego.NegTokenInit.parse(byte[]))
Missing class org.bouncycastle.asn1.DERApplicationSpecific (referenced from: byte[] jcifs.spnego.NegTokenInit.toByteArray())
Missing class org.bouncycastle.jsse.BCSSLParameters (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
Missing class org.bouncycastle.jsse.BCSSLSocket (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 5 other contexts)
Missing class org.bouncycastle.jsse.provider.BouncyCastleJsseProvider (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.<init>())
Missing class org.conscrypt.Conscrypt$Version (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int))
Missing class org.conscrypt.Conscrypt (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int) and 4 other contexts)
Missing class org.conscrypt.ConscryptHostnameVerifier (referenced from: okhttp3.internal.platform.ConscryptPlatform$DisabledHostnameVerifier)
Missing class org.openjsse.javax.net.ssl.SSLParameters (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List))
Missing class org.openjsse.javax.net.ssl.SSLSocket (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
Missing class org.openjsse.net.ssl.OpenJSSE (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.<init>())
Missing class sun.security.x509.X509Key (referenced from: void net.i2p.crypto.eddsa.EdDSAEngine.engineInitVerify(java.security.PublicKey))

FAILURE: Build failed with an exception.

So I disable minifyEnabled and the build passed, but the Amaze crashes with NoClassDefFoundError in Android 13.

@TranceLove
Copy link
Collaborator Author

@Bambooin right, the minify rule. Added them back - although some can indeed just put dontwarn and skip them - either they're not used or should be available at system level. 🤔

@TranceLove TranceLove force-pushed the feature/sdk34 branch 4 times, most recently from 0350790 to 68df2d2 Compare July 11, 2024 15:29
@TranceLove
Copy link
Collaborator Author

TranceLove commented Jul 11, 2024

With gradlew clean spotlessApply spotlessCheck jacocoTestPlayReleaseUnitTestReport some other classes, especially at file_operations module are seen missing, failing unit tests.

Probably related to proguard rule at file_operations module IMO. Wild guess, still looking into it...

@TranceLove TranceLove force-pushed the feature/sdk34 branch 3 times, most recently from 01b96d6 to 4194638 Compare July 16, 2024 15:47
@TranceLove TranceLove marked this pull request as ready for review August 3, 2024 10:47
@TranceLove
Copy link
Collaborator Author

build test apk

VishalNehra
VishalNehra previously approved these changes Oct 8, 2024
@VishalNehra
Copy link
Member

getting following error at application startup
Caused by: java.lang.SecurityException: com.amaze.filemanager.debug: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts at android.os.Parcel.createExceptionOrNull(Parcel.java:3087) at android.os.Parcel.createException(Parcel.java:3071) at android.os.Parcel.readException(Parcel.java:3054) at android.os.Parcel.readException(Parcel.java:2996) at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684) at java.lang.reflect.Method.invoke(Native Method) at leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:85) at java.lang.reflect.Proxy.invoke(Proxy.java:1006) at $Proxy8.registerReceiverWithFeature(Unknown Source) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1868) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1804) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:765) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:765) at com.amaze.filemanager.ui.activities.MainActivity.onResume(MainActivity.java:1366) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1622)

@EmmanuelMess
Copy link
Member

@TranceLove is this anywhere near mergeable? seems somewhat urgent.

@TranceLove
Copy link
Collaborator Author

@EmmanuelMess Check. Will take a look.

TranceLove and others added 3 commits February 10, 2025 22:54
- build.gradle upgrades
- Code adaptations to remove switch cases to resource IDs
- Fix import of resource IDs from library level resources
- Minimum version requirement set to LOLLIPOP
- Fix Context.registerReceiver() on newer Androids
- Quirks to work around problems with ContextCompat.registerReceiver() at Robolectric tests
- Remove CMake version
@TranceLove
Copy link
Collaborator Author

build test apk

@EmmanuelMess EmmanuelMess self-requested a review February 11, 2025 02:18
@TranceLove
Copy link
Collaborator Author

Sorry the stock Github workflow still uses Java 11 while this PR requires Java 17. Need to build the test apks on your own 🙇

Updated:
- Gradle
- sshj
- Glide
- slf4j and logback
- AndroidX test libs
- gson
- okhttp
@@ -67,14 +67,15 @@ jobs:
strategy:
fail-fast: true
matrix:
api-level: [ 16, 19, 28 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a newer version too, like 35, to have 3 versions running

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved to a new issue if it breaks the tests.

@EmmanuelMess
Copy link
Member

I think it is now requesting exactly java 17, whereas before I could build with java 19:

Could not determine the dependencies of task ':app:packageFdroidDebug'.
> Could not create task ':app:compileFdroidDebugJavaWithJavac'.
   > Failed to calculate the value of task ':app:compileFdroidDebugJavaWithJavac' property 'javaCompiler'.
      > Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any, implementation=vendor-specific} for LINUX on x86_64.
         > No locally installed toolchains match and toolchain download repositories have not been configured.

* Try:
> Learn more about toolchain auto-detection at https://docs.gradle.org/8.7/userguide/toolchains.html#sec:auto_detection.
> Learn more about toolchain repositories at https://docs.gradle.org/8.7/userguide/toolchains.html#sub:download_repositories.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1s

Which is not really an issue, but is just a bit weird.

@EmmanuelMess
Copy link
Member

onOptionsItemSelected's switches got changed into if-else statements?

@Bambooin
Copy link
Contributor

Issue explanation (write below this line)

I built the apk with the latest commit, but failed to open the Amaze anymore.

./gradlew assemblefdroidRelease

This issue shows up with this pull request at beginning for my device, I try to build every time when the commit is changed in this pull request.

Exception

  • App Name: Amaze File Manager
  • Package: com.amaze.filemanager
  • Version: 3.10
  • User Action: Unknown
  • Request: Could not initialize ACRA crash report
  • OS: Linux Android 13 - 33
  • Device: violet
  • Model:
  • Product: lineage_violet
Crash log

org.acra.config.ACRAConfigurationException: Class org.acra.attachment.DefaultAttachmentProvider cannot be abstract.
	at org.acra.config.ClassValidator.check(ClassValidator.java:35)
	at org.acra.config.CoreConfigurationBuilder.build(CoreConfigurationBuilder.java:844)
	at com.amaze.filemanager.application.AppConfig.initACRA(AppConfig.java:256)
	at com.amaze.filemanager.application.AppConfig.attachBaseContext(AppConfig.java:126)
	at android.app.Application.attach(Application.java:346)
	at android.app.Instrumentation.newApplication(Instrumentation.java:1244)
	at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1458)
	at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1395)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6772)
	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7924)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)


@EmmanuelMess
Copy link
Member

I'm getting on the release configuration (it may be because it is minified)

 FATAL EXCEPTION: main
                                                                                                    Process: com.amaze.filemanager, PID: 7038
                                                                                                    java.lang.NoSuchFieldError: No field UNKNOWN of type Lcom/amaze/filemanager/fileoperations/filesystem/OpenMode; in class Lcom/amaze/filemanager/fileoperations/filesystem/OpenMode; or its superclasses (declaration of 'com.amaze.filemanager.fileoperations.filesystem.OpenMode' appears in /data/app/~~7amMas2Iua20Kpjju6IT5g==/com.amaze.filemanager-qtcbB6LVf1jEoCp4ixLb5w==/base.apk)
                                                                                                    	at com.amaze.filemanager.ui.views.drawer.Drawer.refreshDrawer(Drawer.java:297)
                                                                                                    	at com.amaze.filemanager.ui.activities.MainActivity.onResume(MainActivity.java:1358)
                                                                                                    	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1603)
                                                                                                    	at android.app.Activity.performResume(Activity.java:8743)
                                                                                                    	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4952)
                                                                                                    	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4995)
                                                                                                    	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
                                                                                                    	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

@TranceLove
Copy link
Collaborator Author

onOptionsItemSelected's switches got changed into if-else statements?

As of Gradle Android 8.0,

AGP 8.0 generates R classes with non-final fields by default.

see https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes?hl=en#default-changes and also https://googlesamples.github.io/android-custom-lint-rules/checks/NonConstantResourceId.md.html

@Bambooin
Copy link
Contributor

The ACRA crash was fixed in latest commit, and the size change is very tiny with minifyEnabled false: (11440019 - 11362203) / 11362203 = 0.00684

No issue found with Android 13 device anymore.

@TranceLove
Copy link
Collaborator Author

TranceLove commented Feb 13, 2025

Re: library modules not minified on release config in submodules' build.gradle, as mentioned here this is not necessary - app minification will minify everything anyway.

@EmmanuelMess

- Fix release build problems, by setting lib modules no minification
- Upgrade ACRA to 5.12.0
- Remove unused lib and dependency declarations
EmmanuelMess
EmmanuelMess previously approved these changes Feb 13, 2025
@EmmanuelMess
Copy link
Member

Tested and passes.

No special requirements and deprecations as reported at https://developer.android.com/google/play/billing/migrate-gpblv7?hl=en#6to7, should be fine to update as-is
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

Successfully merging this pull request may close these issues.

4 participants