常规构建工作正常,但是在类型ID的预期资源上签名的构建错误



定期构建我的应用程序时,它没有错误。当我尝试构建签名的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>

不确定为什么这是错误的。

谢谢

pete

这不是编译器错误,这是一份警告。

要解决它,请尝试以下一个:

  • 清洁您的项目并再次同步
  • 使用View.generateViewId()设置任意ID
  • res/values/中创建ids.xml文件

如果调试版本在模拟器/物理设备上正确运行,则可以安全地继续抑制此警告:

  • 单击错误并选择禁用错误
  • build.gradle

    中添加以下行
    android { 
       lintOptions{
             disable "ResourceType"
       }
    }
    

最新更新