项目作者: pomeloJiang

项目描述 :
将MTK提供的Android8.1 Launcher3源码导入至Android Studio编译运行
高级语言: Java
项目地址: git://github.com/pomeloJiang/Launcher3.git
创建时间: 2018-01-25T13:59:25Z
项目社区:https://github.com/pomeloJiang/Launcher3

开源协议:Other

下载


Launcher3

将MTK提供的Android8.1 Launcher3源码导入至Android Studio编译运行

最近开始做Android 8.1的项目,Launcher3相对于 7.0 改动比较大。将Launcher3导入至Android Studio方便调试。

参考网上的一篇文章:https://www.jianshu.com/p/28b1d205b4e6

修改protos目录下launcher_dump.proto

将原来 option java_package = “com.android.launcher3.model”;

修改成 option java_package = “com.android.launcher3.model.nano”;
为了能定位到LauncherDumpProto这个接口


build.gradle

MTK提供的源码中加了测试框架

  1. - final String SUPPORT_LIBS_VERSION = '26.0.0-SNAPSHOT'
  2. + final String SUPPORT_LIBS_VERSION = '27.0.1'
  3. dependencies {
  4. compile "com.android.support:support-v4:${SUPPORT_LIBS_VERSION}"
  5. compile "com.android.support:support-dynamic-animation:${SUPPORT_LIBS_VERSION}"
  6. compile "com.android.support:recyclerview-v7:${SUPPORT_LIBS_VERSION}"
  7. compile "com.android.support:palette-v7:${SUPPORT_LIBS_VERSION}"
  8. compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
  9. testCompile 'junit:junit:4.12'
  10. androidTestCompile "org.mockito:mockito-core:1.9.5"
  11. androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
  12. androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
  13. androidTestCompile 'com.android.support.test:runner:0.5'
  14. androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
  15. androidTestCompile "com.android.support:support-annotations:${SUPPORT_LIBS_VERSION}"
  16. }

我用的Android Studio版本是3.0.1,在build的时候找不到 “26.0.0-SNAPSHOT”这个版本下的依赖包,于是我将 SUPPORT_LIBS_VERSION 改成了目前最新的的 27.0.1版本,重新编译仍会报错,按照错误提示将goole()仓库添加进去就好了。

  1. repositories {
  2. mavenCentral()
  3. jcenter()
  4. google()
  5. }

编译运行

  1. + 由于Android Studio不能卸载已存在的Launcher3,所以不能直接运行,需要我们进入adb shell手动删除以下文件:
  2. + 1rm -r system/priv-app/Launcher3/Launcher3.apk
  3. + 2rm -r data/data/com.android.launcher3
  4. + 3、退出shell,清除Launcher3的数据 adb shell pm clear com.android.launcher3
  5. + 4、重启设备 adb reboot
  6. + 5、运行

运行的时候会提示你找不到Default Activity,点击Edit Configuration -> Launch Options ,在Launch选项这里 将Default Activity改为 Specified Activity,然后将Activity选为 com.android.launcher3.Launcher 便可以正常编译运行

最后

如果喜欢原生干净的代码,也给大家提供个Google AOSP版的Launcher3地址:

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