CognitoCredentialsProvider on refresh throws runtimeException - android

I am trying to upload a text file to Amazon s3 from my android application. I am using the following code snippet provided by Amazon AWS.
private static CognitoCredentialsProvider sCredProvider;
public static CognitoCredentialsProvider getCredProvider(Context context) {
if(sCredProvider == null) {
Log.i("Util","reached utility");
Log.i("Util","Context"+context);
sCredProvider = new CognitoCredentialsProvider(
context,
Constants.AWS_ACCOUNT_ID,
Constants.COGNITO_POOL_ID,
Constants.COGNITO_ROLE_UNAUTH,
null);
Log.i("Util","returning scredprovider"+sCredProvider);
sCredProvider.refresh();
}
Log.i("Util","returning scredprovider"+sCredProvider);
return sCredProvider;
}
When the code passes through sCredProvider.refresh(); it throws the follow error.
08-05 02:21:24.908: E/AndroidRuntime(25712): FATAL EXCEPTION: main
08-05 02:21:24.908: E/AndroidRuntime(25712): java.lang.RuntimeException: Unable to create service network.NetworkService: android.os.NetworkOnMainThreadException
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2667)
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.app.ActivityThread.access$1600(ActivityThread.java:153)
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1329)
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.os.Looper.loop(Looper.java:137)
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.app.ActivityThread.main(ActivityThread.java:5227)
08-05 02:21:24.908: E/AndroidRuntime(25712): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 02:21:24.908: E/AndroidRuntime(25712): at java.lang.reflect.Method.invoke(Method.java:511)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-05 02:21:24.908: E/AndroidRuntime(25712): at dalvik.system.NativeStart.main(Native Method)
08-05 02:21:24.908: E/AndroidRuntime(25712): Caused by: android.os.NetworkOnMainThreadException
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
08-05 02:21:24.908: E/AndroidRuntime(25712): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
08-05 02:21:24.908: E/AndroidRuntime(25712): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
08-05 02:21:24.908: E/AndroidRuntime(25712): at java.net.InetAddress.getAllByName(InetAddress.java:214)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.http.AmazonHttpClient.executeHelper(Unknown Source)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.http.AmazonHttpClient.execute(Unknown Source)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityServiceClient.invoke(Unknown Source)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityServiceClient.getOpenIdToken(Unknown Source)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.auth.CognitoCredentialsProvider.startSession(Unknown Source)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.amazonaws.auth.CognitoCredentialsProvider.refresh(Unknown Source)
08-05 02:21:24.908: E/AndroidRuntime(25712): at com.chan.censioevlog.Util.getCredProvider(Util.java:41)
08-05 02:21:24.908: E/AndroidRuntime(25712): at network.NetworkService.onCreate(NetworkService.java:55)
08-05 02:21:24.908: E/AndroidRuntime(25712): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2657)
08-05 02:21:24.908: E/AndroidRuntime(25712): ... 10 more
Commenting out the line run the application fine. But I don't see the file uploaded to Amazon S3. I did setup to Amazon Cognito credential provider.
The source code can be found here.

CognitoCredentialsProvider.refresh() will make a network request to fetch Cognito identity id and session credentials if those aren't cached (handled by the provider itself). Based on the stack trace, you call getCredProvider(Context context) on the main thread. And refresh() is invoked on the main thread. That's why you see NetworkOnMainThreadException. To fix this issue, you can remove sCredProvider.refresh(). If for some reason you want to call refresh(), you need to call it in a background thread. Please refer to AsyncTask.

Related

