ClassNotFoundException:未找到类“com.example.blogapp.whateverString”

ru *_*hee 5 android manifest androidx

迁移 androidx 后,当我单击按钮时,它会向我显示\n为什么会发生这种情况?

\n\n

当我点击按钮打开日历时我想要做什么

\n\n

这是我点击按钮时的错误

\n\n
  java.lang.ClassNotFoundException: Didn\'t find class "com.example.blogapp.whateverString" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.example.blogapp-BjDX\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的 Manifest.xml,其中有任何字符串的形式

\n\n
<?xml version="1.0" encoding="utf-8"?>\n<manifest xmlns:android="http://schemas.android.com/apk/res/android"\n    xmlns:tools="http://schemas.android.com/tools"\n    package="com.example.together">\n    <!--\n         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use\n         Google Maps Android API v2, but you must specify either coarse or fine\n         location permissions for the \'MyLocation\' functionality.\n    -->\n    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- \xeb\xa7\xb5 \xec\x9d\xb4\xec\x9a\xa9\xed\x95\x98\xea\xb8\xb0 \xec\x9c\x84\xed\x95\xa8 -->\n    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />\n    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- \xeb\x8b\xa4\xec\x9d\x8c \xec\xa7\x80\xeb\x8f\x84 -->\n    <uses-permission android:name="android.permission.INTERNET" /> <!-- \xeb\x8c\x80\xeb\x9e\xb5\xec\xa0\x81\xec\x9d\xb8 \xec\x9c\x84\xec\xb9\x98 \xec\xb0\xb8\xec\xa1\xb0 \xea\xb6\x8c\xed\x95\x9c -->\n    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- \xec\xa0\x95\xed\x99\x95\xed\x95\x9c \xec\x9c\x84\xec\xb9\x98 \xec\xb0\xb8\xec\xa1\xb0 \xea\xb6\x8c\xed\x95\x9c -->\n    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\n    <uses-permission android:name="android.permission.SEND_SMS" />\n    <uses-permission android:name="android.permission.RECEIVE_SMS" />\n    <uses-permission android:name="android.permission.READ_PHONE_STATE" />\n\n    <application\n        tools:replace="android:appComponentFactory"\n        android:appComponentFactory="whateverString"\n        android:allowBackup="false"\n        android:icon="@mipmap/ic_launcher"\n        android:label="@string/app_name"\n        android:roundIcon="@mipmap/ic_launcher_round"\n        android:supportsRtl="true"\n        android:theme="@style/AppTheme"\n        android:usesCleartextTraffic="true">\n
Run Code Online (Sandbox Code Playgroud)\n\n

我用这两行

\n\n
tools:replace="android:appComponentFactory"\n        android:appComponentFactory="whateverString"\n
Run Code Online (Sandbox Code Playgroud)\n\n

因为我添加了以下实现

\n\n
    implementation \'androidx.appcompat:appcompat:1.0.2\'\n    implementation \'com.google.android.material:material:1.1.0-alpha07\'\n    implementation \'joda-time:joda-time:2.10.1\'\n\n
Run Code Online (Sandbox Code Playgroud)\n\n

我从这里看到有人在我的情况下出现错误时推荐使用下面的代码

\n\n
tools:replace="android:appComponentFactory"\n        android:appComponentFactory="whateverString"\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以这就是我使用“WhateverString”的原因

\n\n

我该如何解决这个问题?\ni 不明白为什么在我迁移 androidx 后突然向我显示错误

\n

小智 3

在清单文件中添加了这一行

 android:appComponentFactory="whateverString"
Run Code Online (Sandbox Code Playgroud)

但该类找不到“whateverString”,因此您必须删除

tools:replace="android:appComponentFactory"
        android:appComponentFactory="whateverString"
Run Code Online (Sandbox Code Playgroud)

将这些行添加到清单文件中

android:requestLegacyExternalStorage="true"
 android:usesCleartextTraffic="true"
    tools:targetApi="p"
Run Code Online (Sandbox Code Playgroud)