Android - ClassNotFoundException after refactoring - android

I've recently refactored class, package and folder names in my app (it's currently called MyApp) using Eclipse's refactor command, and I'm not getting a ClassNotFoundException. I've made sure there are no more instances of the old name anywhere in the code base. I've also deleted all the class files in \bin\classes and generated Java files in \gen (both of which have regenerated, I've checked). I've also updated the API level from 16 to 17 in an attempt to solve the problem. Here is the stack trace:
12-22 17:00:46.690: E/AndroidRuntime(25466): FATAL EXCEPTION: main
12-22 17:00:46.690: E/AndroidRuntime(25466): java.lang.RuntimeException: Unable to instantiate application com.myapp.MyApp: java.lang.ClassNotFoundException: Didn't find class "com.myapp.MyApp" on path: /data/app/com.myapp-2.apk
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4364)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.ActivityThread.access$1300(ActivityThread.java:141)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.os.Handler.dispatchMessage(Handler.java:99)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.os.Looper.loop(Looper.java:137)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-22 17:00:46.690: E/AndroidRuntime(25466): at java.lang.reflect.Method.invokeNative(Native Method)
12-22 17:00:46.690: E/AndroidRuntime(25466): at java.lang.reflect.Method.invoke(Method.java:511)
12-22 17:00:46.690: E/AndroidRuntime(25466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-22 17:00:46.690: E/AndroidRuntime(25466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-22 17:00:46.690: E/AndroidRuntime(25466): at dalvik.system.NativeStart.main(Native Method)
12-22 17:00:46.690: E/AndroidRuntime(25466): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.MyApp" on path: /data/app/com.myapp-2.apk
12-22 17:00:46.690: E/AndroidRuntime(25466): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
12-22 17:00:46.690: E/AndroidRuntime(25466): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-22 17:00:46.690: E/AndroidRuntime(25466): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.Instrumentation.newApplication(Instrumentation.java:968)
12-22 17:00:46.690: E/AndroidRuntime(25466): at android.app.LoadedApk.makeApplication(LoadedApk.java:499)
12-22 17:00:46.690: E/AndroidRuntime(25466): ... 11 more
Here is my Manifest. I know hardcoding strings is bad style.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="#drawable/ic_launcher"
android:name="MyApp"
android:label="MyApp"
android:theme="#style/NoActionBar">
<activity
android:name=".Otheractivity"
android:label="Otheractivity">
</activity>
<activity
android:name=".MainMenu"
android:label="MainMenu">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Any ideas on what the problem could be?

had the same problem, solved it by :
right click your project -> Java build path -> order and export(tab) -> make 'v' on "android private libraries"
tell me if it worked.

android:name="MyApp" in your Manifest means you need to have MyApp.java, declaring the class MyApp extending Application in your com.myapp package.

For those who still get this error in Android Studio, I resolved this by deleting .gradle folder from root directory -> clean and build -> run app again.

with the latest version of eclipse/ adt I get this sometimes when I have external libraries included. Removing them from the build path, and re-adding usually works to fix it.

Related

Android Flow example crashes with ClassNotFoundException

I'm Naive in Android development. I tried to use flow/mortar for development and stuck with an exception.
Here's what I did. In Eclipse, I chose New (Crtl N) -> Android Project from existing code and imported the flow sample downloaded from the square flow website https://github.com/square/flow/.
Eclipse marked errors in all the files as the package name was not matching the file's location. So to fix the package mismatch issue, I moved the files from : \flow-master\flow-sample\src\main\java\com\example\flow to : \flow-master\flow-sample\src\com\example\flow.
After this, I got some more errors saying 'Unresolved to a Type' which I fixed by importing proper jar files. Now all the errors are cleared and I tried to install and launch the app.
The app crashes as soon as we launch with the Logcat error below:
E/AndroidRuntime(5438): FATAL EXCEPTION: main
E/AndroidRuntime(5438): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.flow/com.example.flow.MainActivity}: java.lang.ClassNotFoundException: com.example.flow.MainActivity
E/AndroidRuntime(5438): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1888)
E/AndroidRuntime(5438): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1989)
E/AndroidRuntime(5438): at android.app.ActivityThread.access$600(ActivityThread.java:126)
E/AndroidRuntime(5438): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1155)
E/AndroidRuntime(5438): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(5438): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(5438): at android.app.ActivityThread.main(ActivityThread.java:4482)
E/AndroidRuntime(5438): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(5438): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(5438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
E/AndroidRuntime(5438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
E/AndroidRuntime(5438): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(5438): Caused by: java.lang.ClassNotFoundException: com.example.flow.MainActivity
E/AndroidRuntime(5438): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(5438): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(5438): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(5438): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E/AndroidRuntime(5438): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
E/AndroidRuntime(5438): ... 11 more
The error says that the file MainActivity is not found even when the file is available in the path com.example.flow.. Can someone please help me understand what the issue is?
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flow"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18"/>
<application
android:icon="#drawable/flow_icon">
<activity
android:label="Flow"
android:name="com.example.flow.MainActivity"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

Weird Android error

I'm trying to run my start my app, but i get a weird error. I've changed my OS but I've imported my projects in my Workspace. What can be wrong? Every thing is added to the maniferst file like is should, and this app was running nice before I change my OS.
12-13 18:48:10.578: W/dalvikvm(19830): Unable to resolve superclass of Lcom/darkovski/quran/Main; (56)
12-13 18:48:10.578: W/dalvikvm(19830): Link of class 'Lcom/darkovski/quran/Main;' failed
12-13 18:48:10.578: D/AndroidRuntime(19830): Shutting down VM
12-13 18:48:10.578: W/dalvikvm(19830): threadid=1: thread exiting with uncaught exception (group=0x2b542210)
12-13 18:48:10.598: E/AndroidRuntime(19830): FATAL EXCEPTION: main
12-13 18:48:10.598: E/AndroidRuntime(19830): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.darkovski.quran/com.darkovski.quran.Main}: java.lang.ClassNotFoundException: com.darkovski.quran.Main
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1891)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.ActivityThread.access$600(ActivityThread.java:127)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.os.Handler.dispatchMessage(Handler.java:99)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.os.Looper.loop(Looper.java:137)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.ActivityThread.main(ActivityThread.java:4441)
12-13 18:48:10.598: E/AndroidRuntime(19830): at java.lang.reflect.Method.invokeNative(Native Method)
12-13 18:48:10.598: E/AndroidRuntime(19830): at java.lang.reflect.Method.invoke(Method.java:511)
12-13 18:48:10.598: E/AndroidRuntime(19830): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-13 18:48:10.598: E/AndroidRuntime(19830): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-13 18:48:10.598: E/AndroidRuntime(19830): at dalvik.system.NativeStart.main(Native Method)
12-13 18:48:10.598: E/AndroidRuntime(19830): Caused by: java.lang.ClassNotFoundException: com.darkovski.quran.Main
12-13 18:48:10.598: E/AndroidRuntime(19830): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-13 18:48:10.598: E/AndroidRuntime(19830): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-13 18:48:10.598: E/AndroidRuntime(19830): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-13 18:48:10.598: E/AndroidRuntime(19830): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
12-13 18:48:10.598: E/AndroidRuntime(19830): ... 11 more
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.darkovski.quran"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.darkovski.quran.Main"
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="com.darkovski.quran.Playlist"
android:screenOrientation="portrait" />
<activity
android:name="com.darkovski.quran.AlbumDetails"
android:screenOrientation="portrait" />
<service
android:name=".MediaPlayerService"
android:enabled="true" />
<activity
android:name="com.darkovski.quran.Favorites"
android:screenOrientation="portrait" />
<activity
android:name="com.darkovski.quran.DownloadManager"
android:screenOrientation="portrait" />
</application>
</manifest>
This has nothing to do with Manifest. It is because somehow the super class of your class com/darkovski/quran/Main is not getting loaded in the apk which leads to a class not found.
Try cleaning and rebuilding the project or restarting eclipse. Just check if all the libraries are present in the new workspace and are build properly.

