Exception raised while including google map to my android application - android

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.

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 :|

Cordova hello world app crashing

I am new in Android Development. I am working on cordova platform
I have created a sample hello world app and getting this error when i am trying to open it in genymotion. ALthough the app compile succesfully but when i run it in genymotion it just shows the prompt with text "Unfortunately "APP" has stopped."
The Error log shows.
01-12 08:16:04.867 2073-2073/com.technoserves.crudnew D/dalvikvm﹕ Late-enabling CheckJNI
01-12 08:16:06.107 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ Unable to resolve superclass of Lcom/technoserves/crudnew/CordovaApp; (14)
01-12 08:16:06.119 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ Link of class 'Lcom/technoserves/crudnew/CordovaApp;' failed
01-12 08:16:06.135 2073-2073/com.technoserves.crudnew D/AndroidRuntime﹕ Shutting down VM
01-12 08:16:06.135 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa6142908)
01-12 08:16:06.155 2073-2073/com.technoserves.crudnew E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.technoserves.crudnew/com.technoserves.crudnew.CordovaApp}: java.lang.ClassNotFoundException: Didn't find class "com.technoserves.crudnew.CordovaApp" on path: /data/app/com.technoserves.crudnew-1.apk
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.technoserves.crudnew.CordovaApp" on path: /data/app/com.technoserves.crudnew-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            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:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)
01-12 08:16:22.399 2073-2073/com.technoserves.crudnew I/Process﹕ Sending signal. PID: 2073 SIG: 9
I have updated my cordova to resolve but still same error however a few days ago it was working fine and i have build some apps.
First download Cordova jar file from following link:
http://www.java2s.com/Code/JarDownload/cordova/cordova-1.8.1.jar.zip
after that extract the folder and put cordova-1.8.1 inside your libs folder of project in eclipse
And right click on your project--> properties and Select Android from left pane and scroll to bottom remove the cordova library if added.
then clean and build your project.

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.

CognitoCredentialsProvider on refresh throws runtimeException

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.

Unable to resolve superclass of FragmentActivity

I had my environment setup on a previous machine, and I'm on a differnt MacBook. For some strange reason, I keep getting an issue with one of my classes which exend FragmentActivity. It keeps saying it can't find the FragmentActivity class, although I have the support jar in my class path, as per the image:
The detailed error message that I'm seeing is here:
10-23 23:10:16.300 26062-26062/com.testapp W/dalvikvm﹕ Unable to resolve superclass of Lcom/testapp/views/loginregistration/LoginView; (92)
10-23 23:10:16.300 26062-26062/com.testapp W/dalvikvm﹕ Link of class 'Lcom/testapp/views/loginregistration/LoginView;' failed
10-23 23:10:16.300 26062-26062/com.testapp D/AndroidRuntime﹕ Shutting down VM
10-23 23:10:16.300 26062-26062/com.testapp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x414f8700)
10-23 23:10:16.330 26062-26062/com.testapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.testapp/com.testapp.views.loginregistration.LoginView}: java.lang.ClassNotFoundException: Didn't find class "com.testapp.views.loginregistration.LoginView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.testapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.testapp-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.testapp.views.loginregistration.LoginView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.testapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.testapp-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Is there someting else i'm missing?
In your IDE (as shown in your screenshot), check the 'export' box next to the classpath entry that contains the missing class.
I had a similar problem with a class from the Android Support library (Unable to resolve superclass of Lcom ... PagerAdapter). It turned out a library referenced in the .classpath needed to be exported:
From:
<classpathentry
To:
<classpathentry exported="true" ...
For Eclipse users, I fixed the problem by exporting Android Private Libraries in the Java Build Path menu.

Categories

Resources