Class (an Activity) is declared but ClassNotFoundException still occurs [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I've tried to fix this issue for long time but still being stuck.
I already declared my Activity in AndroidManifest.xml file but ActivityNotFoundException still occurs, Please help!
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sel.appsinfo" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyAppTheme" >
<activity
android:name="com.sel.appsinfo.AppsInfoMainActivity"
android:uiOptions="splitActionBarWhenNarrow" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity></application>
Logcat:
08-05 23:37:17.566: W/dalvikvm(26899): Unable to resolve superclass of Lcom/sel/appsinfo/BaseActivity; (85)
08-05 23:37:17.567: W/dalvikvm(26899): Link of class 'Lcom/sel/appsinfo/BaseActivity;' failed
08-05 23:37:17.568: W/dalvikvm(26899): Unable to resolve superclass of Lcom/sel/appsinfo/AppsInfoMainActivity; (166)
08-05 23:37:17.568: W/dalvikvm(26899): Link of class 'Lcom/sel/appsinfo/AppsInfoMainActivity;' failed
08-05 23:37:17.571: D/AndroidRuntime(26899): Shutting down VM
08-05 23:37:17.571: W/dalvikvm(26899): threadid=1: thread exiting with uncaught exception (group=0x40c97258)
08-05 23:37:17.574: E/AndroidRuntime(26899): FATAL EXCEPTION: main
08-05 23:37:17.574: E/AndroidRuntime(26899): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sel.appsinfo/com.sel.appsinfo.AppsInfoMainActivity}: java.lang.ClassNotFoundException: com.sel.appsinfo.AppsInfoMainActivity
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2023)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.ActivityThread.access$600(ActivityThread.java:127)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1174)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.os.Looper.loop(Looper.java:137)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.ActivityThread.main(ActivityThread.java:4503)
08-05 23:37:17.574: E/AndroidRuntime(26899): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 23:37:17.574: E/AndroidRuntime(26899): at java.lang.reflect.Method.invoke(Method.java:511)
08-05 23:37:17.574: E/AndroidRuntime(26899): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
08-05 23:37:17.574: E/AndroidRuntime(26899): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
08-05 23:37:17.574: E/AndroidRuntime(26899): at dalvik.system.NativeStart.main(Native Method)
08-05 23:37:17.574: E/AndroidRuntime(26899): Caused by: java.lang.ClassNotFoundException: com.sel.appsinfo.AppsInfoMainActivity
08-05 23:37:17.574: E/AndroidRuntime(26899): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-05 23:37:17.574: E/AndroidRuntime(26899): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-05 23:37:17.574: E/AndroidRuntime(26899): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-05 23:37:17.574: E/AndroidRuntime(26899): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1911)
08-05 23:37:17.574: E/AndroidRuntime(26899): ... 11 more
It looks like AppsInfoMainActivity extends BaseActivity but BaseActivity extends something else which is probably not valid. Make sure it is extending Activity or an AppCompat Activity class and that the imports are correct
Make sure your Intent Filter tag in the XML which contains MAIN also contains
<category android:name="android.intent.category.DEFAULT" />
I think there's a problem about your class path. Please check class path and if it's wrong correct it.
If it's extending Activity or an AppCompat Activity class and that the imports are right, maybe 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All must be the same.
Hmm Maybe cleaning Project will help.
I solved it, It was because of I had so many libs included unnecessary :|

App crashes when instantiating HelpStackSDK

We tried integrating HelpStack by following steps given on GitHub, but we kept getting the following errors:
04-03 13:54:22.054 4638-4638/com.playerline.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.playerline.android/com.tenmiles.helpstack.activities.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.tenmiles.helpstack.activities.HSActivityParent.onCreate(HSActivityParent.java:48)
at com.tenmiles.helpstack.activities.HomeActivity.onCreate(HomeActivity.java:46)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
I'm guessing it has something to do with the App Theme, which in our case is is Theme.AppCompat.NoActionBar.

Android Application Crashes on launch

