android 为什么我会得到“fd不得为空”验证错误添加贴纸包到WhatsApp?

qgelzfjb  于 2023-01-03  发布在  Android
关注(0)|答案(2)|浏览(139)

我正在创建一个Android应用程序,用于向WhatsApp添加自定义贴纸。我遵循了this example,但在向WhatsApp添加贴纸时,显示了一个错误对话框,消息为***“此贴纸包有一些问题,无法添加到Whatsap”。我在活动结果中得到的验证错误为“fd不得为空”**。我无法找到此错误的原因。在这种情况下,FD是什么?

我已经尝试:-我尝试添加publisherEmail,网站等所有字段,但仍然得到这个错误。

  • 对于托盘图像,我已经在我的资产文件夹中添加了一个webp图标,并在trayImageFile字段中提供了它的名称。

需要什么:-我从firebase中获取的自定义贴纸包应该添加到WhatsApp中,无论是正常的还是动画的。

这是从我的项目创建的json文件

[
  {
    "androidPlayStoreLink":"i have added valid playstore link here removed purposely here",
    "animatedStickerPack":false,
    "avoidCache":false,
    "identifier":"50016",
    "imageDataVersion":"",
    "index":"0",
    "isCustom":false,
    "isPremimmum":false,
    "isWhitelisted":false,
    "licenseAgreementWebsite":"",
    "name":"Thanks",
    "privacyPolicyWebsite":"",
    "publisher":"TEST CONTENT",
    "publisherEmail":"1",
    "publisherWebsite":"",
    "stickerMode":0,
    "stickers":[
      {
        "emojis":[

        ],
        "imageFileName":"500161",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500161.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500162",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500162.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500163",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500163.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500164",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500164.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500165",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500165.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500166",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500166.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500167",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500167.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500168",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500168.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"500169",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/500169.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001610",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001610.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001611",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001611.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001612",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001612.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001613",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001613.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001614",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001614.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001615",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001615.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001616",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001616.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001617",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001617.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001618",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001618.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001619",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001619.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001620",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001620.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001621",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001621.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001622",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001622.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001623",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001623.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001624",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001624.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001625",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001625.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001626",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001626.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001627",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001627.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001628",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001628.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001629",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001629.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"5001630",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/50016/5001630.webp"
      }
    ],
    "stickersAddedIndex":30,
    "totalSize":0,
    "trayImageFile":"my_tray_icon.webp"
  },
  {
    "androidPlayStoreLink":"i have added valid playstore link here removed purposely here",
    "animatedStickerPack":true,
    "avoidCache":false,
    "identifier":"60006",
    "imageDataVersion":"",
    "index":"0",
    "isCustom":false,
    "isPremimmum":false,
    "isWhitelisted":false,
    "licenseAgreementWebsite":"",
    "name":"Dogs",
    "privacyPolicyWebsite":"",
    "publisher":"TEST CONTENT",
    "publisherEmail":"1",
    "publisherWebsite":"",
    "stickerMode":0,
    "stickers":[
      {
        "emojis":[

        ],
        "imageFileName":"600061",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600061.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600062",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600062.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600063",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600063.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600065",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600065.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600066",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600066.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600067",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600067.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600068",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600068.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"600069",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/600069.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000610",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000610.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000611",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000611.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000612",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000612.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000613",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000613.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000614",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000614.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000615",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000615.webp"
      },
      {
        "emojis":[

        ],
        "imageFileName":"6000616",
        "size":0,
        "uri":"file:///data/user/0/com.example.myapppackagename/files/60006/6000616.webp"
      }
    ],
    "stickersAddedIndex":15,
    "totalSize":0,
    "trayImageFile":"my_tray_icon.webp"
  }
]

我在这里遗漏了什么吗?应该在这里为fd添加哪个字段?有人能帮我吗?任何帮助都将不胜感激。谢谢

t40tm48m

t40tm48m1#

如果您有自定义URI,则执行以下操作

File file =new File(uri);
                Uri newUri = Uri.fromFile(file);
                getApplicationContext().getContentResolver().openFileDescriptor(newUri,"r" );

和openAssetFile的内容提供程序类中

pfd = Objects.requireNonNull(getContext()).getContentResolver().openFileDescriptor(
                                csp.getTrayImageUri(), "r");

然后执行您的工作,此外,如果您有任何疑问IB我或评论在这里

zlhcx6iw

zlhcx6iw2#

唯一的原因是你没有在你的安卓应用中提供读/写权限。在代码中添加权限逻辑并重新安装应用-〉给予权限,它就可以工作了!

相关问题