I have created 2 flavors(one and two) and one main package as you can see in image which i have shared. These three flavors has a separate three MainActivity.class.
when i change the flavor i am trying to change the textView content from MainActivity.class of its flavor, but it's not getting changed. Only the layout is getting replaced as per the flavor not the class.
For example, i set current flavor as one and set textView content as "one" from MainActivity.class its not getting changed but it takes the MainActivity.class of main package and the layout is working taken based on the flavor.
project structure image
Only the layout is getting replaced as per the flavor not the class.
Because the MainActivity.java of "main" is used every time.
The package name must be same in the other two modules.
Java files are not replaced so, you can remove MainActivity of "main".
Make a manifest file for your specific flavour that overrides the new activity for the flavour as follows:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<!-- Tutorial activity -->
<activity android:name="com.colan.flavortest.MainActivity" />
<activity
android:name="com.colan.newtwo.MainActivity"
tools:node="remove" />
<activity-alias
android:name="com.colan.newtwo.MainActivity"
android:targetActivity="com.colan.flavortest.MainActivity"
tools:replace="android:targetActivity"/>
</application>
</manifest>
Android.Content.ActivityNotFoundException: Unable to find explicit activity class {AgLiveMobile.Droid/aglivemobile.droid.views.NewDemoView};
have you declared this activity in your AndroidManifest.xml?
I am implementing Drawer menu and referring
https://github.com/benhysell/V.FlyoutTest
I am getting this error on following line :
this.ShowViewModel<NewDemoViewModel>();
I have also given full path as follows in the xml file :
<activity
android:name="aglivemobile.droid.views.NewDemoView">
</activity>
What does it mean? What should I do to resolve this?
Thanks in advance
Maybe you need to check that you added the new activity to the manifest.xml file
or
The activity you are calling should appear not only in the Manifest for its own package, but in the Manifest for the CALLING package, too.
Probably, you have to add presenter (if you don't have) to Setup for Android. Something like that:
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies);
Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(mvxFragmentsPresenter);
return mvxFragmentsPresenter;
}
I have two classes one that extends Activity and inside that class file I called another intent which class extends ListActivity. How do I change the androidmanifest.xml file to load that two activities? I should say that I declared both of the activities in androidmanifest.xml file as
<activity android:name="NoteActivity"></activity>
<activity android:name="AddNote"></activity>
the NoteActivity extends Activity and the AddNote extends ListActivity; when I run it it doesn't run and said "stopped" unfortunately.
You need to define your newly created activities in manifest too. So simply update your AndroidManifest.xml at least as minimum as below:
<activity android:name=".NoteActivity" android:label="Activity1" />
<activity android:name=".AddNote" android:label="Activity2" />
*It is assumed that your activity files are placed in root of your package as defined in manifest and make sure the class names are correctly depicted in the xml above.
Note: Make sure your activity starts with a dot (.) symbol too.
Attempts to switch activities between two Android Fragments is failing.
This happens in spite of using the Android doco example verbatim:
Android Fragment doco
Attempts to add the target Fragment to the AndroidManifest.xml does not compile with the same message that is in the Title of this question.
If I hack the same process using only Views and straight Activities the all is well.
If I leave the AndroidManifest.xml unchanged then I get a run-time exception with the question:
android.content.ActivityNotFoundException: Unable to find explicit activity class {name.davidwbrown.actionbartabs/name.davidwbrown.actionbartabs.UserDetailsFragment}; have you declared this activity in your AndroidManifest.xml?
Try defining an xml layout containing the fragment instead of assigning it to the <activity> tag on the manifest. Then use findViewById(R.id.frameId) to find it in code and then attach it to the activity. In the manifest, keep the activity tag something similar to this and it should work:
<activity
android:name="name.davidwbrown.actionbartabs.UserDetailsFragment"
android:label="#string/activity_name" >
</activity>
Maybe you should try changing your Fragment class to a FragmentActivity class.
I am getting this exception while I am trying to call an activity from another one. The complete exception is
android.content.ActivityNotFoundException:Unable to find explicit activity class {com.x.y/com.x.y.class};
I am doing an intent.setClass("com.x.y","com.x.y.className") where className is the name of my activity class and com.x.y is the package it resides in.
My AndroidManifest.xml has the following content:
<activity android:name="com.x.y.className" android:label="#string/app_name">
Am I missing anything?
Maybe you need to check that you added the new activity to the manifest.xml file
Example:
<activity
android:name=".className"
android:label="#string/app_name" >
</activity>
If other people are encountering something similar and arrive at this post, an issue I had may save you some time. May not be related to the OP's problem but def related to the ActivityNotFound exception.
I was trying to load an activity by using:
Intent intent = new Intent( this, class );
However I continuously kept getting the ActivityNotFoundException even though I had checked and rechecked the code multiple times.
This exception I was getting wasn't actually being caused by the intent but some code I was running inside the loaded activity throwing a RuntimeException. (my issue was caused by Typeface.createFromAsset())
It is possible you are running into a similar RuntimeException in your activity.
To see if this is the case, put your intent code in try catch blocks. Like so:
try {
/* your code */
...
} catch ( ActivityNotFoundException e) {
e.printStackTrace();
}
Run your app again, and check your LogCat, if it's the same issue, you'll get a RuntimeException with a "Caused By:" entry pointing to your actual issue.
I spent a good hour trying to figure this out. Hopefully this may save someone some time.
The activity you are calling should appear not only in the Manifest for its own package, but in the Manifest for the CALLING package, too.
Delete your activity from the manifest and then add it again. This type do not write type the XML directly. Instead, go to Application > Application nodes > add, choose the Activity, and then browse for the file source.
This worked for me.
intent.setClass takes parameters as "Package Context" and "Class".
an example would be:
intent.setClass(CurrentActivity.this, TargetActivity.class);
also you need to check if the activity is registered in manifest file.
Added a new activity and defined it in manifest.xml, but I was still getting "Unable to find explicit activity class" error. I am using Eclipse. Solution for my problem was "cleaning" the project. From the main menu in Eclipse: Project|Clean.... Then you select your project and clean it.
Hey, you need to use another form of Intent constructor. This will surely solve your issue within a second:
Example:
Intent inte=new Intent(getBaseContext(),"your class name with .class extension ");
startActivity(inte);
This works perfectly and I checked this code, its working properly.
I had an ActivityNotFoundException when I implemented the Activity inside another class (as an inner class):
//... inside the utility class Pref
public static class Activity extends PreferenceActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
}
//...
Declared as the following inside the manifest:
<activity android:name=".Pref.Activity"
...
After declaring this as a normal class (public class PrefActicity) and changing manifest accordingly, it worked as usual.
I was using getActivityContext() (instead of Activity.this) for the menu code to save some work, and copy-and-paste it to each activity without editing each time.
I replaced them with Activity.this, and the issue is gone.
I have a feeling a smarter Android guy could work-around not having to do that. Would like to hear what it would be.
Looking at the documentation here what you want is:
intent.setClassName("com.x.y", "className");
Restart the Eclipse and check your Manifestfile again. If you find missing the respective Activity, then add it and try again. It solved my similar issue.
In addition to Mina's answer.
When you declare activity as inner static class then you should write your activity into manifest like ...
<activity android:name=".app.FragmentLayoutSupport$DetailsActivity" />
here .app comes from your package name , it can be .helpers.afdfa$afda
My solution to this error was to add a package name in front of the name in manifest.
I had the following activities:
id.scanner.main.A1
id.scanner.main.gallery.A2
My manifest contained the following:
<activity android:name=".A1" ....></activity>
<activity android:name=".A2" ....></activity>
This solved the problem:
<activity android:name=".A1" ....></activity>
<activity android:name="gallery.A2" ....></activity>
Yeah I got this problem too. I refreshed the project. And then, everything works fine.
when i have same issue. if you are using library class files and writing it into android manifest files write it like and then remove the library projects manifest files this portion>>
then it will work absolutely..
This exception also occurs if you include a library in your app and if the library is calling an activity defined in the library project. In this case we need to merge library's manifest with calling app's manifest.
With ADT version 20, we can do this by adding the below statement in project.properties of calling app.
manifestmerger.enabled=true
Check out the content of the Android Manifest File in the bin folder of the project. When your app is compiled and packaged the Manifest File is copied to the bin folder. In my case the Manifest in the bin folder did not agree with the original Manifest. This is probably a mistake of Eclipse. I manually copied the Manifest to the bin folder and it worked.
you can add this code in manifiest.xml file
action android:name="com.kaushalam.activity101activity.SecondActivity"
category android:name="android.intent.category.DEFAULT"
I got the same case too. After reading thepearson's answer, I revised my Activity and found out that I wrote
public void onCreate(Bundle s)
But in fact it should be
protected void onCreate(Bundle s)
And it works now!
This works if you have an Activity object (which you need to launch):
intent.setClassName(CallingActivity.this, activityToLaunch.getComponentName().getClassName());
Activity you're calling sholdn't contain "sheme" and contain intent-filter:
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="com.example.sj.myapplication.SecondActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
so in calling code:
Intent intent=new Intent("com.example.sj.myapplication.SecondActivity");
startActivity(intent);
Try using the following:
intent.setClassName("com.x.y", "com.x.y.className");
This works for me
I also ran into ActivityNotFoundException by passing the wrong view into setContentView(), each activity's class file must correspond with the layout xml file this way.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wrongView);
}
as opposed to
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.correctView);
}
I had the same issue. I tried everything but the error, which I sorted out later, was that there was a space left between double quotes and my class name. It has to be:
intent.setClassName("com.x.y","com.x.y.className")
not
intent.setClassName("com.x.y"," com.x.y.className")