My android application crashes every time I run/launch it on both the emulator and a real device and returns this error message: Unfortunately "application_name" has stopped!
This is what my logcat looks like:
08-05 22:34:24.452: D/dalvikvm(541): Not late-enabling CheckJNI (already on)
08-05 22:34:25.012: D/AndroidRuntime(541): Shutting down VM
08-05 22:34:25.012: W/dalvikvm(541): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-05 22:34:25.012: E/AndroidRuntime(541): FATAL EXCEPTION: main
08-05 22:34:25.012: E/AndroidRuntime(541): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.tutorial.sharedpreferences/com.tutorial.sharedpreferences.Main}: java.lang.NullPointerException
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.os.Looper.loop(Looper.java:137)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.reflect.Method.invoke(Method.java:511)
08-05 22:34:25.012: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-05 22:34:25.012: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-05 22:34:25.012: E/AndroidRuntime(541): at dalvik.system.NativeStart.main(Native Method)
08-05 22:34:25.012: E/AndroidRuntime(541): Caused by: java.lang.NullPointerException
08-05 22:34:25.012: E/AndroidRuntime(541): at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:153)
08-05 22:34:25.012: E/AndroidRuntime(541): at com.tutorial.sharedpreferences.Main.<init>(Main.java:13)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.Class.newInstanceImpl(Native Method)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.Class.newInstance(Class.java:1319)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-05 22:34:25.012: E/AndroidRuntime(541): ... 11 more
You are attempting to call getSharedPreferences() from an initializer. You cannot safely call methods you inherit from Activity until after super.onCreate() is called.

Mp4parser - android - cant make it work

I am a trying to make video splitting app with the help of shorten example. I am trying to implement the following project from github.
https://github.com/dadachi/TestMp4parser.
but the app is not working and aborting.
LogCat -
08-05 17:03:42.161: D/OpenGLRenderer(6834): Enabling debug mode 0
08-05 17:03:44.934: D/do shoren starting(6834): do shoren starting
08-05 17:03:44.944: W/dalvikvm(6834): threadid=12: thread exiting with uncaught exception (group=0x4151e700)
08-05 17:03:44.944: E/AndroidRuntime(6834): FATAL EXCEPTION: doShorten
08-05 17:03:44.944: E/AndroidRuntime(6834): java.lang.RuntimeException: No box object found for ftyp
08-05 17:03:44.944: E/AndroidRuntime(6834): at com.coremedia.iso.PropertyBoxParserImpl$FourCcToBox.invoke(PropertyBoxParserImpl.java:187)
08-05 17:03:44.944: E/AndroidRuntime(6834): at com.coremedia.iso.PropertyBoxParserImpl.createBox(PropertyBoxParserImpl.java:90)
08-05 17:03:44.944: E/AndroidRuntime(6834): at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:87)
08-05 17:03:44.944: E/AndroidRuntime(6834): at com.coremedia.iso.IsoFile.parse(IsoFile.java:85)
08-05 17:03:44.944: E/AndroidRuntime(6834): at com.coremedia.iso.IsoFile.<init>(IsoFile.java:54)
08-05 17:03:44.944: E/AndroidRuntime(6834): at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:32)
08-05 17:03:44.944: E/AndroidRuntime(6834): at ek.shor.shortanproj.ShortenExample$1.run(ShortenExample.java:105)
08-05 17:03:44.944: E/AndroidRuntime(6834): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
08-05 17:03:44.944: E/AndroidRuntime(6834): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
08-05 17:03:44.944: E/AndroidRuntime(6834): at java.lang.Thread.run(Thread.java:841)
08-05 17:03:45.535: E/WindowManager(6834): Activity ek.shor.shortanproj.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41df8010 V.E..... R......D 0,0-729,192} that was originally added here
08-05 17:03:45.535: E/WindowManager(6834): android.view.WindowLeaked: Activity ek.shor.shortanproj.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41df8010 V.E..... R......D 0,0-729,192} that was originally added here
08-05 17:03:45.535: E/WindowManager(6834): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:345)
08-05 17:03:45.535: E/WindowManager(6834): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:239)
08-05 17:03:45.535: E/WindowManager(6834): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
08-05 17:03:45.535: E/WindowManager(6834): at android.app.Dialog.show(Dialog.java:281)
08-05 17:03:45.535: E/WindowManager(6834): at org.bestforce.utils.Ut.ShowWaitDialog(Ut.java:40)
08-05 17:03:45.535: E/WindowManager(6834): at ek.shor.shortanproj.ShortenExample.doShorten(ShortenExample.java:82)
08-05 17:03:45.535: E/WindowManager(6834): at ek.shor.shortanproj.ShortenExample.shorten(ShortenExample.java:78)
08-05 17:03:45.535: E/WindowManager(6834): at ek.shor.shortanproj.MainActivity.onClick(MainActivity.java:50)
08-05 17:03:45.535: E/WindowManager(6834): at android.view.View.performClick(View.java:4240)
08-05 17:03:45.535: E/WindowManager(6834): at android.view.View$PerformClick.run(View.java:17721)
08-05 17:03:45.535: E/WindowManager(6834): at android.os.Handler.handleCallback(Handler.java:730)
08-05 17:03:45.535: E/WindowManager(6834): at android.os.Handler.dispatchMessage(Handler.java:92)
08-05 17:03:45.535: E/WindowManager(6834): at android.os.Looper.loop(Looper.java:137)
08-05 17:03:45.535: E/WindowManager(6834): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-05 17:03:45.535: E/WindowManager(6834): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 17:03:45.535: E/WindowManager(6834): at java.lang.reflect.Method.invoke(Method.java:525)
08-05 17:03:45.535: E/WindowManager(6834): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-05 17:03:45.535: E/WindowManager(6834): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-05 17:03:45.535: E/WindowManager(6834): at dalvik.system.NativeStart.main(Native Method)
The files are same as in the git hub project. please let me know what mistake I am doing what all mistakes I am making.
The TestMp4Parser example is not updated. The Mp4Parser library has been updated and there are new methods to split and append the Videos.

