我跟随this tutorial&试图获得sample code" gplus-quickstart-android"工作。我没有错误地构建项目。但是,当我尝试在我的设备上运行应用程序(用usb连接到我的笔记本电脑)时,应用程序会立即崩溃。
我看到了这个错误java.lang.ClassNotFoundException:com.google.android.gms.plus.sample.quickstart.MainActivity
这是日志记录:
07-21 10:49:10.699: E/Trace(22334): error opening trace file: No such file or directory (2)
07-21 10:49:10.779: W/dalvikvm(22334): threadid=1: thread exiting with uncaught exception (group=0x4100e450)
07-21 10:49:10.809: E/AndroidRuntime(22334): FATAL EXCEPTION: main
07-21 10:49:10.809: E/AndroidRuntime(22334): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.android.gms.plus.sample.quickstart/com.google.android.gms.plus.sample.quickstart.MainActivity}: java.lang.ClassNotFoundException: com.google.android.gms.plus.sample.quickstart.MainActivity
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1991)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.ActivityThread.access$600(ActivityThread.java:133)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.os.Handler.dispatchMessage(Handler.java:99)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.os.Looper.loop(Looper.java:137)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.ActivityThread.main(ActivityThread.java:4794)
07-21 10:49:10.809: E/AndroidRuntime(22334): at java.lang.reflect.Method.invokeNative(Native Method)
07-21 10:49:10.809: E/AndroidRuntime(22334): at java.lang.reflect.Method.invoke(Method.java:511)
07-21 10:49:10.809: E/AndroidRuntime(22334): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-21 10:49:10.809: E/AndroidRuntime(22334): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-21 10:49:10.809: E/AndroidRuntime(22334): at dalvik.system.NativeStart.main(Native Method)
07-21 10:49:10.809: E/AndroidRuntime(22334): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.plus.sample.quickstart.MainActivity
07-21 10:49:10.809: E/AndroidRuntime(22334): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-21 10:49:10.809: E/AndroidRuntime(22334): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-21 10:49:10.809: E/AndroidRuntime(22334): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
07-21 10:49:10.809: E/AndroidRuntime(22334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1982)
07-21 10:49:10.809: E/AndroidRuntime(22334): ... 11 more
是否有人提示如何解决这个问题或者我可能做错了什么?
答案 0 :(得分:1)
导入项目后MainActivity.java
不在src文件夹中,它位于java文件夹中。
所以,我在包含名称MainActivity.java
&的src文件夹中创建了com.google.android.gms.plus.sample.quickstart
复制了MainActivity.java
MainActivity
使用FragmentActivity
因此,我在项目中添加了android-support-v4.jar
。
然后运行项目!