Modify the corresponding sdk version
Change targetSdkVersion to 34, minSdkVersion greater than 23, and compileSdkVersion to 34
Please note the following points
-
The Gradle version needs to be upgraded to at least 7.4.2, otherwise an error will be reported Caused by: java.io.IOException: AAPT2 process unexpectedly exit. Error output:
aapt2 W 06-26 09 :56:23 8280 8280 LoadedArsc.cpp:682] Unknown chunk type '200'. -
It is recommended to upgrade the Gradle version to 8.0.1 or above, otherwise all xml files in the project need to be rectified. You can refer to https://code-examples.net/zh-TW/q/2e3f77, otherwise an error will be reported Task:app :shrinkReleaseRes FAILED
Execution failed for task ':app:shrinkReleaseRes'.
A failure occurred while executing com.android.build.gradle.internal.transforms.ShrinkProtoResourcesAction
ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog. -
If Gradle is upgraded to 8.0 or above and jdk needs to be upgraded to 17 or above, it is recommended to use Tools-AGP Upgrade Assistant to automatically upgrade. It will automatically upgrade the files that need to be changed under the project. Otherwise, you need to add a lot of configurations manually. When upgrading, you need to pay attention to all Maven repositories. Http is changed to Https, and the use of Http library is not allowed.
-
If R8 obfuscation is used, Java17 will enable R8 fullMode obfuscation mode by default, which will cause a crash when the network requests the serialized data structure. You can turn off fullMode obfuscation and configure it in gradle.properties
android.enableR8.fullMode = false
The above are the compilation problems and pitfalls encountered when adapting to Android 14
For specific adaptation methods, please refer to the official documentation.