Exception raised while including google map to my android application

I installed google play services in my sdk.
My xml file is attached below
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
But an exception is raised after compiling java file.
Complete Log file also attached.
08-05 06:02:06.686: D/AndroidRuntime(1236): Shutting down VM
08-05 06:02:06.686: W/dalvikvm(1236): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
08-05 06:02:06.847: E/AndroidRuntime(1236): FATAL EXCEPTION: main
08-05 06:02:06.847: E/AndroidRuntime(1236): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.viewindia/com.example.viewindia.ViewIndia}: android.view.InflateException: Binary XML file line #25: Error inflating class fragment
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.os.Looper.loop(Looper.java:137)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-05 06:02:06.847: E/AndroidRuntime(1236): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 06:02:06.847: E/AndroidRuntime(1236): at java.lang.reflect.Method.invoke(Method.java:525)
08-05 06:02:06.847: E/AndroidRuntime(1236): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-05 06:02:06.847: E/AndroidRuntime(1236): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-05 06:02:06.847: E/AndroidRuntime(1236): at dalvik.system.NativeStart.main(Native Method)
08-05 06:02:06.847: E/AndroidRuntime(1236): Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class fragment
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
08-05 06:02:06.847: E/AndroidRuntime(1236): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Activity.setContentView(Activity.java:1895)
08-05 06:02:06.847: E/AndroidRuntime(1236): at com.example.viewindia.ViewIndia.onCreate(ViewIndia.java:25)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Activity.performCreate(Activity.java:5133)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-05 06:02:06.847: E/AndroidRuntime(1236): ... 11 more
08-05 06:02:06.847: E/AndroidRuntime(1236): 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
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Fragment.instantiate(Fragment.java:592)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Fragment.instantiate(Fragment.java:560)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Activity.onCreateView(Activity.java:4738)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
08-05 06:02:06.847: E/AndroidRuntime(1236): ... 21 more
08-05 06:02:06.847: E/AndroidRuntime(1236): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/com.example.viewindia-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.viewindia-2, /system/lib]]
08-05 06:02:06.847: E/AndroidRuntime(1236): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-05 06:02:06.847: E/AndroidRuntime(1236): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-05 06:02:06.847: E/AndroidRuntime(1236): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-05 06:02:06.847: E/AndroidRuntime(1236): at android.app.Fragment.instantiate(Fragment.java:582)
08-05 06:02:06.847: E/AndroidRuntime(1236): ... 24 more
How can I solve this problem?
You have to add the Google Play Service SDK as a project in your workspace (assuming you're using Eclipse). This is described here.
The next step is to link this project with your Android project as a library. Here's the docu about this step.

Categories

Resources