我正在尝试GCM Client
按照Google(https://developers.google.com/cloud-
messaging/android/client
)的指南在Android
上实现新功能。对于两个不同的设备,我收到的错误略有不同。我注意到两个设备的方法getNoBackupFilesDir都收到NoSuchMethodError。
这是Android 4.2.2的logcat:
06-08 09:01:09.920: I/dalvikvm(9138): Could not find methodandroid.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
06-08 09:01:09.920: W/dalvikvm(9138): VFY: unable to resolve virtual method 273: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
06-08 09:01:09.920: D/dalvikvm(9138): VFY: replacing opcode 0x6e at 0x00c2
06-08 09:01:09.920: I/dalvikvm(9138): DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras
06-08 09:01:09.920: W/dalvikvm(9138): VFY: unable to resolve instance field 12
06-08 09:01:09.920: D/dalvikvm(9138): VFY: replacing opcode 0x54 at 0x00e1
06-08 09:01:09.920: E/dalvikvm(9138): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
06-08 09:01:09.920: W/dalvikvm(9138): VFY: unable to resolve check-cast 25 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
06-08 09:01:09.920: D/dalvikvm(9138): VFY: replacing opcode 0x1f at 0x000e
06-08 09:01:09.920: I/dalvikvm(9138): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh
06-08 09:01:09.920: W/dalvikvm(9138): VFY: unable to resolve virtual method 528: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
06-08 09:01:09.920: D/dalvikvm(9138): VFY: replacing opcode 0x6e at 0x000b
06-08 09:01:09.950: I/dalvikvm(9138): Could not find method android.support.v4.content.ContextCompat.getNoBackupFilesDir, referenced from method com.google.android.gms.iid.zzd.zzde
06-08 09:01:09.950: W/dalvikvm(9138): VFY: unable to resolve virtual method 2080: Landroid/support/v4/content/ContextCompat;.getNoBackupFilesDir (Landroid/content/Context;)Ljava/io/File;
06-08 09:01:09.950: D/dalvikvm(9138): VFY: replacing opcode 0x6e at 0x0007
06-08 09:01:09.950: W/dalvikvm(9138): threadid=11: thread exiting with uncaught exception (group=0x4174c930)
06-08 09:01:09.960: E/AndroidRuntime(9138): FATAL EXCEPTION: AsyncTask #1
06-08 09:01:09.960: E/AndroidRuntime(9138): java.lang.RuntimeException: An error occured while executing doInBackground()
06-08 09:01:09.960: E/AndroidRuntime(9138): at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-08 09:01:09.960: E/AndroidRuntime(9138): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.lang.Thread.run(Thread.java:856)
06-08 09:01:09.960: E/AndroidRuntime(9138): Caused by: java.lang.NoSuchMethodError: android.support.v4.content.ContextCompat.getNoBackupFilesDir
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.google.android.gms.iid.zzd.zzde(Unknown Source)
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.google.android.gms.iid.zzd.<init>(Unknown Source)
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.google.android.gms.iid.zzd.<init>(Unknown Source)
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.example.MainActivity$1.doInBackground(MainActivity.java:113)
06-08 09:01:09.960: E/AndroidRuntime(9138): at com.example.MainActivity$1.doInBackground(MainActivity.java:1)
06-08 09:01:09.960: E/AndroidRuntime(9138): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-08 09:01:09.960: E/AndroidRuntime(9138): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-08 09:01:09.960: E/AndroidRuntime(9138): ... 4 more
这是Android 5.1.1的logcat:
06-08 09:06:49.786: E/AndroidRuntime(2852): FATAL EXCEPTION: AsyncTask #1
06-08 09:06:49.786: E/AndroidRuntime(2852): Process: com.example, PID: 2852
06-08 09:06:49.786: E/AndroidRuntime(2852): java.lang.RuntimeException: An error occured while executing doInBackground()
06-08 09:06:49.786: E/AndroidRuntime(2852): at android.os.AsyncTask$3.done(AsyncTask.java:304)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
06-08 09:06:49.786: E/AndroidRuntime(2852): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.lang.Thread.run(Thread.java:818)
06-08 09:06:49.786: E/AndroidRuntime(2852): Caused by: java.lang.NoSuchMethodError: No virtual method getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.example-1/base.apk)
06-08 09:06:49.786: E/AndroidRuntime(2852): at com.google.android.gms.iid.zzd.zzde(Unknown Source)
06-08 09:06:49.786: E/AndroidRuntime(2852): at com.google.android.gms.iid.zzd.<init>(Unknown Source)
06-08 09:06:49.786: E/AndroidRuntime(2852): at com.google.android.gms.iid.zzd.<init>(Unknown Source)
06-08 09:06:49.786: E/AndroidRuntime(2852): at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
06-08 09:06:49.786: E/AndroidRuntime(2852): at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
06-08 09:06:49.786: E/AndroidRuntime(2852): at it.abgsys.htms.MainActivity$1.doInBackground(MainActivity.java:113)
06-08 09:06:49.786: E/AndroidRuntime(2852): at it.abgsys.htms.MainActivity$1.doInBackground(MainActivity.java:1)
06-08 09:06:49.786: E/AndroidRuntime(2852): at android.os.AsyncTask$2.call(AsyncTask.java:292)
06-08 09:06:49.786: E/AndroidRuntime(2852): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-08 09:06:49.786: E/AndroidRuntime(2852): ... 4 more
在第113行,我有这个:
InstanceID instanceID = InstanceID.getInstance(applicationContext);
在这里使用:
// AsyncTask to register Device in GCM Server
private void registerInBackground() {
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
String msg = "";
InstanceID instanceID = InstanceID.getInstance(applicationContext);
try {
regId = instanceID.getToken(GCM_SENDER_ID,
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
} catch (IOException e) {
e.printStackTrace();
}
return msg;
}
@Override
protected void onPostExecute(String msg) {
if (!TextUtils.isEmpty(regId)) {
Toast.makeText(
applicationContext,
"Registered with GCM Server successfully.\n\n"
+ msg, Toast.LENGTH_SHORT).show();
Log.e(TAG, "Registered with GCM Server successfully. RegID: " + regId);
} else {
Toast.makeText(
applicationContext,
"Reg ID Creation Failed.\n\nEither you haven't enabled Internet or GCM server is busy right now. "
+ "Make sure you enabled Internet and try registering again after some time."
+ msg, Toast.LENGTH_LONG).show();
Log.e(TAG, "Reg ID Creation Failed!!!");
}
}
}.execute(null, null, null);
}
我已Google Play Services
按照文档中的说明正确导入了库。(https://developers.google.com/android/guides/setup)
有没有人遇到这个错误?我该如何解决?
使用的开发环境:带有ADT的Eclipse Kepler SR2
如果您需要其他信息,请发表评论。
我看到该方法getNoBackupFilesDir
在android.support.v4.content.ContextCompat中找到。
似乎问题是我在项目中包含了旧的appcompat-v7。使用的SDK manager
最新版本进行下载,Android Support Library
然后按照添加带有资源的库的步骤进行操作,并将该库添加到您的应用程序项目中。
我一直在试图找出java安全/加密库的方法,我相信我在理解发生了什么方面取得了一些进展。我想我设法让加密部分工作了。在encrypt方法中,如果我只是尝试返回,我会得到一些看起来像加密文本的不可读的杂乱无章的东西。当我试图不返回它,而是继续调用decrypt并进行明文-->encrypt-->decrypt是我所拥有的一切时,问题就来了 所以我用一些明文调用encrypt,并尝试返回明文以确保它工
程序包nath.prem.com.premgcmproject; //如果令牌被更改,则再次注册设备@override public void onTokenRefresh(){Intent Intent=new Intent(this,GCMRegistrationIntentService.class);startService(Intent);}} 在客户端获取GCM令牌时出错 致命异常:I
我已经按照在Android应用程序中实现GCM的示例,该应用程序正在使用以下代码接收消息: 问题是GCMinentService(公共类GCMinentService扩展了IntentService)从未运行过?我是否遗漏了什么,或者它通常应该触发onHandleIntent方法? 如果以任何方式与清单文件相关,请提前感谢:
这是我正在使用的库:https://github.com/clickntap/vimeo 我正在尝试使用图书馆的一个Android应用程序。我的测试设备是Kitkat(4.4.4)。 下面是我添加库的方法: 但在上收到以下错误: 和警告: 下面是第二个场景,其中包含:
有没有我可以参考的示例应用程序用于Android上的SAML交互?有人在Android上成功移植/使用了OpenSAML吗? 我正在尝试编写一个简单的应用程序,它将(而不是浏览器重定向)使用本机API来执行SAML身份验证。 还有一些指向测试环境的指针,我可以在其中测试SAML客户机,这会有所帮助。
我使用的是macOS版本12.0.1。所以,发生的是,我重新安装了XAMPP,所以当我点击开始时,它开始了,并显示了我的IP地址。接下来,当我去服务并试图启动所有Apache、MySQL和ProFTPD时,它们都没有启动,日志中写道: 所以,当我不知所措时,我决定检查Lampp中的文件。因此,我安装了XAMPP,然后单击了Lampp,它显示了以下文件: XAMPP文件 应该还有这么多文件,但这里没