English | 中文文档
- Instead of changing the project's directory structure, we add additional configurations and dependencies to build Gradle environment support
- Scripts are used to remove some attributes and fields not supported by AS, then utilize git local ignore
- A small amount of code is modified, but overall it does not affect its compilation as an AOSP subproject using mm
- The running effect will be slightly different from the native one, which is caused by style differences due to failed references to private attributes after being separated from the source code
- Gradle 6.5
- JDK version 8
# Setup build environment
gradle wrapper
# Execute pre-filter task
./gradlew :Filter:run
# Build and package
./gradlew assemble
- Android Studio 4.2.2 & JDK version 8
Step 2: Execute Build APK in Android Studio, then push the apk to the Settings directory on the device
adb push Settings.apk /system/system_ext/priv-app/Settings/
adb shell killall com.android.settings
adb reboot
// AOSP/android-11/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-header.jar
compileOnly files('libs/framework.jar')
// AOSP/android-11/out/soong/.intermediates/libcore/core-all/android_common/javac/core-all.jar
compileOnly files('libs/core-all.jar')
// AOSP/android-11/out/soong/.intermediates/frameworks/opt/telephony/telephony-common/android_common/javac/telephony-common.jar
compileOnly files('libs/telephony-common.jar')
// AOSP/android-11/out/soong/.intermediates/frameworks/opt/net/ims/ims-common/android_common/javac/ims-common.jar
compileOnly files('libs/ims-common.jar')
// AOSP/android-11/out/soong/.intermediates/tools/platform-compat/java/android/compat/annotation/app-compat-annotations/android_common/turbine/app-compat-annotations.jar
compileOnly files('libs/app-compat-annotations.jar')
// AOSP/android-11/prebuilts/sdk/current/androidx/m2repository/androidx/preference/preference/1.2.0-alpha01/preference-1.2.0-alpha01.aar
implementation(name: 'preference-1.2.0-alpha01', ext: 'aar')
PS: androidx.preference is not easy to reference in the following way, so it is replaced with static dependency
## implementation 'androidx.preference:preference:1.2.0-alpha01'
// Built-in aar in the project, no need to import from elsewhere
implementation(name: 'contextualcards', ext: 'aar')
// AOSP/android-11/out/soong/.intermediates/packages/apps/Settings/settings-logtags/android_common/javac/settings-logtags.jar
implementation files('libs/settings-logtags.jar')
// AOSP/android-11/out/soong/.intermediates/packages/apps/Settings/statslog-settings/android_common/javac/statslog-settings.jar
implementation files('libs/statslog-settings.jar')
// AOSP/android-11/out/soong/.intermediates/external/zxing/core/zxing-core-1.7/android_common/combined/zxing-core-1.7.jar
implementation files('libs/zxing-core-1.7.jar')
// AOSP/android-11/out/soong/.intermediates/external/guava/guava/android_common/turbine-combined/guava.jar
implementation files('libs/guava.jar')
// AOSP/android-11/out/soong/.intermediates/hardware/interfaces/dumpstate/1.0/android.hardware.dumpstate-V1.0-java/android_common/javac/android.hardware.dumpstate-V1.0-java.jar
implementation files('libs/android.hardware.dumpstate-V1.0-java.jar')
// AOSP/android-11/out/soong/.intermediates/hardware/interfaces/dumpstate/1.1/android.hardware.dumpstate-V1.1-java/android_common/javac/android.hardware.dumpstate-V1.1-java.jar
implementation files('libs/android.hardware.dumpstate-V1.1-java.jar')
// AOSP/android-11/out/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base-V1.0-java/android_common/javac/android.hidl.base-V1.0-java.jar
implementation files('libs/android.hidl.base-V1.0-java.jar')
Import code from specific paths directly into the project as Module dependencies. You can reference them through implementation project during build, or build aar with gradle build and place it in the libs folder.
// AOSP/android-11/frameworks/libs/systemui/iconloaderlib
implementation project(':iconloaderlib')
// AOSP/android-11/frameworks/opt/net/wifi/libs/WifiTrackerLib
implementation project(':WifiTrackerLib')
// AOSP/android-11/external/setupcompat
implementation project(':setupcompat')
// AOSP/android-11/external/setupdesign
implementation project(':setupdesign')
// AOSP/android-11/frameworks/base/packages/SettingsLib
implementation project(':SettingsLib')
implementation project(':SettingsLib:ActionBarShadow')
implementation project(':SettingsLib:RestrictedLockUtils')
implementation project(':SettingsLib:ActionButtonsPreference')
implementation project(':SettingsLib:HelpUtils')
implementation project(':SettingsLib:SettingsSpinner')
implementation project(':SettingsLib:Tile')
implementation project(':SettingsLib:LayoutPreference')
implementation project(':SettingsLib:AppPreference')
implementation project(':SettingsLib:RadioButtonPreference')
implementation project(':SettingsLib:search')
implementation project(':SettingsLib:SearchWidget')
implementation project(':SettingsLib:EntityHeaderWidgets')
implementation project(':SettingsLib:AdaptiveIcon')
implementation project(':SettingsLib:DisplayDensityUtils')
Find the signing certificates in the AOSP/android-11/build/target/product/security path and use keytool-importkeypair to generate the keystore. Execute the following command:
./keytool-importkeypair -k platform.keystore -p 123456 -pk8 platform.pk8 -cert platform.x509.pem -alias platform
And add the following code to the gradle configuration:
signingConfigs {
platform {
storeFile file("platform.keystore")
storePassword '123456'
keyAlias 'platform'
keyPassword '123456'
}
}
buildTypes {
release {
debuggable false
minifyEnabled false
signingConfig signingConfigs.platform
}
debug {
debuggable true
minifyEnabled false
signingConfig signingConfigs.platform
}
}
git ls-files -v | grep '^h\ '
git update-index --assume-unchanged $path
git update-index --no-assume-unchanged $path
git ls-files -v | grep '^h' | awk '{print $2}' |xargs git update-index --no-assume-unchanged

















