Classnotfoundexception When Trying To Start A Service From An Activity In Android
Solution 1:
This kinda crap just happens sometimes. Try cleaning the project...
Also, if you're starting the service from a different package, try using the full package and then class name.
Intentintent=newIntent();
intent.setClassName("com.example.Something", "com.example.Something.MyService");
startService(intent);
Solution 2:
Just an idea: if you go to "bin" folder of the project there should be your "*.apk" file. Rename it to zip, unzip and investigate if there is your service class. I suspect smth went wrong at build step and your class is not in the apk. Delete everything that is in bin folder and manage to rebuild the project from scratch. Then unzip/check again.
Solution 3:
Is the service in some package? if so, you may need to use the full path of the Service class in your manifest.
Solution 4:
Try this:
startService(newIntent(this, MyService.class));
If you still have a problem, in the Manifest.XML file tack on the package name to the beginning of the service name as follows:
<serviceandroid:name="mypackagename.MyService"></service>
Not sure why you have that "exported" code in there.
Post a Comment for "Classnotfoundexception When Trying To Start A Service From An Activity In Android"