java.lang.NoClassDefFoundError in android - android

I updated the Sherlock action bar library to new version in my project. After compiling and running logcat shows NoClassDefFoundError.
I have checked the jar versions. I have added the jars in project libs folder. I also checked order and export tab in build path. I also tried clean and build. Still i am getting NoClassDefFoundError.
My LogCat is shown below
E/AndroidRuntime(9699): java.lang.NoClassDefFoundError: com.mobiotics.tvbuddydemo.TVBuddyMainActivity
E/AndroidRuntime(9699): at com.mobiotics.tvbuddydemo.SplashScreen.onCreate(SplashScreen.java:54)
E/AndroidRuntime(9699): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(9699): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
E/AndroidRuntime(9699): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime(9699): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime(9699): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime(9699): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(9699): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(9699): at android.app.ActivityThread.main(ActivityThread.java:3839)
E/AndroidRuntime(9699): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(9699): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(9699): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
E/AndroidRuntime(9699): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/AndroidRuntime(9699): at dalvik.system.NativeStart.main(Native Method)
THE error line in splash screen
TVBuddyMainActivity.setSuccess(false);
i cant figure out the cause earlier working fine
My MAINFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mobiotics.tvbuddydemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15"
/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme"
android:screenOrientation="portrait"
>
<activity
android:name=".SplashScreen"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TVBuddyMain"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CustomSearch"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".PackageBuilderActivity"
android:screenOrientation="portrait"
>
</activity>
<service
android:name="com.mobiotics.tvbuddy.data.service.Droid_service"
android:exported="false" />
</application>
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

If you are using jar file. Do not add by "java Build path". Jar file should be in libs folder. if there is not libs folder create it and please put your jar file in libs folder. Then Right click on jar file and do build path and add to build path.
thank u

com.mobiotics.tvbuddydemo.TVBuddyMainActivity is not declared in android manifest file.
you have declared android:name=".TVBuddyMain" whic is not needed.
furthermore accessing static method inside an activity is not good idea.
TVBuddyMainActivity.setSuccess(false)
pass that false value through intent.

Related

Unexpectedly Closed Application After Integration Parse.com

There was no problem while running my little android application. I integrated my application new feature. I am using real time push notification with using ready script by www.parse.com . There is no problem while running but when i closed screen and reopen .There is an error. Your application closed unexpectedly. I dont know why and there is no log.
I am using this code in my main activity before oncreate
Parse.initialize(this, "XXX", "YYY");
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseAnalytics.trackAppOpened(getIntent());
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.islamiceducationquestions.v1"
android:versionCode="13"
android:versionName="8.0.1">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="com.islamiceducationquestions.v1.permission.C2D_MESSAGE" />
<uses-permission android:name="com.islamiceducationquestions.v1.permission.C2D_MESSAGE" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.islamiceducationquestions.v1" />
</intent-filter>
</receiver>
</application>
</manifest>
Log is :
java.lang.RuntimeException: Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2844)
at android.app.ActivityThread.access$1700(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
at com.parse.Parse.checkContext(Parse.java:583)
at com.parse.Parse.getApplicationContext(Parse.java:191)
at com.parse.ManifestInfo.getContext(ManifestInfo.java:241)
at com.parse.ManifestInfo.getPackageManager(ManifestInfo.java:249)
at com.parse.ManifestInfo.getPackageInfo(ManifestInfo.java:272)
at com.parse.ManifestInfo.deviceSupportsGcm(ManifestInfo.java:357)
at com.parse.ManifestInfo.getPushType(ManifestInfo.java:129)
at com.parse.PushService.startServiceIfRequired(PushService.java:150)
at com.parse.ParseBroadcastReceiver.onReceive(ParseBroadcastReceiver.java:19)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2833)
... 10 more
As you can see here Android Parse.com Simple ListView Tutorial you will need to call Parse.initialize from Application's onCreate instead of from Activity or Service. do it as:
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
// Add your initialization code here
Parse.initialize(this, YOUR_APPLICATION_ID, YOUR_CLIENT_KEY);
}
}
Also add ParseApplication in AndroidManifest.xml as application tag name:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:name="ParseApplication"
....

Xtify + Worklight 6.1 integration in android environment

We have been working on the integration between worklight and xtify for push notifications. We are using version 2.3.2 for xtify sdk since latest version (2.4.2) made the app failed because a class not found exception.
The logic for using xtify has been added to the native code of the WL hybrid application as follows:
public class XtifyWL extends WLDroidGap {
public static final String XTIFY_APP_KEY = "xxxxxxxx-xxxxx-xxxx-xxxxx-xxxxxxxxx";
public static final String PROJECT_NUM = "xxxxxxxxxxxx"; // This is the Google Project Number
#Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
XtifySDK.start(getApplicationContext(), XTIFY_APP_KEY, PROJECT_NUM);
}
We are receiving the push notifications, but they are duplicated. We received one notification for worklight that fails when you try to open it, and one more for the native application thats works correctly.
How can we fix it?
About the issue with the SDK 2.4.2.2
The exception with SDK 2.4.2.2 is:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to get provider com.xtify.sdk.db.Provider: java.lang.ClassNotFoundException: com.xtify.sdk.db.Provider
at android.app.ActivityThread.installProvider(ActivityThread.java:4609)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4236)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4178)
at android.app.ActivityThread.access$1400(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
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:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.xtify.sdk.db.Provider
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.installProvider(ActivityThread.java:4594)
... 12 more
The only place where we see that class is in the AndroidManifest.xml
<provider android:name="com.xtify.sdk.db.Provider" android:authorities="com.XtifyApp.XTIFY_PROVIDER" android:exported="false" />
If we comment that line it fails with the next use of any class of the SDK. We have added the sdk .jar file to the libs folder of the android project and to the build path of the android project.
Thanks,
We have found why when we send a push notification, we see them duplicated (two notifications icons on the top).
It was an error in the AndroidManifest.xml, we added all the Xtify GCM configuration and we also left the worklight GCM configuration so we where registering two receivers.
But we have still the issue of "java.lang.ClassNotFoundException" when we try to use the latest Xtify SDK. Athough at least receiving simple notifications seems to work with the SDK 2.3.2.
This is the correct AndroidManifest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.XtifyApp" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18"/>
<supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="false"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Push permissions -->
<permission android:name="com.XtifyApp.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.XtifyApp.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="#string/app_name" android:debuggable="true" android:icon="#drawable/icon">
<activity android:name=".XtifyApp" android:label="#string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.XtifyApp.XtifyApp.NOTIFICATION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.worklight.common.WLPreferences" android:label="Worklight Settings"></activity>
<!-- Start XTIFY -->
<provider android:name="com.xtify.sdk.db.Provider" android:authorities="com.XtifyApp.XTIFY_PROVIDER" android:exported="false" />
<receiver android:name=".XtifyNotifier" >
<intent-filter>
<action android:name="com.xtify.sdk.NOTIFIER" />
</intent-filter>
</receiver>
<receiver android:name="com.xtify.sdk.c2dm.C2DMBroadcastReceiver" >
<intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.XtifyApp" />
</intent-filter>
<intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.XtifyApp" />
</intent-filter>
</receiver>
<receiver android:name="com.xtify.sdk.NotifActionReceiver" />
<receiver android:name="com.xtify.sdk.wi.AlarmReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<service android:name="com.xtify.sdk.location.LocationUpdateService" />
<service android:name="com.xtify.sdk.c2dm.C2DMIntentService" />
<service android:name="com.xtify.sdk.alarm.MetricsIntentService" />
<service android:name="com.xtify.sdk.alarm.TagIntentService" />
<service android:name="com.xtify.sdk.alarm.RegistrationIntentService" />
<service android:name="com.xtify.sdk.alarm.LocationIntentService" />
<!-- END XTIFY -->
<!-- Start Worklight GCM configuration -->
<!--
<service android:name=".GCMIntentService"/>
<service android:name=".ForegroundService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.XtifyApp"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.XtifyApp"/>
</intent-filter>
</receiver>
-->
<!-- END Worklight GCM configuration -->
</application>
</manifest>

UserManager getUserCount() (Jelly Bean)

I am working on this class : UserManager
public int getUserCount ()
Return the number of users currently created on the device.
My code is:
UserManager um = (UserManager) getSystemService(USER_SERVICE);
int count = um.getUserCount();
Log.i("count",""+count);
It produce error like this:
Caused by: java.lang.SecurityException: You need MANAGE_USERS permission to: query users
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.os.IUserManager$Stub$Proxy.getUsers(IUserManager.java:321)
at android.os.UserManager.getUsers(UserManager.java:198)
at android.os.UserManager.getUserCount(UserManager.java:186)
at com.example.multiusertest.MainActivity.onCreate(MainActivity.java:52)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
I already added this permission manually in Manifest file. Does anyone know why it is produce.
Manifest File:
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.MANAGE_USERS"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.multiusertest.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The MANAGE_USERS has a protectionlevel of signature|system, which means that the application has to be signed with the platform key. See this thread on XDA

PhoneGap APK runs fine but crashes on each run after Google Play deployment

I have built an application for a large multicultural festival in my city that kicks off on Saturday. I've tweaked a lot of bugs in the iPhone version and we are waiting for Apple to approve it. I have taken that perfected version as the basis for the Android version.
The Android version looks and works great. I can run it on my Samsung Galaxy S II by either "Run as Android Application" in Eclipse or by uploading it to a server and downloading it into the phone. I can also email the app to myself and it works, too. I submitted it to the Google Play store and once it got into the wild (this is advertised on billboards, buses, everywhere) it crashes the minute it is opened.
I'm not really sure how to troubleshoot this when it works fine on the device before publication. I read about how it has to do with the MainActivity activity name, but everything looks like it lines up.
Error 1 [ClassNotFoundException in PathClassLoader.findClass()]:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.honestapi.folk2011/com.honestapi.folk2011.Folklorama}:
java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama in loader
dalvik.system.PathClassLoader[/data/app/com.honestapi.folk2011-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3997)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama in loader dalvik.system.PathClassLoader[/data/app/com.honestapi.folk2011-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
at java.lang.ClassLoader.loadClass(ClassLoader.java:548)
at java.lang.ClassLoader.loadClass(ClassLoader.java:508)
at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
Error 2 [ClassNotFoundException in BaseDexClassLoader.findClass()]:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.honestapi.folk2011/com.honestapi.folk2011.Folklorama}:
java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
at android.app.ActivityThread.access$600(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
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:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.honestapi.folk2011.Folklorama
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1027)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1885)
Any help would be greatly appreciated! I am in quite the pickle.
Edit - Here is the AndroidManifest.xml from the bin folder
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="false" android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name" android:theme="#style/AppTheme">
<activity android:name=".MainActivity" android:label="#string/title_activity_main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="#string/share_name">
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
It turned out my main Java file was named "MainActivity.java" but it was being called as "Folklorama.java" throughout the project files. I renamed the file to Folklorama.java.

