常规构建工作正常,但在EXPECTED RESOURCE TYPE ID上签署了构建错误

问题描述 投票:0回答:1

当我定期构建我的应用程序时,它构建没有错误。当我尝试构建SIGNED APK时,我收到错误...

错误:类型为id [ResourceType]的预期资源

标记的代码行是......

tv = (TextView)myView.findViewById(R.id.tvTimestamp);

该ID在相应的布局xml中定义如下:

<FrameLayout
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:padding="5dp"
   >

   <!-- Clock -->
   <ImageView
       android:layout_width="12dp"
       android:layout_height="12dp"
       android:src="@drawable/ic_clock_white"
       android:layout_gravity="center_vertical"
       />

   <TextView
       android:id="@+id/tvTimestamp"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center_vertical"
       android:textSize="14sp"
       android:layout_marginLeft="20dp"
       />
 </FrameLayout>

不知道为什么这个错误。

谢谢

皮特

android apk android-resources
1个回答
0
投票

这不是编译器错误,它是一个lint警告。

要解决此问题,请尝试以下方法之一:

  • 清理项目并再次同步
  • 使用View.generateViewId()设置任意id
  • ids.xml中创建一个res/values/文件

如果调试版本在仿真器/物理设备上正确运行,那么您可以安全地继续并通过以下方式禁止此警告:

  • 单击错误并选择“禁用错误”
  • build.gradle中添加以下行 android { lintOptions{ disable "ResourceType" } }
© www.soinside.com 2019 - 2024. All rights reserved.