gpt4 book ai didi

android - 在路径 : DexPathList 上找不到类

转载 作者:行者123 更新时间:2023-11-30 01:52:59 26 4
gpt4 key购买 nike

在运行并收到短信后,我在此代码中使用了接收器,显示此错误。我尝试一些事情。我创建新项目并再次添加文件。删除bin文件。清理并重新启动项目。但它不能解决错误。有什么可以解决这个错误。我真的解决不了。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="blocker.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>

<uses-sdk android:minSdkVersion="8" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity

android:name=".FirstPage"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<receiver android:name=".receiver.SMSReceiver" android:enabled="true">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>


<activity

android:name=".Search"
android:label="@string/app_name" >

</activity>

<activity

android:name=".BlockActivity"
android:label="@string/app_name" >

</activity>


<activity
android:name=".SmsFilter"
android:label="@string/app_name" >

</activity>


<activity
android:name=".CustomAdapter"
android:label="@string/app_name" >

</activity>
</application>

</manifest>

错误: enter image description here

属性:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

短信接收类:

public class SmsFilter extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {




if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
Bundle extras = intent.getExtras();
if (extras != null) {
Object[] pdus = (Object[])extras.get("pdus");

if (pdus.length < 1) return; // Invalid SMS. Not sure that it's possible.

StringBuilder sb = new StringBuilder();
String sender = null;
for (int i = 0; i < pdus.length; i++) {
SmsMessage message = SmsMessage.createFromPdu((byte[]) pdus[i]);
if (sender == null) sender = message.getOriginatingAddress();
String text = message.getMessageBody();
if (text != null) sb.append(text);
}

Log.i("LOG: ", "sms recived");
Log.i("LOG: ", sender);



if (sender != null && Search.search(sender)==true) {


abortBroadcast();

}
return;
}
}

// ...
}




}

最佳答案

请再次检查接收者的名称和您在 list 接收者中声明的类名。

在 java 文件中类名是-SmsFilter extends BroadcastReceiver

SmsFilter extends BroadcastReceiver

如您所见,名称是 Sm​​sFilter,但在您的 list 文件中,您将其声明为 SMSReceiver

名称不匹配。将您的 list 编辑为类似这样的内容-

<receiver android:name=".receiver.SmsFilter" android:enabled="true">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

希望对你有帮助

关于android - 在路径 : DexPathList 上找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32725312/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com