I am trying to implement the most basic example of google maps android api v2 example.
But it crashes with the error:java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable.
I have set up the google api and have looked at stackoverflow posts like:
-https://stackoverflow.com/questions/14252879/google-maps-android-api-v2-tutorials,
-Google map android API V2 crashed
and
-https://stackoverflow.com/questions/13796822/google-map-android-api-v2-application-crashes
but their problems are slightly different than mine.
Can you please point me to the right direction? I am using android 2.2 and would like to use the new Maps to make use of fragments in my app; so that I can get some functionality like apple's uinavigation to push new views in a pop up activity.
Thanks.
Thank you,how did you get to the png you are showing in the attachment?The google play service is shown as a referenced library in my package explorer; I did add it; this is my logcat:
01-16 06:23:55.087: E/AndroidRuntime(305): FATAL EXCEPTION: main
01-16 06:23:55.087: E/AndroidRuntime(305): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
01-16 06:23:55.087: E/AndroidRuntime(305): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
01-16 06:23:55.087: E/AndroidRuntime(305): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:271)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-16 06:23:55.087: E/AndroidRuntime(305): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.Activity.setContentView(Activity.java:1647)
01-16 06:23:55.087: E/AndroidRuntime(305): at com.example.afis.MainActivity.onCreate(MainActivity.java:13)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
01-16 06:23:55.087: E/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-16 06:23:55.087: E/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 06:23:55.087: E/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
01-16 06:23:55.087: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-16 06:23:55.087: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-16 06:23:55.087: E/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
01-16 06:23:55.097: W/ActivityManager(59): Force finishing activity com.example.afis/.MainActivity
01-16 06:23:55.607: W/ActivityManager(59): Activity pause timeout for HistoryRecord{44ee9110 com.example.afis/.MainActivity}
Please check if the "libs" folder containing the "android-support-v4.jar" exists in your project. Because you are using Android 2.2, you must have "libs " folder in your project root directory. If you have not that, just copy that jar file into your "libs" folder .
"android-support-v4.jar" is located in "/extras/android/compatibility/v4/android-support-v4.jar" under your drectory.
And before running your project, you must set your project Build target to "Google APIs", not Android x.x. version : Select your project and click Project > Properties > Project Build Target in Eclipse and select any "Google APIs ", and then run your project on your phone. If you use the emulator, also MUST set the AVD of the emulator to the any "Google APIs ".
Once more, you don't need to create the new Google Maps API key in order to test your project, Just use the default provided API key, which is shown as "Key for browser apps (with referers) "in your Google APIs Console.
Use Android SDK Manager download "google play services"
import it into your workspace (path: android-sdk root/extras/google/google_play_service/libproject/google-play-service_lib)
project Properties -> android -> Library add google-play-service_lib
Build path -> Order and Export check Android private libraries
I solved this error by checking "Copy projects into workspace" while importing the Google Play Services lib.
More info here: http://developer.android.com/google/play-services/setup.html
Related
I have android app in market so I get this error but I don't know why.
Exception class java.lang.NoClassDefFoundError
Source method MainActivity.onCreate()
java.lang.NoClassDefFoundError: android.app.DownloadManager
at com.example.viewpagerexample.MainActivity.onCreate(MainActivity.java:182)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
at android.app.ActivityThread.access$2300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
DownloadManager was added on API level 9 (aka Gingerbread).
My guess you declared minSDK as lower than 9 in your AndroidManifest.xml
If that is the case, you need to devise a workaround for users using older Android version.
You can check on which version your app is running by using the following code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
// Use DownloadManager
}
else {
// Workaround
}
i'm getting this message when i run my application i don't know why i'm getting it could any one help me. here is the logcat.
java.lang.VerifyError: com.kosh.me.Smaller
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
This happens when the build library classes conflict with those at run-time. Try performing a Clean of your project followed by a build.
I Have Tried Below tutorial For Reading Contacts In Android
http://www.edumobile.org/android/android-programming-tutorials/read-contacts-from-device/
http://eagle.phys.utk.edu/guidry/android/readContacts.html
Both Are Complete without any Error But When I Am Running It's Showing Force Close Error
I tried with API 8,13,16
Same Error For all. I Dont Know More About It But I Completly Follow Tutorial.
Catlog Here
09-30 14:02:09.121: D/AndroidRuntime(305): Shutting down VM
09-30 14:02:09.121: W/dalvikvm(305): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-30 14:02:09.141: E/AndroidRuntime(305): FATAL EXCEPTION: main
09-30 14:02:09.141: E/AndroidRuntime(305): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.app.ReadContacts/com.app.ReadContacts.ReadContacts}: java.lang.ClassNotFoundException: com.app.ReadContacts.ReadContacts in loader dalvik.system.PathClassLoader[/data/app/com.app.ReadContacts-2.apk]
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
09-30 14:02:09.141: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-30 14:02:09.141: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-30 14:02:09.141: E/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
09-30 14:02:09.141: E/AndroidRuntime(305): Caused by: java.lang.ClassNotFoundException: com.app.ReadContacts.ReadContacts in loader dalvik.system.PathClassLoader[/data/app/com.app.ReadContacts-2.apk]
09-30 14:02:09.141: E/AndroidRuntime(305): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
09-30 14:02:09.141: E/AndroidRuntime(305): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-30 14:02:09.141: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-30 14:02:09.141: E/AndroidRuntime(305): ... 11 more
09-30 14:07:09.262: I/Process(305): Sending signal. PID: 305 SIG: 9
Have you added the com.app.ReadContacts.ReadContacts Activity to your AndroidManifest.xml?
The error you're receiving suggests that you haven't...
The line to add is probably
<activity android:name=".ReadContacts"/>
although depending on your project structure it can be necessary to use the fully qualified name
<activity android:name="com.app.ReadContacts.ReadContacts"/>
have u mentioned read contacts permission in manifest file?
<uses-permission android:name="android.permission.READ_CONTACTS" />
if yes, post the error message from log cat
It appears that the class com.app.ReadContacts.ReadContacts cannot be found. Have you specified your Activity in your AndroidManifest.xml file?
I'm just trying to get the basics down of using Admob in my android apps, but for some reason, even the example code crashes my device and emulator. I followed the instructions on https://developers.google.com/mobile-ads-sdk/docs/ and it didn't fix my problem. As far as I can see, everything is included properly, I've added the jar file to the build path, etc etc. But for some reason, I always get errors like the following:
09-16 00:36:11.855: E/AndroidRuntime(305): FATAL EXCEPTION: main
09-16 00:36:11.855: E/AndroidRuntime(305): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.example.ads.xml/com.google.example.ads.xml.BannerSample}: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.ads.AdView
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-16 00:36:11.855: E/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
09-16 00:36:11.855: E/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
09-16 00:36:11.855: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-16 00:36:11.855: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-16 00:36:11.855: E/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
09-16 00:36:11.855: E/AndroidRuntime(305): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.ads.AdView
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-16 00:36:11.855: E/AndroidRuntime(305): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.Activity.setContentView(Activity.java:1647)
09-16 00:36:11.855: E/AndroidRuntime(305): at com.google.example.ads.xml.BannerSample.onCreate(BannerSample.java:14)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-16 00:36:11.855: E/AndroidRuntime(305): ... 11 more
09-16 00:36:11.855: E/AndroidRuntime(305): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.google.example.ads.xml-2.apk]
09-16 00:36:11.855: E/AndroidRuntime(305): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
09-16 00:36:11.855: E/AndroidRuntime(305): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
09-16 00:36:11.855: E/AndroidRuntime(305): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
09-16 00:36:11.855: E/AndroidRuntime(305): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
09-16 00:36:11.855: E/AndroidRuntime(305): ... 20 more
Any help would be greatly appreciated. Thanks!
Have you put jar file in libs folder?.If Not create a new folder named libs and copy paste the jar file in it then add it to build path by right click on it and choose build path option and the add to build path.Also Do not use adview in Dialog.It may cause problem.For more help just follow the step by step guide https://developers.google.com/mobile-ads-sdk/docs/ .
Answer-
But it is good practice to put your jar file in libs folder so that it can be managed properly and I have experienced some time when if i do not put my jar in the libs folder it gives me class not found exception OK that's why I suggest you to do the same. this time you may not have any problem but most of the time It cause problem
So it looks like I glossed over a step. My Bad. I forgot to check the jar in the order/export tab.
I made an android project on Motodev (which is an eclipse plugin itself). But now when I am trying to run the same project on eclipse, the emulator gives me an error the following error:
FATAL EXCEPTION: main E/AndroidRuntime(4711): java.lang.VerifyError: com.tenpearls.namecalling.Activities.SearchContactsActivity
E/AndroidRuntime(4711): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(4711): at java.lang.Class.newInstance(Class.java:1429)
E/AndroidRuntime(4711): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(4711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
E/AndroidRuntime(4711): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(4711): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(4711): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(4711): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(4711): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(4711): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(4711): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(4711): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(4711): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(4711): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(4711): at dalvik.system.NativeStart.main(Native Method)
That can be the result when you have compiled against a different library than you are using at runtime.
A good explanation can be had here.
Another possibility is having a duplicate class in the classpath somewhere, such as in a library jar.