Coding android app with google maps v2 - Crashes immediately

I am new to app programming, and programming in general. I am still in school for computer science (i'm a sophmore). So please take it easy on me. I hate getting bashed on forums.
My problem is that my app, which will use google maps as the main window crashes immediately. I have posted all my code below, and I am looking for any help to what I might be missing to get this app up and running (or so it does not crash immediately).
A couple things might be wrong:
1) I am now using the SHA1 debug key for this testing stage. Is this right?
2) Do I need to communicate with a type 'GoogleMap' in java to set starting location or anything?
3) I am testing this on my phone (Galaxy SIII) which has worked in the past on simple layouts, but might testing this google maps app need authentication that the phone cannot give?
A couple links I found helpful, up until now:
https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
Google Maps Android API v2 - Sample Code crashes
Notes on setup: I have added android-support-v4.jar and google-play-services.jar to my reference libraries.
Properties -> Java Build Path, Libraries
Now, Below, this is all the code I have so far!
Java file (Main.java):
package com.MYDOMAINNAME.www;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
xml file (main layout):
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
program manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MYDOMAINNAME.www"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.MYDOMAINNAME.www.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.MYDOMAINNAME.www.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name= "com.google.android.maps" />
<activity
android:name="com.MYDOMAINNAME.www.Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY SHA1 DEBUG KEY"/>
</application>
</manifest>
So I would ask, is there anything I need to add or subtract to get this going?
Thanks a bunch!
Log Cat:
12-22 14:45:28.482: E/Trace(10174): error opening trace file: No such file or directory (2)
12-22 14:45:28.482: D/ActivityThread(10174): setTargetHeapUtilization:0.25
12-22 14:45:28.482: D/ActivityThread(10174): setTargetHeapIdealFree:8388608
12-22 14:45:28.482: D/ActivityThread(10174): setTargetHeapConcurrentStart:2097152
12-22 14:45:28.502: D/AndroidRuntime(10174): Shutting down VM
12-22 14:45:28.502: W/dalvikvm(10174): threadid=1: thread exiting with uncaught exception (group=0x4155e438)
12-22 14:45:28.512: E/AndroidRuntime(10174): FATAL EXCEPTION: main
12-22 14:45:28.512: E/AndroidRuntime(10174): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.MYDOMAINAME.www/com.MYDOMAINAME.www.MainActivity}: java.lang.ClassNotFoundException: com.MYDOMAINAME.www.MainActivity
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2012)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.ActivityThread.access$700(ActivityThread.java:139)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.os.Handler.dispatchMessage(Handler.java:99)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.os.Looper.loop(Looper.java:137)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.ActivityThread.main(ActivityThread.java:4918)
12-22 14:45:28.512: E/AndroidRuntime(10174): at java.lang.reflect.Method.invokeNative(Native Method)
12-22 14:45:28.512: E/AndroidRuntime(10174): at java.lang.reflect.Method.invoke(Method.java:511)
12-22 14:45:28.512: E/AndroidRuntime(10174): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
12-22 14:45:28.512: E/AndroidRuntime(10174): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
12-22 14:45:28.512: E/AndroidRuntime(10174): at dalvik.system.NativeStart.main(Native Method)
12-22 14:45:28.512: E/AndroidRuntime(10174): Caused by: java.lang.ClassNotFoundException: com.MYDOMAINAME.www.MainActivity
12-22 14:45:28.512: E/AndroidRuntime(10174): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-22 14:45:28.512: E/AndroidRuntime(10174): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-22 14:45:28.512: E/AndroidRuntime(10174): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
12-22 14:45:28.512: E/AndroidRuntime(10174): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2003)
12-22 14:45:28.512: E/AndroidRuntime(10174): ... 11 more
What did you name your java file for Main? It should be Main.java not MainActivity.java.
If you look at the log , this line 12-22 14:04:16.043: E/AndroidRuntime(9154): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.gotonight.www/com.gotonight.www.MainActivity}: java.lang.ClassNotFoundException: com.gotonight.www.MainActivity its trying to find com.gotonight.www.MainActivity but your Main class is com.gotonight.www.Main

