栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

AndroidStudio编译调试aosp11R 的Launcher3

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

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


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 添加


 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()

现在可以运行了

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/785655.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号