AndroidStudio编译调试aosp11R 的Launcher3

1.下载aosp并编译

2.下载Launcher3
可以直接使用aosp中的,也可以使用git单独下载

git clone https://android-review.googlesource.com/platform/packages/apps/Launcher3.git

可以使用国内镜像下载,使用中科大源

git clone git://mirrors.ustc.edu.cn/aosp/platform/packages/apps/Launcher3.git

AndroidStudio编译调试aosp11R 的Launcher3_第1张图片

#查看tag
git tag
#git checkout切换到自己aosp的分支,我的是android-11.0.0_r40
git checkout android-11.0.0_r40

AndroidStudio编译调试aosp11R 的Launcher3_第2张图片
3.用AndroidStudio打开

修改gralde.properties,将COMPILE_SDK=android-R改为android-30

# Until all the dependencies move to android X
android.useAndroidX = true
android.enableJetifier = true

ANDROID_X_VERSION=1+

GRADLE_CLASS_PATH=com.android.tools.build:gradle:3.5.1

PROTOBUF_CLASS_PATH=com.google.protobuf:protobuf-gradle-plugin:0.8.8
PROTOBUF_DEPENDENCY=com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7

BUILD_TOOLS_VERSION=28.0.3
COMPILE_SDK=android-30

No matching configuration of project :IconLoader was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'app' with value 'aosp', attribute 'recents' with value 'withoutQuickstep', attribute 'com.android.build.gradle.internal.dependency.AndroidTypeAttr' with value 'Aar' but:

注释掉

//    implementation project(':IconLoader')
错误: 找不到符号
import com.android.launcher3.icons.DotRenderer;

错误: 找不到符号
import com.android.launcher3.icons.IconNormalizer;
错误: 程序包com.android.launcher3.logger.LauncherAtom不存在
错误: 找不到符号
import com.android.systemui.plugins.PluginListener;
错误: 程序包com.google.protobuf.nano不存在
      com.google.protobuf.nano.MessageNano

将aosp-11-2/out/target/common/obj/JAVA_LIBRARIES/Launcher3CommonDepsLib_intermediates下的classes.jar,重命名为Launcher3CommonDepsLib.jar,导入AndroidStudio
添加依赖

implementation files('libs/Launcher3CommonDepsLib.jar')

类重复

Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules classes.jar (androidx.core:core:1.6.0) and jetified-Launcher3CommonDepsLib.jar (Launcher3CommonDepsLib.jar)
Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules classes.jar (androidx.core:core:1.6.0) and jetified-Launcher3CommonDepsLib.jar (Launcher3CommonDepsLib.jar)
Duplicate class android.support.v4.os.ResultReceiver found in modules classes.jar (androidx.core:core:1.6.0) and jetified-Launcher3CommonDepsLib.jar (Launcher3CommonDepsLib.jar)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules classes.jar (androidx.core:core:1.6.0) and jetified-Launcher3CommonDepsLib.jar (Launcher3CommonDepsLib.jar)

注释掉

//    implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}"
//    implementation "androidx.recyclerview:recyclerview:1.1.0"
//    implementation "androidx.preference:preference:${ANDROID_X_VERSION}"

可以运行了
4.编译运行,我这里是运行到api25的模拟器上。

Could not identify launch activity: Default Activity not found
Error while Launching activity
Failed to launch an application on all devices

AndroidManifest.xml的com.android.launcher3.Launcher 添加

<category android:name="android.intent.category.LAUNCHER"/>
 at com.android.launcher3.Utilities.(Utilities.java:107)
        at com.android.launcher3.config.FeatureFlags.getDebugFlag(FeatureFlags.java:275)
        at com.android.launcher3.config.FeatureFlags.(FeatureFlags.java:67)
        at com.android.launcher3.LauncherProvider.onCreate(LauncherProvider.java:126)

注释掉,日志信息

//        if (FeatureFlags.IS_STUDIO_BUILD) {
//            Log.d(TAG, "Launcher process started");
//        }
at com.android.launcher3.Utilities.(Utilities.java:107)
        at com.android.launcher3.config.FeatureFlags.getDebugFlag(FeatureFlags.java:275)
        at com.android.launcher3.config.FeatureFlags.(FeatureFlags.java:67)
        at com.android.launcher3.LauncherProvider.onCreate(LauncherProvider.java:126)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)

修改Utilities.java:107

public static final Person[] EMPTY_PERSON_ARRAY = null;
at com.android.launcher3.qsb.QsbContainerView.getSearchWidgetProviderInfo(QsbContainerView.java:98)
        at com.android.launcher3.qsb.QsbContainerView$QsbFragment.getSearchWidgetProvider(QsbContainerView.java:329)
        at com.android.launcher3.qsb.QsbContainerView$QsbFragment.createQsb(QsbContainerView.java:195)
        at com.android.launcher3.qsb.QsbContainerView$QsbFragment.onCreateView(QsbContainerView.java:189)

修改QsbContainerView.java:98

appWidgetManager.getInstalledProviders()

现在可以运行了
AndroidStudio编译调试aosp11R 的Launcher3_第3张图片
AndroidStudio编译调试aosp11R 的Launcher3_第4张图片

可以的代码:https://gitee.com/aaaa_sss/launcher3

你可能感兴趣的:(android,android,gradle,android,studio)