Android - exception launching project on start after copying a lot of code over from another project

am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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.ClassNotFoundException: business.premium.Problemio
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:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
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:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app

ClassNotFoundException on Galaxy Tab (only)

I have a working Android application. It works on more than 500 different devices. The manifest is
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.decamps.droid.photoid" android:versionCode="5"
android:versionName="1.4">
<application android:icon="#drawable/icon" android:label="#string/app_label"
android:name="PhotoIDroid" android:description="#string/app_desc"
android:debuggable="FALSE">
But when it it launched from a Samsung Galaxy Tab, it doesn't start and crashes with:
java.lang.RuntimeException: Unable to
instantiate application
info.decamps.droid.photoid.PhotoIDroid:
java.lang.ClassNotFoundException:
info.decamps.droid.photoid.PhotoIDroid
in loader
dalvik.system.PathClassLoader[/data/app/info.decamps.droid.photoid-1.apk]
at
android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:670)
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4483)
at
android.app.ActivityThread.access$3000(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181)
at
android.os.Handler.dispatchMessage(Handler.java:99)
at
android.os.Looper.loop(Looper.java:144)
at
android.app.ActivityThread.main(ActivityThread.java:4937)
at
java.lang.reflect.Method.invokeNative(Native
Method) at
java.lang.reflect.Method.invoke(Method.java:521)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at
dalvik.system.NativeStart.main(Native
Method) Caused by:
java.lang.ClassNotFoundException:
info.decamps.droid.photoid.PhotoIDroid
in loader
dalvik.system.PathClassLoader[/data/app/info.decamps.droid.photoid-1.apk]
at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at
android.app.Instrumentation.newApplication(Instrumentation.java:945)
at
android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:660)
... 11 more
How an the Samsung Galaxy not find the application class?
Any clue on how to resolve this?
I have been able to reproduce tis crash on the Samsung Galaxy emulator.
I have removed the android:name attribute declaration from the AndroidManifest.xml and it now works.

Categories

Resources