android–ParseUtils中的NoClassDefFoundError

android–ParseUtils中的NoClassDefFoundError,第1张

概述我正在使用解析推送通知我收到以下错误java.lang.NoClassDefFoundError:notifications.ParseUtils$1atnotifications.ParseUtils.registerParse(ParseUtils.java:33)atcom.techieweb.solutions.pickeronline.MyApplication.onCreate(MyApplication.java:

我正在使用解析推送通知我收到以下错误

   java.lang.NoClassDefFoundError: notifications.ParseUtils        at notifications.ParseUtils.registerParse(ParseUtils.java:33)        at com.techIEweb.solutions.pickeronline.MyApplication.onCreate(MyApplication.java:20)        at androID.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1017)        at androID.app.ActivityThread.handleBindApplication(ActivityThread.java:4590)        at androID.app.ActivityThread.access00(ActivityThread.java:157)        at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)        at androID.os.Handler.dispatchMessage(Handler.java:99)        at androID.os.Looper.loop(Looper.java:176)        at androID.app.ActivityThread.main(ActivityThread.java:5317)        at java.lang.reflect.Method.invokeNative(Native Method)        at java.lang.reflect.Method.invoke(Method.java:511)        at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)        at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:869)        at dalvik.system.NativeStart.main(Native Method)

我用这个作为参考
     http://www.androidhive.info/2015/06/android-push-notifications-using-parse-com/

这是我的ParseUtils.java类

  public class ParseUtils {private static String TAG = ParseUtils.class.getSimplename();public static voID verifyParseConfiguration(Context context) {    if (TextUtils.isEmpty(AppConfig.PARSE_APPliCATION_ID) || TextUtils.isEmpty(AppConfig.PARSE_CLIENT_KEY)) {        Toast.makeText(context, "Please configure your Parse Application ID and ClIEnt Key in AppConfig.java", Toast.LENGTH_LONG).show();        ((Activity) context).finish();    }}public static voID registerParse(Context context) {    // initializing parse library    Parse.initialize(context, AppConfig.PARSE_APPliCATION_ID, AppConfig.PARSE_CLIENT_KEY);    ParseInstallation.getCurrentInstallation().saveInBackground(); //Shows error heree    ParsePush.subscribeInBackground(AppConfig.PARSE_CHANNEL, new SaveCallback() {        @OverrIDe        public voID done(ParseException e) {            Log.e(TAG, "Successfully subscribed to Parse!");        }    });}public static voID subscribeWithEmail(String email) {    ParseInstallation installation = ParseInstallation.getCurrentInstallation();    installation.put("email", email);    installation.saveInBackground();    Log.e(TAG, "Subscribed with email: " + email);}}

这是MyApplication

    public class MyApplication extends Application {private static MyApplication mInstance;@OverrIDepublic voID onCreate() {    super.onCreate();    mInstance = this;    // register with parse    ParseUtils.registerParse(this);}public static synchronized MyApplication getInstance() {    return mInstance;}}

这是NotificationUtils类

public class NotificationUtils {private String TAG = NotificationUtils.class.getSimplename();private Context mContext;public NotificationUtils() {}public NotificationUtils(Context mContext) {    this.mContext = mContext;}public voID showNotificationMessage(String Title, String message, Intent intent) {    // Check for empty push message    if (TextUtils.isEmpty(message))        return;    if (isAppIsInBackground(mContext)) {        // notification icon        int icon = R.mipmap.ic_launcher;        int smallicon = R.drawable.ic_push;        int mNotificationID = AppConfig.NOTIFICATION_ID;        PendingIntent resultPendingIntent =                PendingIntent.getActivity(                        mContext,                        0,                        intent,                        PendingIntent.FLAG_CANCEL_CURRENT                );        NotificationCompat.InBoxStyle inBoxStyle = new NotificationCompat.InBoxStyle();        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(                mContext);        Notification notification = mBuilder.setSmallicon(smallicon).setTicker(Title).setWhen(0)                .setautoCancel(true)                .setContentTitle(Title)                .setStyle(inBoxStyle)                .setContentIntent(resultPendingIntent)                .setSound(ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION))                .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))                .setContentText(message)                .build();        notificationmanager notificationmanager = (notificationmanager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);        notificationmanager.notify(mNotificationID, notification);    } else {        intent.putExtra("Title", Title);        intent.putExtra("message", message);        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_top);        mContext.startActivity(intent);    }}/** * Method checks if the app is in background or not * * @param context * @return */public static boolean isAppIsInBackground(Context context) {    boolean isInBackground = true;    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {        List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();        for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {            if (processInfo.importance == ActivityManager.RunningAppProcessInfo.importANCE_FOREGROUND) {                for (String activeProcess : processInfo.pkgList) {                    if (activeProcess.equals(context.getPackagename())) {                        isInBackground = false;                    }                }            }        }    } else {        List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);        Componentname componentInfo = taskInfo.get(0).topActivity;        if (componentInfo.getPackagename().equals(context.getPackagename())) {            isInBackground = false;        }    }    return isInBackground;}}

请帮我.

解决方法:

通过删除解决了错误

  ParsePush.subscribeInBackground(AppConfig.PARSE_CHANNEL, new SaveCallback() {    @OverrIDe    public voID done(ParseException e) {        Log.e(TAG, "Successfully subscribed to Parse!");    }});

并且仅使用

  ParseInstallation.getCurrentInstallation().saveInBackground();

https://teamtreehouse.com/community/pushservicesetdefaultpushcallback-has-now-been-depreciated-what-can-be-used

总结

以上是内存溢出为你收集整理的android – ParseUtils中的NoClassDefFoundError全部内容,希望文章能够帮你解决android – ParseUtils中的NoClassDefFoundError所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1108216.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存