简体   繁体   English

引用“ systemui”资源以在Oreo中构建RRO /叠加主题

[英]Referencing `systemui` resources for building RRO/overlay themes in Oreo

I'm trying to build an RRO/overlay theme for my device running Oreo to change status-bar icons/indicators. 我正在尝试为运行Oreo的设备构建RRO /叠加主题,以更改状态栏图标/指示器。

I pulled AOSP's status-bar icons and included them in the package with a single modification: changing references to internal systemui package from ?attr/XXX to ?*com.android.systemui:attr/XXX . 我拉了AOSP的状态栏图标,并进行了一次修改systemui它们包含在包中: systemui内部systemui包的引用从?attr/XXX更改为?*com.android.systemui:attr/XXX Every time I build, the following errors are thrown: 每次构建时,都会引发以下错误:

\thm\res\drawable\stat_sys_wifi_signal_0.xml:24: error: Error: No resource found that matches the given name (at 'fillColor' with value '?*com.android.systemui:attr/fillColor').

\thm\res\drawable\stat_sys_wifi_signal_0.xml:27: error: Error: No resource found that matches the given name (at 'fillColor' with value '?*com.android.systemui:attr/backgroundColor').

I'm using command-line to build my APK, and this is my file setup: 我正在使用命令行构建我的APK,这是我的文件设置:

./AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="test.theme.aospstatusbar">

    <overlay
        android:priority="1"
        android:targetPackage="com.android.systemui"
</manifest>

The following file is a sample of the drawables I included in the package, and in which the error samples above are referring to: 以下文件是我包含在包装中的可绘制对象的示例,其中上面的错误示例所指:

./res/drawable/stat_sys_wifi_signal_0.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="18.41dp"
        android:height="18.41dp"
        android:viewportWidth="21.2"
        android:viewportHeight="21.2">
      <group
          android:translateX="0.5"
          android:translateY="2.0">
        <path
            android:pathData="M18.79,9.79c-0.32,-0.32 -0.83,-0.32 -1.15,0L16.43,11l-1.21,-1.21c-0.32,-0.32 -0.83,-0.32 -1.15,0L14.06,9.8l0,0c-0.32,0.32 -0.32,0.83 0,1.15l1.21,1.21l-1.21,1.21l0,0c-0.32,0.32 -0.32,0.83 0,1.15l0.01,0.01c0.32,0.32 0.83,0.32 1.15,0l1.21,-1.21l1.21,1.21c0.32,0.32 0.83,0.32 1.15,0c0.32,-0.32 0.32,-0.83 0,-1.15l-1.21,-1.21l1.21,-1.21C19.1,10.64 19.1,10.13 18.79,9.79z"
            android:fillColor="?*com.android.systemui:attr/fillColor"/>
        <path
            android:pathData="M11.69,7.44h6.27L19.95,5c0.4,-0.49 0.3,-1.22 -0.23,-1.56c-1.6,-1.05 -5.04,-2.9 -9.62,-2.9c-4.59,0 -8.03,1.85 -9.62,2.9C-0.05,3.78 -0.16,4.51 0.24,5l9.02,11.08c0.42,0.52 1.22,0.52 1.64,0l0.78,-0.96V7.44z"
            android:fillColor="?*com.android.systemui:attr/backgroundColor"/>
      </group>
</vector>

I build using the following command ( aapt being in build-tools\\26.0.3 ): 我使用以下命令进行build-tools\\26.0.3aapt位于build-tools\\26.0.3 ):

aapt package -M \thm\AndroidManifest.xml -S \thm\res -I %sdk%\platforms\android-26\android.jar -F \thm\build\overlay.apk -f

I believe the problem is in referencing from the systemui package? 我相信问题出在从systemui包中引用吗? Am I doing something wrong? 难道我做错了什么?

I don't know if the answer is still relevant but I was trying to do the same thing and I have found a solution. 我不知道答案是否仍然有用,但是我试图做同样的事情,但已经找到了解决方案。 Just put -I systemui.apk into the aapt command and it should compile. 只需将-I systemui.apk放入aapt命令中,即可进行编译。 Assuming you have the pulled systemui package in the same folder. 假设您在同一文件夹中有提取的systemui软件包。 This should work for any package. 这适用于任何软件包。

You cannot do that .You said you have pulled the AOSP resource for System UI , you can directly use them in your build. 您不能这样做。您说您已经为系统UI提取了AOSP资源,可以直接在构建中使用它们。

Detail explanation : 详细说明:

The resource you are trying to access is part of com.android.systemui package which is not present in the android.jar you have passed to your aapt command . 您尝试访问的资源是com.android.systemui包的一部分,该包在传递给aapt命令的android.jar中不存在。 The only resources present in android.jar accessible to 3rd party are the ones listed in the public.xml file of android framework : 第三方可访问的android.jar中存在的唯一资源是android框架的public.xml文件中列出的资源:

http://androidxref.com/8.0.0_r4/xref/frameworks/base/core/res/res/values/public.xml http://androidxref.com/8.0.0_r4/xref/frameworks/base/core/res/res/values/public.xml

The aapt when trying to processDebugResources looks for the resource in android.jar and \\thm\\res . 尝试处理debugResources时,aapt在android.jar和\\ thm \\ res中查找资源。 Since it could not find the resource into both , it throws the no resource found error . 由于无法同时在两者中找到资源,因此将引发“找不到资源”错误。

Solution : 解决方案:

Create similar resource as present here and use them in your theme. 创建此处显示的类似资源,并在您的主题中使用它们。 You have to resolve every dependency , such that your apk can run independently on any android device . 您必须解决所有依赖关系,以便您的apk可以在任何android设备上独立运行。

http://androidxref.com/8.0.0_r4/xref/frameworks/base/packages/SystemUI/res/ http://androidxref.com/8.0.0_r4/xref/frameworks/base/packages/SystemUI/res/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM