I have sub-folders(packages) defined in an application, which has to be defined in Manifest file accordingly.
But after defining as per the conventions and as suggested by patrons in their posts, the application crashes. The error again in the logcat is
"03-17 19:38:54.118: E/AndroidRuntime(558): android.content.ActivityNotFoundException: Unable to find explicit activity class {in.co.avksons/prox_analysis.prox_main_scr}; have you declared this activity in your AndroidManifest.xml?"
I tried to look in each file on the specifics of the package, but could not find the error.
What are the possible causes for not acknowledging the package definition in the manifest file.
Thanks
Can you post your Manifest file? I have a feeling you are referencing your Activity incorrectly.
If for example you have an activity called TestActivity, and it was under the folder Activities, and your package name was com.test.app then you would reference your activity as follows:
com.test.app.Activities.TestActivity
You cant use '/' in the manifest file, use '.' instead.
Most likely, you have wrong declaration of activiy in Manifest. If you have package "com.application.view", for example, declaration will be like this:
android:name=".view.Activity"
Related
I need to add an activity tag for an external library I'm using, per their documentation, but when I do that using this code
<activity
android:name="com.adityaanand.morphdialog.MorphDialogActivity"
android:theme="#style/MorphDialog.Custom.Light">
</activity>
in my application tag, I get the error
Unable to find explicit activity class {com.jggdevelopment.simpleweather/in.adityaanand.morphdialog.MorphDialogActivity}; have you declared this activity in your AndroidManifest.xml?
How can I include an external library's activity in my manifest file?
This is the library.
All I had to do was change the activity name to in.adityaanand.morphdialog.MorphDialogActivity and it worked. I thought I had tried that already, but I guess not.
Is it compulsory to add a class file, which extends activity, to manifest?
I have created a java file for handling file IO and to use openfileoutput() openfileinput() i have extended Activity class.
YES you most declare it in the manifest so the application will know its activity.
If you use/call that class (which extends Activity) somewhere in your code, you MUST declare that class (Activity) in Manifest file. If you don't, you will get exception.
Manifest file is used to declared essential information for your app (Activity, Service, Broadcast Receiver, keys,...).
For more info about Manifest, you can check it here.
when you launch the application first the OS will check your manifest file.So if your Activity is not Listed in the Manifest file.Then it won't execute it.So your ACTIVITY class should be declared in the Manifest file.
in my application I call
startActivityForResult( new Intent(this, ShowPreferencesActivity.class), <some code>);
the activity is declared as :
package ca.qc.webalterpraxis.cinedroid.activity.preference;
public class ShowPreferencesActivity extends PreferenceActivity { ...}
and in my manifest I got :
<activty android:name=".activity.preference.ShowPreferencesActivity" android:label="#string/set_preferences">
But I receive an exception when I try to start the activity (in the first line of code of this question) :
E/AndroidRuntime(1830): android.content.ActivityNotFoundException: Unable to find explicit activity class {ca.qc.webalterpraxis.cinedroid/ca.qc.webalterpraxis.cinedroid.activity.preference.ShowPreferencesActivity}; have you declared this activity in your AndroidManifest.xml?
I tried everything I could :
replacing, in the manifest, the name of the class with the fully qualified name of the class
setting the intent class name using setClassName
providing a default filter for the activity
I relaunched eclipse around 10 times, rebooted my computer, erased the application from the device, resintalled, etc...
I don't have any idea of what's happening. And the worse is that it was working before, but not anymore after I renamed the class. Something strange : even if I rename the class now, the AndroidManifest won't update in eclipse, I have to update it by hand..but it still works for other classes...
Also, please note that I have a test application, apart of the under test app, and the test app can't find the activity to instrument it, neither.
Oh, and last but not least, I am 100 % sure that the ShowPreferencesActivity is in the resulting dex file, I dexdumped it to check.
Thanks in advance for your time.
(I use the maven-android-plugin)
Thanks all, I found my problem : the tag in the manifest was
<activty
and not
<activity
But why does eclipse allow that ???!!!
I want to open an activity without declaring it in an manifest file.
I don't know if it is possible or not.
What I actually want is to dynamically open an activity from my program using intents.
Can anyone help me if it is possible.
Not possible. Although I am unsure what you mean "dynamically open an activity".
See: http://developer.android.com/reference/android/app/Activity.html
Under Class Overview it states "To be of use with Context.startActivity(), all activity classes must have a corresponding declaration in their package's AndroidManifest.xml"
You can have an Activity in your package and not define it in the manifest, however you would not be able to start it successfully.
Your 'Dynamic' activity start is actually the normal way of starting an activity (as you have said in a comment to the answer of Matt M). Though you HAVE to add the Activities in manifest as Matt M said. In list view, clicking an activity will call a function that will start respective activity with startActivity() function.
I tried this very long, but since the Instrumentation class uses the IActivityTaskManager, which is a class of the internal API located at com.android.server.wm, that is not in the Activity classloader, I solved this by another method:
Using a subclass
I just made an Gist, with sample code.
GIST
Is it required to start activity name with dot ('.') in manifest file.? for example activity
ContactManager starts with '.'
<activity android:name=".ContactManager" android:label="#string/app_name">
where as the activity ContactAdder is without dot
<activity android:name="ContactAdder" android:label="#string/addContactTitle">
in the manifest file of ContactManager sample http://developer.android.com/resources/samples/ContactManager/AndroidManifest.html
UPDATE: If activity name starts with . it is appended to package name to become fully qualified name, but what happens if it doesn't start with '.'
I got curious too, and went looking for it in the Android source code.
I found what seems to be the relevant code at the platform/frameworks/base repository, in the tools/aapt/Resource.cpp file. The relevant function is fullyQualifyClassName, called by massageManifest.
The rule it applies is explained in a comment block within the fullyQualifyClassName function:
// asdf --> package.asdf
// .asdf .a.b --> package.asdf package.a.b
// asdf.adsf --> asdf.asdf
Explaining this rule, we have:
If the name starts with a dot, always prefix it with the package.
If the name has a dot anywhere else, do not prefix it.
If the name has no dot at all, also prefix it with the package.
So, to answer your question: as long as there is no dot anywhere else, both ways of writing the activity name should have the same effect.
As an extra, the massageManifest function shows where this rule is applied:
In the application element, on the name and backupAgent attributes.
In the activity, service, receiver, provider, and activity-alias elements, on the name attribute.
In the activity-alias element, on the targetActivity attribute.
From the Android Dev Guide < activity > reference:
The name of the class that implements
the activity, a subclass of Activity.
The attribute value should be a fully
qualified class name (such as,
"com.example.project.ExtracurricularActivity").
However, as a shorthand, if the first
character of the name is a period (for
example, ".ExtracurricularActivity"),
it is appended to the package name
specified in the element.
There is no default. The name must be
specified.
Recently I understood the application package concept in Android and the answer for this question, thought i should share it.
If the application package(specified in manifest) is same as the java package in which Activity is present then it is not required to specify full package name in manifest for activities. If application package name is different from the java package name then activity name should be complete with package name.
This blog post give information about the application package and java packages in android.
http://blog.javia.org/android-package-name/comment-page-1/#comment-14063