Android资源链接失败,仅限于我的前景可绘制物,而不是我的背景可绘制物。

huangapple go评论58阅读模式
英文:

Android resource linking failed only on my foreground drawables not my background ones

问题

我正在尝试创建一个.aab文件以将我的应用程序发布到Play商店,但我在底部导航的前景可绘制对象上遇到了Android资源链接失败的问题。

一个可绘制对象的XML示例:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="108dp"
    android:height="108dp"
    android:viewportWidth="108"
    android:viewportHeight="108"
    android:tint="#000000">
  <group android:scaleX="2.61"
      android:scaleY="2.61"
      android:translateX="22.68"
      android:translateY="22.68">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
  </group>
</vector>

我的底部导航XML:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/home"
        android:title="Home"
        android:icon="@drawable/ic_home_foreground"/>
    <item
        android:id="@+id/workout"
        android:title="Workout"
        android:icon="@drawable/ic_workout_foreground"/>
    <item
        android:id="@+id/history"
        android:title="History"
        android:icon="@drawable/ic_history_foreground"/>

</menu>

希望这些信息对您有所帮助。

英文:

I am trying to create an .aab file to post my app to play store but im getting a android resource linking failed on only my foreground drawbales of my bottom navigation,

xml of one of the drawables:

&lt;vector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:width=&quot;108dp&quot;
    android:height=&quot;108dp&quot;
    android:viewportWidth=&quot;108&quot;
    android:viewportHeight=&quot;108&quot;
    android:tint=&quot;#000000&quot;&gt;
  &lt;group android:scaleX=&quot;2.61&quot;
      android:scaleY=&quot;2.61&quot;
      android:translateX=&quot;22.68&quot;
      android:translateY=&quot;22.68&quot;&gt;
    &lt;path
        android:fillColor=&quot;@android:color/white&quot;
        android:pathData=&quot;M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z&quot;/&gt;
  &lt;/group&gt;
&lt;/vector&gt;

My bottom nav xml:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

    &lt;item
        android:id=&quot;@+id/home&quot;
        android:title=&quot;Home&quot;
        android:icon=&quot;@drawable/ic_home_foreground&quot;/&gt;
    &lt;item
        android:id=&quot;@+id/workout&quot;
        android:title=&quot;Workout&quot;
        android:icon=&quot;@drawable/ic_workout_foreground&quot;/&gt;
    &lt;item
        android:id=&quot;@+id/history&quot;
        android:title=&quot;History&quot;
        android:icon=&quot;@drawable/ic_history_foreground&quot;/&gt;

&lt;/menu&gt;

答案1

得分: 1

你可能将资源添加到了调试文件夹中 - 这意味着你可以从Android Studio运行应用的调试版本,但当你尝试创建发布版本时,编译器找不到该资源。请检查你的资源父文件夹/查找器/资源管理器,如果是这样的话,将你的资源文件从

app/src/debug/resources/drawable/

移动到

app/src/main/resources/drawable/

英文:

Probably you added your resources in debug folder - which means that you can run the debug version of the app from android studio, but when you try to create a release one the compiler can not find the resource. Check your resource parent folder/finder/explorer and if so ^^, move your resource file

from
> app/src/debug/resources/drawable/

to

> app/src/main/resources/drawable/

huangapple
  • 本文由 发表于 2023年2月14日 02:57:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440144.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定