pull to refresh example, error - android

I'm trying to add the "pull to refresh" widget to my code, I'm just using this example:
https://github.com/johannilsson/android-pulltorefresh
So, I create the pullToRefresh package, generate a jar file with eclipse and import it in other package, I got this error:
06-26 10:55:05.482: E/AndroidRuntime(508): FATAL EXCEPTION: main
06-26 10:55:05.482: E/AndroidRuntime(508): java.lang.RuntimeException: Unable to start activity ComponentInfo{example.pull/example.pull.PullToRefreshExampleActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.pull.widget.pullToRefresh
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.ActivityThread.access$500(ActivityThread.java:122)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.os.Looper.loop(Looper.java:132)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.ActivityThread.main(ActivityThread.java:4123)
06-26 10:55:05.482: E/AndroidRuntime(508): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 10:55:05.482: E/AndroidRuntime(508): at java.lang.reflect.Method.invoke(Method.java:491)
06-26 10:55:05.482: E/AndroidRuntime(508): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-26 10:55:05.482: E/AndroidRuntime(508): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-26 10:55:05.482: E/AndroidRuntime(508): at dalvik.system.NativeStart.main(Native Method)
06-26 10:55:05.482: E/AndroidRuntime(508): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.pull.widget.pullToRefresh
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.createView(LayoutInflater.java:596)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:671)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
06-26 10:55:05.482: E/AndroidRuntime(508): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:223)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.Activity.setContentView(Activity.java:1786)
06-26 10:55:05.482: E/AndroidRuntime(508): at example.pull.PullToRefreshExampleActivity.onCreate(PullToRefreshExampleActivity.java:21)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.Activity.performCreate(Activity.java:4397)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
06-26 10:55:05.482: E/AndroidRuntime(508): ... 11 more
06-26 10:55:05.482: E/AndroidRuntime(508): Caused by: java.lang.reflect.InvocationTargetException
06-26 10:55:05.482: E/AndroidRuntime(508): at java.lang.reflect.Constructor.constructNative(Native Method)
06-26 10:55:05.482: E/AndroidRuntime(508): at java.lang.reflect.Constructor.newInstance(Constructor.java:416)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.createView(LayoutInflater.java:576)
06-26 10:55:05.482: E/AndroidRuntime(508): ... 22 more
06-26 10:55:05.482: E/AndroidRuntime(508): Caused by: android.content.res.Resources$NotFoundException: File pulltorefresh from xml type layout resource ID #0x7f030000
06-26 10:55:05.482: E/AndroidRuntime(508): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2135)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2090)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.content.res.Resources.getLayout(Resources.java:849)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.view.LayoutInflater.inflate(LayoutInflater.java:389)
06-26 10:55:05.482: E/AndroidRuntime(508): at com.pull.widget.pullToRefresh.init(pullToRefresh.java:92)
06-26 10:55:05.482: E/AndroidRuntime(508): at com.pull.widget.pullToRefresh.<init>(pullToRefresh.java:66)
06-26 10:55:05.482: E/AndroidRuntime(508): ... 25 more
06-26 10:55:05.482: E/AndroidRuntime(508): Caused by: java.io.FileNotFoundException: pulltorefresh
06-26 10:55:05.482: E/AndroidRuntime(508): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:487)
06-26 10:55:05.482: E/AndroidRuntime(508): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2117)
06-26 10:55:05.482: E/AndroidRuntime(508): ... 30 more
what I see more important:-
06-26 10:55:05.482: E/AndroidRuntime(508): at com.pull.widget.pullToRefresh.init(pullToRefresh.java:92)
Is this line:
mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
in "pullToRefresh.java" in the package created.
From the package, what could it be happening??
Thanks in advance

Related

What does this Android Runtime logCat error mean?

