I am having problem when starting com.facebook.katana.ProxyAuth. The activity that is starting this intent is defined in manifest file with android:launchMode="singleInstance"
I've solved this by removing launch mode as single instance, this intent is started successfully.
I really need this activity to be single instance, so does anyone know how to solve this problem without removing android:launchMode="singleInstance"?
Intent intent = new Intent();
intent.setClassName("com.facebook.katana",
"com.facebook.katana.ProxyAuth");
intent.putExtra("client_id", applicationId);
// Verify that the application whose package name is
// com.facebook.katana.ProxyAuth
// has the expected FB app signature.
if (!validateActivityIntent(activity, intent)) {
return false;
}
// activity is defined in manifest as single instance
activity.startActivityForResult(intent, activityCode);
LogCat:
05-14 16:42:13.470: E/AndroidRuntime(28141): FATAL EXCEPTION: main
05-14 16:42:13.470: E/AndroidRuntime(28141): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.katana/com.facebook.katana.ProxyAuth}: java.lang.NullPointerException
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.os.Looper.loop(Looper.java:144)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.ActivityThread.main(ActivityThread.java:4937)
05-14 16:42:13.470: E/AndroidRuntime(28141): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 16:42:13.470: E/AndroidRuntime(28141): at java.lang.reflect.Method.invoke(Method.java:521)
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-14 16:42:13.470: E/AndroidRuntime(28141): at dalvik.system.NativeStart.main(Native Method)
05-14 16:42:13.470: E/AndroidRuntime(28141): Caused by: java.lang.NullPointerException
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.facebook.orca.common.util.Base64.c(Base64.java:497)
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.facebook.orca.common.util.Base64.b(Base64.java:459)
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.facebook.katana.ProxyAuth.b(ProxyAuth.java:36)
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.facebook.katana.activity.PlatformDialogActivity.a(PlatformDialogActivity.java:127)
05-14 16:42:13.470: E/AndroidRuntime(28141): at com.facebook.orca.activity.FbFragmentActivity.onCreate(FbFragmentActivity.java:48)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
05-14 16:42:13.470: E/AndroidRuntime(28141): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
05-14 16:42:13.470: E/AndroidRuntime(28141): ... 11 more
05-14 16:42:15.520: E/ActivityManager(114): Error running process
05-14 16:42:15.520: E/ActivityManager(114): java.io.IOException: Error running exec(). Command: [/system/xbin/procrank] Working Directory: null Environment: [ANDROID_SOCKET_zygote=11, ANDROID_BOOTLOGO=1, EXTERNAL_STORAGE=/mnt/sdcard, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, PATH=/sbin:/system/sbin:/system/bin:/system/xbin, ANDROID_DATA=/data, BOOTCLASSPATH=/system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/com.htc.framework.jar:/system/framework/com.htc.android.pimlib.jar:/system/framework/com.htc.android.easopen.jar:/system/framework/com.scalado.util.ScaladoUtil.jar, ANDROID_PROPERTY_WORKSPACE=10,65536, ANDROID_ROOT=/system, LD_LIBRARY_PATH=/system/lib]
05-14 16:42:15.520: E/ActivityManager(114): at java.lang.ProcessManager.exec(ProcessManager.java:226)
05-14 16:42:15.520: E/ActivityManager(114): at java.lang.ProcessBuilder.start(ProcessBuilder.java:201)
05-14 16:42:15.520: E/ActivityManager(114): at com.android.server.am.ActivityManagerService.logProcessResult(ActivityManagerService.java:9437)
05-14 16:42:15.520: E/ActivityManager(114): at com.android.server.am.ActivityManagerService.access$900(ActivityManagerService.java:155)
05-14 16:42:15.520: E/ActivityManager(114): at com.android.server.am.ActivityManagerService$9.run(ActivityManagerService.java:9614)
05-14 16:42:15.520: E/ActivityManager(114): Caused by: java.io.IOException: No such file or directory
05-14 16:42:15.520: E/ActivityManager(114): at java.lang.ProcessManager.exec(Native Method)
05-14 16:42:15.520: E/ActivityManager(114): at java.lang.ProcessManager.exec(ProcessManager.java:224)
05-14 16:42:15.520: E/ActivityManager(114): ... 4 more
It may not be the answer that you need, but you may try android:launchMode="singleTask", it behaves like singleInstance in many cases and works with the facebook authentication. See Android singleTask or singleInstance launch mode?
Related
I have an Android app that handles single sign-on with Facebook and requests the following permissions on login: read_stream, user_likes
I made sure to make my Facebook application public such that it is NOT in sandbox mode, but I still get the following error when logging in for only some accounts:
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): Exception during service
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): com.facebook.http.protocol.ApiException: Invalid application MY_VALID_APP_ID
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:78)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:107)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:291)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:266)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:27)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:157)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:366)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:259)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:245)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:51)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:191)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at com.facebook.common.executors.HandlerExecutorServiceImpl$ListenableScheduledFuture.run(HandlerExecutorServiceImpl.java:268)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at android.os.Handler.handleCallback(Handler.java:725)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at android.os.Handler.dispatchMessage(Handler.java:92)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at android.os.Looper.loop(Looper.java:137)
05-14 12:00:01.264: W/fb4a(:<default>):BlueServiceQueue(5095): at android.os.HandlerThread.run(HandlerThread.java:60)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): Failed to send
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): com.facebook.fbservice.service.ServiceException: API_ERROR: API_ERROR
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:637)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:46)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at com.facebook.fbservice.ops.BlueServiceOperation$2.run(BlueServiceOperation.java:602)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at android.os.Handler.handleCallback(Handler.java:725)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at android.os.Handler.dispatchMessage(Handler.java:92)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at android.os.Looper.loop(Looper.java:137)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at java.lang.reflect.Method.invoke(Method.java:511)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-14 12:00:01.298: W/fb4a(:<default>):GDPDialog(5095): at dalvik.system.NativeStart.main(Native Method)
05-14 12:00:01.475: W/InputMethodManagerService(732): Focus gain on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy#41b99b70 (uid=10085 pid=4961)
I can also confirm that I am setting the correct Facebook Application id in my Android app as well. I also set the required key hashes for my Android app too. Any help would be appreciated!
It sounds like you're missing the Facebook App ID meta data in your manifest (or it's pointing to the wrong ID):
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:exported="true"
android:value="#string/your_facebook_app_id_string" />
I also have the same problem as you! I use new function 'Test Apps' of Facebook SDK ,
i found:
https://developers.facebook.com/docs/apps/test-apps/
Note:
Test Apps are always in Development Mode, making it less likely someone may chance upon a pre-release version of your product
So, I solved the problem by add join team members to testing in Roles.
If you do not have an Test App, you go to "Status and Review" setting to enable "live and available to all users".
I hope to help you, sr my English!
I am populating shared preferences into a PreferenceFragment, available as a tab in the ActionBar. The preferences are populated in the Fragment's onCreate method,
public static class WIKPreferenceFragment extends PreferenceFragment
{
#Override
public void onCreate ( Bundle bundle )
{
super.onCreate( bundle );
this.addPreferencesFromResource( R.layout.settings_fragment );
}
}
When the tab is selected, the PreferenceFragment is added directly,
public void onTabSelected ( Tab tab, FragmentTransaction transaction )
{
transaction.replace( R.id.tab_view_target, new WIKPreferenceFragment() );
( (WIKActivity) this.activity ).setTabMemory( tab.getPosition() );
}
The content of R.layout.settings_fragment is
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<PreferenceCategory android:title="#string/category_proximity_settings" >
<CheckBoxPreference
android:key="#+key/USE_PASSIVE_GPS"
android:summary="#string/summary_use_passive_gps"
android:title="#string/title_use_passive_gps" />
<EditTextPreference
android:inputType="number"
android:key="#+key/GPS_TIMEOUT"
android:summary="#string/summary_gps_timeout"
android:title="#string/title_gps_timeout" />
</PreferenceCategory>
</PreferenceScreen>
With a clean install, the preference fragment appears correctly when the tab is first selected. If another tab is selected and this tab is returned to, the following error occurs:
05-14 19:23:02.366: E/AndroidRuntime(11744): FATAL EXCEPTION: main
05-14 19:23:02.366: E/AndroidRuntime(11744): Process: org.eightbeers.android.wik, PID: 11744
05-14 19:23:02.366: E/AndroidRuntime(11744): java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:224)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.Preference.getPersistedString(Preference.java:1429)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.EditTextPreference.onSetInitialValue(EditTextPreference.java:154)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.Preference.dispatchSetInitialValue(Preference.java:1345)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.Preference.onAttachedToHierarchy(Preference.java:1140)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.PreferenceGroup.addPreference(PreferenceGroup.java:163)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:104)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:45)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.GenericInflater.rInflate(GenericInflater.java:488)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.GenericInflater.inflate(GenericInflater.java:326)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:272)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:285)
05-14 19:23:02.366: E/AndroidRuntime(11744): at org.eightbeers.android.wik.activity.SettingsTab$WIKPreferenceFragment.onCreate(SettingsTab.java:27)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.Fragment.performCreate(Fragment.java:1688)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:860)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1063)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.BackStackRecord.run(BackStackRecord.java:684)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1450)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:444)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.os.Handler.handleCallback(Handler.java:733)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.os.Handler.dispatchMessage(Handler.java:95)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.os.Looper.loop(Looper.java:136)
05-14 19:23:02.366: E/AndroidRuntime(11744): at android.app.ActivityThread.main(ActivityThread.java:5105)
05-14 19:23:02.366: E/AndroidRuntime(11744): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 19:23:02.366: E/AndroidRuntime(11744): at java.lang.reflect.Method.invoke(Method.java:515)
05-14 19:23:02.366: E/AndroidRuntime(11744): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
05-14 19:23:02.366: E/AndroidRuntime(11744): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
05-14 19:23:02.366: E/AndroidRuntime(11744): at dalvik.system.NativeStart.main(Native Method)
Some potentially-helpful data points:
This error does not occur when the CheckBoxPreference is commented-out, or if the EditTextPreference is commented-out (i.e., everything works if there is only one preference; of course, I'd like to have more than one, more than two, even)
This error does not occur if preferences are not reloaded in onCreate if they've already been loaded; however, when this is changed no preferences appear at all when the tab is reselected
This error persists through clearing of user data, restarting Eclipse, uninstalling of the app, project cleans, and phone reboots (okay, just one); with exception to the phone reboot (since I only tried it once), it persists through any combination of the previous
To make uninstalls easier, I renamed the app from WIK to AAWIK; however, in the Settings -> Application Manager window the app still appears alphabetized as WIK. Everywhere else in the UI --- app drawer, uninstall pane, notifications, etc. --- it is AAWIK; this might just be an extreme caching issue? (Edit: this last one was addressed by just letting the phone sit, idle, long enough for me to type this question; no longer a useful data point, all other issues still persist.)
The problem was solved by switching the android:key="#+key/[keyname]" in the XML for android:key="[keyname]".
I do not intend to accept my answer immediately since I have no idea of why this worked, and Google has not been forthcoming.
Key should be stored as string in prefs.xml (or another name if you want)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_key_gps" translatable="false">pref_key_gps</string>
</resources>
you should replace:
android:key="#+key/USE_PASSIVE_GPS"
to:
android:key="#string/pref_key_gps"
Chinese
现在碰到的问题是,addPreferencesFromResource ClassCastException Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
我所使用到的控件 <EditTextPreference .../>
我的业务场景:
通过 EditTextPreference 处理的数据都是数字。
首次将数据写入 xml 文件的工作不是通过 EditTextPreference 完成的;我是手动完成的,使用的方法是 putInt
在加载包含 EditTextPreference 布局的时候报错。
错误原因,在 EditTextPreference 类内部所维护的数据是通过 putString 和 getString 来维护的。
所以我只需要将手动部分设置成 putString 即可解决问题。
English
My problem is : addPreferencesFromResource ClassCastException Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
The widget I am using is: <EditTextPreference .../>
My business scene is:
EditTextPreference only contrue numbers.
I write data to xml file by SharedPerference.Editro.putInt() ,not done by `EditTextPreference' ,in the first time .
App creash when load EditTextPreference layout.
The cause of the problem is :
Inside the EditTextPreference class , data maintained by putString and getString .But I used is putInt
So change putInt to putString can fix the problem
I am getting the error below when I try to login through facebook plugin for Android.
The app basically crashes "stopped", Any ideas will be appreciated.
ERROR/AndroidRuntime(2008): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to resume activity {xxx/com.facebook.LoginActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x7f060012
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
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:5039)
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: android.content.res.Resources$NotFoundException: String resource ID #0x7f060012
at android.content.res.Resources.getText(Resources.java:230)
at android.content.res.Resources.getString(Resources.java:314)
at android.content.Context.getString(Context.java:327)
at com.facebook.widget.WebDialog.onCreate(WebDialog.java:189)
at android.app.Dialog.dispatchOnCreate(Dialog.java:355)
at android.app.Dialog.show(Dialog.java:260)
at com.facebook.AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient.java:471)
at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:214)
at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:193)
at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:121)
at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:102)
at com.facebook.LoginActivity.onResume(LoginActivity.java:113)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
at android.app.Activity.performResume(Activity.java:5182)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
... 12 more
i kinda resolved it, i deleted the app_id string. turns out facebook plugin doesn't use that.
HI here is a small code i picked it from the sample code of google analytics.
tracker = GoogleAnalyticsTracker.getInstance();
tracker.startNewSession("UA-YOUR-ACCOUNT-HERE", this);
setContentView(R.layout.main);
Button createEventButton = (Button)findViewById(R.id.NewEventButton);
createEventButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
tracker.trackEvent(
"Clicks", // Category
"Button", // Action
"clicked", // Label
77); // Value
}
});
Error:
'05-14 13:52:36.599: E/AndroidRuntime(7367): FATAL EXCEPTION: main
05-14 13:52:36.599: E/AndroidRuntime(7367): java.lang.NoClassDefFoundError: com.google.android.apps.analytics.GoogleAnalyticsTracker
05-14 13:52:36.599: E/AndroidRuntime(7367): at com.google.android.apps.analytics.sample.TestActivity.onCreate(TestActivity.java:19)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.os.Looper.loop(Looper.java:130)
05-14 13:52:36.599: E/AndroidRuntime(7367): at android.app.ActivityThread.main(ActivityThread.java:3687)
05-14 13:52:36.599: E/AndroidRuntime(7367): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 13:52:36.599: E/AndroidRuntime(7367): at java.lang.reflect.Method.invoke(Method.java:507)
05-14 13:52:36.599: E/AndroidRuntime(7367): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-14 13:52:36.599: E/AndroidRuntime(7367): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-14 13:52:36.599: E/AndroidRuntime(7367): at dalvik.system.NativeStart.main(Native Method)
To solve the problem with the error NoClassdefFoundError when you are using the Google Analytics v2beta library, you need to mark this library as "exported".
How?
Add your library: Project -> Properties -> Java Build Path -> Libraries -> Add External JARs...
Then go to "Order and Export" in the same window, and mark this library as "exported" with the checkbox.
Your proyect will now find the Analytics class when you run it!
More details and why this happen here
I had this problem after updating ADT.
I was storing all of my JAR files in a folder called "lib" and adding the jars to the build path the normal Eclipse way. This worked fine until my update.
After my update, I was getting the NoClassDefFoundError for a class that I could clearly see was included in the jar (checking out the ReferencedLibraries classes).
The solution was to remove my jars from the build path and rename my "lib" folder to "libs". This is an ant convention, and seems to be the way the new ADT finds and includes libraries in an .apk file. Once I did this, everything worked fine.
I am going to consume web service from android according to this link http://jatin4rise.wordpress.com/2010/10/03/webservicecallfromandroid/ but during run time my android application[AndroidFrontend] shown as
Sorry!.
The application AndroidFrontend(process.org.web.android.frontend)has stopped unexpectedly.Please try later.
And the logcat shown as
LOGCAT
05-14 11:13:55.133: E/dalvikvm(208): Could not find class 'org.ksoap2.serialization.SoapObject', referenced from method org.web.android.frontend.AndroidFrontendActivity.onCreate
05-14 11:13:55.133: W/dalvikvm(208): VFY: unable to resolve new-instance 25 (Lorg/ksoap2/serialization/SoapObject;) in Lorg/web/android/frontend/AndroidFrontendActivity;
05-14 11:13:55.133: D/dalvikvm(208): VFY: replacing opcode 0x22 at 0x0010
05-14 11:13:55.163: D/dalvikvm(208): VFY: dead code 0x0012-0081 in Lorg/web/android/frontend/AndroidFrontendActivity;.onCreate (Landroid/os/Bundle;)V
05-14 11:13:55.224: D/AndroidRuntime(208): Shutting down VM
05-14 11:13:55.224: W/dalvikvm(208): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-14 11:13:55.233: E/AndroidRuntime(208): FATAL EXCEPTION: main
05-14 11:13:55.233: E/AndroidRuntime(208): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
05-14 11:13:55.233: E/AndroidRuntime(208): at org.web.android.frontend.AndroidFrontendActivity.onCreate(AndroidFrontendActivity.java:28)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.os.Looper.loop(Looper.java:123)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-14 11:13:55.233: E/AndroidRuntime(208): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 11:13:55.233: E/AndroidRuntime(208): at java.lang.reflect.Method.invoke(Method.java:521)
05-14 11:13:55.233: E/AndroidRuntime(208): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-14 11:13:55.233: E/AndroidRuntime(208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-14 11:13:55.233: E/AndroidRuntime(208): at dalvik.system.NativeStart.main(Native Method)
Guys i have googled these issues as per my knowledge but still seeking for solution.Please let me know the solution if you have.
Thanks for your Precious Time!
The VM is unable to locate the class org.ksoap2.serialization.SoapObject.
Make sure you include the required library (the JAR file) when you build your project.