shadowsocks / shadowsocks-android

A shadowsocks client for Android
Other
35.23k stars 11.57k forks source link

Target Android 14 #3165

Closed AaronChen0 closed 2 months ago

AaronChen0 commented 2 months ago

This is an attempt to update shadowsocks-android to target Android 14 and its dependencies.

Please read this for changes in AGP8. Some build option default values change.

The build succeeded and the debug apk works in both my android 14 and android 12 phones. You can try a debug build apk here. The debug build log can be found here.

Main updates:

AaronChen0 commented 2 months ago

In a release branch here, the build will fail with the following R8 missing class errors:

WARNING: /home/circleci/code/mobile/build/intermediates/merged_java_res/release/mergeReleaseJavaResource/base.jar: R8: Unexpected reference to missing service class: META-INF/services/java.net.spi.InetAddressResolverProvider.
WARNING: /home/circleci/code/mobile/build/intermediates/merged_java_res/release/mergeReleaseJavaResource/base.jar: R8: Unexpected reference to missing service implementation class in META-INF/services/java.net.spi.InetAddressResolverProvider: org.xbill.DNS.spi.DnsjavaInetAddressResolverProvider.
WARNING: /home/circleci/code/mobile/build/intermediates/merged_java_res/release/mergeReleaseJavaResource/base.jar: R8: Unexpected reference to missing service class: META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor.
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/circleci/code/mobile/build/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class lombok.Generated (referenced from: org.slf4j.Logger org.xbill.DNS.Compression.log and 3 other contexts)
Missing class org.slf4j.impl.StaticLoggerBinder (referenced from: void org.slf4j.LoggerFactory.bind() and 3 other contexts)
Missing class org.xbill.DNS.spi.DnsjavaInetAddressResolverProvider (referenced from: java.util.List kotlinx.coroutines.internal.FastServiceLoader.load(java.lang.Class, java.lang.ClassLoader))
Missing class sun.net.spi.nameservice.NameServiceDescriptor (referenced from: org.xbill.DNS.spi.DNSJavaNameServiceDescriptor)

Adding the following to proguard-rules.pro fixes the R8 errors and the apk works normally.

-dontwarn java.net.spi.InetAddressResolverProvider
-dontwarn org.slf4j.impl.StaticLoggerBinder
-dontwarn org.xbill.DNS.spi.DnsjavaInetAddressResolverProvider
-dontwarn sun.net.spi.nameservice.NameServiceDescriptor
-dontwarn lombok.Generated

I am not familiar with R8 proguard rules, should I just add dontwarn if the app works normally in my use? Check the builds here.

Mygod commented 2 months ago

Yes add these rules.

-dontwarn lombok.Generated
-dontwarn org.slf4j.impl.StaticLoggerBinder
-dontwarn org.xbill.DNS.spi.DnsjavaInetAddressResolverProvider
-dontwarn sun.net.spi.nameservice.NameServiceDescriptor
AaronChen0 commented 2 months ago

Build successfully and work in my phones. Please review.

Mygod commented 2 months ago

Thanks! And be patient while I download rust. :)