I'm new to android programming and especially eclipse. I have a very hard time undersanding what the LogCat errors mean and where to look to fix them. I'm used to Visual Studios so it usually tells me where the error is located at. All of the classes it shows me arent even classes that I have created, but built in ones so I'm just confused..
LogCat:
06-26 09:03:56.201: E/AndroidRuntime(3428): FATAL EXCEPTION: main
06-26 09:03:56.201: E/AndroidRuntime(3428): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.basicscanner/com.example.basicscanner.MainActivity}: java.lang.ClassNotFoundException: com.example.basicscanner.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.basicscanner-1.apk]
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.os.Looper.loop(Looper.java:130)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-26 09:03:56.201: E/AndroidRuntime(3428): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 09:03:56.201: E/AndroidRuntime(3428): at java.lang.reflect.Method.invoke(Method.java:507)
06-26 09:03:56.201: E/AndroidRuntime(3428): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-26 09:03:56.201: E/AndroidRuntime(3428): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-26 09:03:56.201: E/AndroidRuntime(3428): at dalvik.system.NativeStart.main(Native Method)
06-26 09:03:56.201: E/AndroidRuntime(3428): Caused by: java.lang.ClassNotFoundException: com.example.basicscanner.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.basicscanner-1.apk]
06-26 09:03:56.201: E/AndroidRuntime(3428): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-26 09:03:56.201: E/AndroidRuntime(3428): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-26 09:03:56.201: E/AndroidRuntime(3428): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-26 09:03:56.201: E/AndroidRuntime(3428): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
It means that the compiler is not able to find your class, maybe because you haven't defined it in your android manifest or maybe the path to your class is not right;)
It is a problem of your Intent.
Please add your Activity in your AndroidManifest.xml.
When you want to making new activity, you should register it in your AndroidManifest.xml.

NoClassFoundError MultipartEntity error in android

I am not able to figure this problem out.I added the following jars.
httpClient-4.2.5.jar
httpcore-4.2.4.jar
httpmime-4.2.5.jar
I added these jar through Add External JARs option in Build Paths and then added them manually in the libs folder of my eclipse project still it gives me the following error while debugging the following line.
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
Actually I am trying to upload multiple images to my php server using this.
Logcat:
06-26 02:06:08.082: E/AndroidRuntime(20389): FATAL EXCEPTION: IntentService[SyncService]
06-26 02:06:08.082: E/AndroidRuntime(20389): java.lang.NoClassDefFoundError: org.apache.http.entity.mime.MultipartEntity
06-26 02:06:08.082: E/AndroidRuntime(20389): at com.example.cameralibrary.ServerCommunication.uploadUserPhoto(ServerCommunication.java:43)
06-26 02:06:08.082: E/AndroidRuntime(20389): at com.example.cameralibrary.SyncService.onHandleIntent(SyncService.java:38)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.os.Looper.loop(Looper.java:138)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.os.HandlerThread.run(HandlerThread.java:60)
06-26 02:06:08.082: E/AndroidRuntime(20389): Caused by: java.lang.ClassNotFoundException: org.apache.http.entity.mime.MultipartEntity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.example.cameralibrary-2.apk]
06-26 02:06:08.082: E/AndroidRuntime(20389): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-26 02:06:08.082: E/AndroidRuntime(20389): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-26 02:06:08.082: E/AndroidRuntime(20389): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
Found out myself.The problem was that I didn't include the READ_EXTERNAL_STORAGE permission.
I added the following line in my manifest and it worked.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

ArcGIS - Unsatisfied link error find library returned null - Hello World sample app