How to fix this classnotfound exception in Android?

I got the stack trace below in the Android developer account. There is just one occurrence of this error.
java.lang.RuntimeException: Unable to instantiate application com.mysite.myapp.TestApplication: java.lang.ClassNotFoundException: com.mysite.myapp.TestApplication in loader dalvik.system.PathClassLoader[/data/app-private/com.mysite.myapp-2.apk]
at android.app.LoadedApk.makeApplication(LoadedApk.java:466)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3268)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.myapp.TestApplication in loader dalvik.system.PathClassLoader[/data/app-private/com.mysite.myapp-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newApplication(Instrumentation.java:945)
at android.app.LoadedApk.makeApplication(LoadedApk.java:461)
... 11 more
In my manifest file, I have declared com.mysite.myapp.TestApplication.
My Manifest file looks like this:
<application
android:name="com.mysite.myapp.TestApplication"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/Theme.myapp" >
<activity
android:name="com.mysite.myapp.ActivityDashboard"
android:configChanges="orientation|keyboard"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
If your main home page is ActivityDashboard.java
insert as below or if TestApplication.java
replace .ActivityDashboard as .TestApplication in the activity tag
<package name="com.mysite.myapp"
<application
android:name="TestApplication"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/Theme.myapp" >
<activity android:name=".ActivityDashboard" android:configChanges="orientation|keyboard"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
......
</application>
android:name="com.mysite.myapp.ActivityDashboard"
Replace thr above in your manifest with the below.
android:name=".ActivityDashboard"
Alternatively:
android:name="com.mysite.myapp.TestApplication.ActivityDashboard"

Categories

Resources