Android9.0 原生Launcher3 Androidstdio编译分享

时间:2025-01-31 08:56:48

最近在公司有修改原生Launcher3的UI,在服务器端不能实时预览,修改验证比较麻烦,所以把Launcher3的源码拿到本地进行编译

刚拿下来遇到以下问题点报错:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\azxjq\Desktop\Launcher3\' line: 15

* What went wrong:
A problem occurred evaluating root project 'Launcher3'.
> Failed to apply plugin [id '']
> Could not create an instance of type .
> .<init>(Ljava/lang/String;Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;Lorg/gradle/api/internal/file/collections/DirectoryFileTreeFactory;)V

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================


第一处报错 Failed to apply plugin [id '' 这里未能应用插的原因是因为对版本有要求

protobuf-gradle-plugin 的版本至少在0.8.13,Gradle的最低版本 5.6 and Java最低8以上。

因此只需更新使用版本。

buildscript {
        repositories {
                mavenCentral()
                google()
        }
        dependencies {
                classpath ':gradle:3.2.0-alpha12'
                classpath ':protobuf-gradle-plugin:0.8.13'
        }

}

 解决完以后继续build:

A problem occurred evaluating root project 'Launcher3'.
> ASCII

出现此问题的原因是里面的版本和我本地不一致,修改一下版本,这里根据自己本地的版本修改

dependencies {
        classpath ':gradle:3.4.1'
        classpath ':protobuf-gradle-plugin:0.8.13'
}

 接下来遇到一下报错:

Execution failed for task ':preAospDebugBuild'.
> Could not resolve all files for configuration ':aospDebugCompileClasspath'.
> Could not find :support-v4:28.0.0-SNAPSHOT.
Required by:
project :
> Could not find :support-dynamic-animation:28.0.0-SNAPSHOT.
Required by:
project :
> Could not find :recyclerview-v7:28.0.0-SNAPSHOT.
Required by:
project :

Possible solution:
- Declare repository providing the artifact, see the documentation at /current/userguide/declaring_repositories.html
 

一开始我以为这里是因为网络的问题,导致所需要的的jar包下载不下来,后来我发现后面加一个SNAPSHOT是什么鬼 ,我果断删除继续build。

import ;
^
符号: 类 IPackageDeleteObserver
位置: 程序包 

filter_HOST.addAction(WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
^
符号: 变量 WIFI_AP_STATE_CHANGED_ACTION
位置: 类 WifiManager

现在报到具体代码的错误,报的错误远不止我贴出来的这么多,这些都是因为我们系统添加了自己的API,android标准的sdk自然找不到我们新增的api,那么这个问题怎么解决呢。

我们可以自己编译出jar包,通过修改的方式,优先使用我们的jar。

具体方式可以参考链接这里 

后面就是还有因为launcher加了

android:sharedUserId=""

 因为我们需要我们自己系统的签名文件,配置以后就可以正常运行了。