This is my first time into the ArcGIS but not the first time for Android. I am an Android developer. For one of our recent projects, i am exploring the ArcGIS modules/samples. I did the following steps:
Installed Eclipse JUNO (latest) - Since my previous version got corrupted, had to replace the system.
Downloaded ArcGIS runtime SDK for Android 10.1.1.
Installed the ArcGIS plugin from the downloaded zip file obtained from step 2.
Restarted Eclipse/System.
Now to explore the basic "Hello World" ArcGIS app, i did the following steps.
File - New - Project - In the new window - selected the "ArcGIS for Android" option.
Out of the 2 options i selected "ArcGIS samples for Android". This option opened another window to fetch the samples from local or online.
I selected "LOCAL".
Under "Maps" section, i selected the "Hello World" sample project.
Now the Hello World project is in my workspace.
Cleaned and build the project. All errors gone.
Run the project.
I am obtaining the following error log:
06-26 16:36:15.678: E/AndroidRuntime(2672): FATAL EXCEPTION: main
06-26 16:36:15.678: E/AndroidRuntime(2672): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.esri.arcgis.android.samples.helloworld/com.esri.arcgis.android.samples.helloworld.HelloWorld}: android.view.InflateException: Binary XML file line #9: Error inflating class com.esri.android.map.MapView
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.ActivityThread.access$600(ActivityThread.java:130)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.os.Looper.loop(Looper.java:137)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.ActivityThread.main(ActivityThread.java:4745)
06-26 16:36:15.678: E/AndroidRuntime(2672): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 16:36:15.678: E/AndroidRuntime(2672): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-26 16:36:15.678: E/AndroidRuntime(2672): at dalvik.system.NativeStart.main(Native Method)
06-26 16:36:15.678: E/AndroidRuntime(2672): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.esri.android.map.MapView
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.Activity.setContentView(Activity.java:1867)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.esri.arcgis.android.samples.helloworld.HelloWorld.onCreate(HelloWorld.java:42)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.Activity.performCreate(Activity.java:5008)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
06-26 16:36:15.678: E/AndroidRuntime(2672): ... 11 more
06-26 16:36:15.678: E/AndroidRuntime(2672): Caused by: java.lang.reflect.InvocationTargetException
06-26 16:36:15.678: E/AndroidRuntime(2672): at java.lang.reflect.Constructor.constructNative(Native Method)
06-26 16:36:15.678: E/AndroidRuntime(2672): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-26 16:36:15.678: E/AndroidRuntime(2672): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-26 16:36:15.678: E/AndroidRuntime(2672): ... 22 more
06-26 16:36:15.678: E/AndroidRuntime(2672): Caused by: java.lang.ExceptionInInitializerError
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.esri.android.map.MapView.a(Unknown Source)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.esri.android.map.MapView.<init>(Unknown Source)
06-26 16:36:15.678: E/AndroidRuntime(2672): ... 25 more
06-26 16:36:15.678: E/AndroidRuntime(2672): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load runtimecore_java: findLibrary returned null
06-26 16:36:15.678: E/AndroidRuntime(2672): at java.lang.Runtime.loadLibrary(Runtime.java:365)
06-26 16:36:15.678: E/AndroidRuntime(2672): at java.lang.System.loadLibrary(System.java:535)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.esri.core.internal.util.e$1.initialize(Unknown Source)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.esri.android.io.a.a(Unknown Source)
06-26 16:36:15.678: E/AndroidRuntime(2672): at com.esri.android.map.MapSurface.<clinit>(Unknown Source)
06-26 16:36:15.678: E/AndroidRuntime(2672): ... 27 more
Later i followed the ArcGIS forums and came across many links for example
http://forums.arcgis.com/threads/484...-returned-null
http://forums.arcgis.com/threads/850...ello-World-run
but alas the error was never cleared.
I encountered a similar problem with one of my Android projects. It had the libs folder with .so files for armeabi and armeabi-v7a. I converted the project into a library and used it one of my another project. Since it was a small project i didn't needed to explore the converted library project. This is due to the referencing of the .so files or library files related to the Eclipse updates. I am still unsure how to configure the .so files into the build path so that there is no "Unsatisfied link" error.
Please see the screenshot attached for the Build Path of this project.
Like Google maps , arc GIS also won't work in Emulator , to run your
app in Real device it should work

Error inflating class fragment Android Map v2

