我试图在 android 设备中使用 GCM 测试推送通知。只是我使用stackoverflow中的可用片段运行服务器端测试。但我得到了java.lang.NoClassDefFoundError: com/univ/entity/GCMTestingClient
import java.io.IOException;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
public class GCMTestingClient {
public String GCMTest() throws IOException {
Sender sender = new Sender("AszEaAipXqOJl--lMKSk6qHiOO7zmavU3cRQPk");
Message message = new Message.Builder()
.collapseKey("1")
.timeToLive(3)
.delayWhileIdle(true)
.addData("hello",
"this text will be seen in notification bar!!").build();
Result result = sender.send(message, "93821834343", 1);
System.out.println("result" + result);
return result.toString();
}
public static void main(String[] args) {
try {
GCMTestingClient gcm=new GCMTestingClient();
gcm.GCMTest();
} catch (Exception e) {
e.printStackTrace();
}
}
}
帮我解决这个问题。
错误信息 :
java.lang.NoClassDefFoundError: com/univ/entity/GCMTestingClient
Caused by: java.lang.ClassNotFoundException: com.univ.entity.GCMTestingClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Exception in thread "main"