I know this is a duplicate question, but solutions from previous post doesn't worked for
me. Thats why am asking this question.
I am trying to implement Google Map V2 in Android App, I got below error
06-26 19:24:51.035: E/AndroidRuntime(7679): FATAL EXCEPTION: main
06-26 19:24:51.035: E/AndroidRuntime(7679): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.titutorial.mapdemo/com.titutorial.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.access$600(ActivityThread.java:140)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.os.Looper.loop(Looper.java:137)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.main(ActivityThread.java:4898)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-26 19:24:51.035: E/AndroidRuntime(7679): at dalvik.system.NativeStart.main(Native Method)
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Activity.setContentView(Activity.java:1924)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.titutorial.mapdemo.MainActivity.onCreate(MainActivity.java:12)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Activity.performCreate(Activity.java:5206)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
06-26 19:24:51.035: E/AndroidRuntime(7679): ... 11 more
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Fragment.instantiate(Fragment.java:584)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Fragment.instantiate(Fragment.java:552)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Activity.onCreateView(Activity.java:4849)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-26 19:24:51.035: E/AndroidRuntime(7679): ... 20 more
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
06-26 19:24:51.035: E/AndroidRuntime(7679): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Fragment.instantiate(Fragment.java:574)
06-26 19:24:51.035: E/AndroidRuntime(7679): ... 23 more
I followed below tutorial,
https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
I did below things
Install Google Play services
Created a new app in Google Console, and got Google Map API key
Created new app in eclipse and added permission and Google Map API key in AndroidManifest.xml
Added Google Play Services library to App
Add a Map to the App (main.xml)
Set targeted API level 17
in my main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
here is my complete source code
https://github.com/railskarthi/MapDemo
After API 11+, I think you now have have to replace your MapFragment by SupportMapFragment. It would be something like:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
Take a look here for further information. Let me know how are you going with.
I have download your project from git and after checking i found that you have missed a line which is required to display map Fragment.
Replace your main activity code with the following code:-
public class MainActivity extends FragmentActivity {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
This could happen also if you did not define API_KEY for google maps in your manifest file.
It looks like this:
`....
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<your key>" />
....`
Create your key in Google Developer Console
Please add these line in your manifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your Goolge API key" />

Application crash after open preferences

When I click Settings in my application's menu, app crash instantly. I don't have idea how to repair it.
I am new to Android and I learn from Hello, Android book.
Application files below:
PrefsFragment.java:
package org.example.sudoku;
import android.os.Bundle;
import android.preference.PreferenceFragment;
public class PrefsFragment extends PreferenceFragment {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
res/xml/preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:key="music"
android:title="#string/music_title"
android:summary="#string/music_summary"
android:defaultValue="true" />
<CheckBoxPreference
android:key="hints"
android:title="#string/hints_title"
android:summary="#string/hints_summary"
android:defaultValue="true" />
</PreferenceScreen>
Logcat:
06-26 16:14:26.600: W/dalvikvm(2827): threadid=1: thread exiting with uncaught exception (group=0x40a041f8)
06-26 16:14:26.610: E/AndroidRuntime(2827): FATAL EXCEPTION: main
06-26 16:14:26.610: E/AndroidRuntime(2827): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.example.sudoku/org.example.sudoku.PrefsFragment}: java.lang.ClassCastException: org.example.sudoku.PrefsFragment cannot be cast to android.app.Activity
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1993)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.access$600(ActivityThread.java:132)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.os.Looper.loop(Looper.java:137)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.main(ActivityThread.java:4575)
06-26 16:14:26.610: E/AndroidRuntime(2827): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 16:14:26.610: E/AndroidRuntime(2827): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 16:14:26.610: E/AndroidRuntime(2827): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-26 16:14:26.610: E/AndroidRuntime(2827): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-26 16:14:26.610: E/AndroidRuntime(2827): at dalvik.system.NativeStart.main(Native Method)
06-26 16:14:26.610: E/AndroidRuntime(2827): Caused by: java.lang.ClassCastException: org.example.sudoku.PrefsFragment cannot be cast to android.app.Activity
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1984)
06-26 16:14:26.610: E/AndroidRuntime(2827): ... 11 more
The problem is that you need to extend PreferenceActivity, not PreferenceFragment.
PreferenceActivity extends ListActivity, which extends Activity, while PreferenceFragment extends Fragment.
That's why you have the ClassCast Exception.
How did you access to your PreferenceFragment ?
Is it contained in a FragmentActivity ?
You cannot call directly a Fragment with startActivity();

Categories

Resources