I am getting following exception
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.as.as/com.as.as.LoginActivity$myTask}; have you declared this activity in your AndroidManifest.xml?
No clue as to whats wrong in this
<application
android:name=".ObjectClass.AppController"
android:allowBackup="true"
android:icon="#drawable/app_logo"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PersonalDetails"
android:label="#string/title_activity_personal_details"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".SignUpRegistration.SignUp" />
<activity
android:name="com.intsig.ccrengine.ISCardScanActivity"
android:label="#string/app_name" />
First try to clean and build project again and then try.
If it's not working then append a full path to your LoginActivity.
For e.g. your package name is com.exmaple then you write in your manifest com.example.LoginActivity instead of just .LoginActivity.
Looks like you are creating the Intent in the wrong way.
From this line
Unable to find explicit activity class {com.as.as/com.as.as.LoginActivity$myTask};
You can tell that you are creating an intent which explicit target is the myTask class, when in reality you want to have the Activity class to be the target class.
Your creating activity code is wrong.
new Intent(getBaseContext(), myTask.class);
This code trying to open activity from myTask class. Guess you are waiting for following code:
new Intent(getBaseContext(), AnotherActivity.class);
Related
Good afternoon,
I have an activity that calls another. The code is as follows:
Intent i = new Intent(getApplicationContext(),Menu.class);
startActivity(i);
When I run the application get the following error:
android.content.ActivityNotFoundException: Unable to find explicit activity class {proyecto.uvigo/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
I do not understand what is wrong because I have already stated, the Activity Menu on the AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="proyecto.uvigo"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Inicio"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".Login"></activity>
<activity android:name=".Menu"></activity>
<activity android:name=".RecuperarPass"></activity>
<activity android:name=".Auxiliar"></activity>
<activity android:name=".MiPerfil"></activity>
<activity android:name=".CambiarPass"></activity>
</application>
Thanks!
It's because your code is using android.view.Menu as an Activity instead of your Menu class. Try this:
Intent i = new Intent(getApplicationContext(), proyecto.uvigo.Menu.class);
startActivity(i);
Alternately, you could rename your Menu class to something like UvigoMenu or UvigoMenuActivity in your class and in your manifest, just to avoid confusion like this.
I am not sure but there is something wrong with Unable to find explicit activity class {proyecto.uvigo/android.view.Menu};. Why android.view.Menu?. Please, check if import android.view.Menu class. If yes, use this
Intent i = new Intent(getApplicationContext(), proyecto.uvigo.Menu.class);
or import proyecto.uvigo.Menu instead of android.view.Menu.
start Menu activity as:
Intent i = new Intent(getApplicationContext(), proyecto.uvigo.Menu.class);
startActivity(i);
or
Intent i= new Intent();
i.setComponent(new ComponentName("proyecto.uvigo", "proyecto.uvigo.Menu"));
startActivity(i);
change
<activity android:name=".Menu"></activity>
to
<activity android:name=".Menu">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I have an android project with several packages. The structure of the packages in this case is com.WAPP.SetLocation is the package that contains the activity I want to run.
In my manifest, com.WAPP is considered the base package:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.WAPP"
android:versionCode="1"
android:versionName="1.0">
My activities are declared in my manifest as:
<activity android:name=".mainScreenActivity"></activity>
<activity android:name=".SetLocation.setLocationActivity"></activity>
The mainScreen activity displays fine, since it is inside the com.WAPP package. But when I try to run the setLocationActivity, I get the unable to find explicit class error. Here is how I have the intent parameters:
Intent i = new Intent();
i.setClassName("com.WAPP.SetLocation",
"com.WAPP.SetLocation.setLocationActivity");
startActivity(i);
The first parameter is application package not the package where the activity is.
You can invoke the Activity like this.
Intent i = new Intent();
i.setClassName("com.WAPP",
"com.WAPP.SetLocation.setLocationActivity");
startActivity(i);
It is preferred as SYLARRR suggested to have Android automatically figure that out for you. Hence the call as..
startActivity(new Intent(this, setLocationActivity.class));
It's recommended per java standards to have the package name all lower-cased and the class name as CamelCased.
If the new activity not in the same packet with MainActivity(you call from here?), try declare on manifest
<activity android:name="com.WAPP.SetLocation.setLocationActivity"></activity>
and in the caller
Intent intent = new Intent(this, setLocationActivity.class);
startActivity(intent);
Hope this helps!
In additional to the above answers make sure that your activities are declared inside application in manifest
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true">
<activity android:name=".mainScreenActivity"></activity>
<activity android:name=".SetLocation.setLocationActivity"></activity>
</application>
If i'm not mistaken, the i.setClassName("com.WAPP.SetLocation","com.WAPP.SetLocation.setLocationActivity"); should be i.setClassName(getBaseContext(),"setLocationActivity"); Reference
Also try this syntax:
startActivity(new Intent(MyActivity.this, setLocationActivity.class));
and try removing the starting dot from:
<activity android:name=".SetLocation.setLocationActivity"></activity>
Do it by this way:
Intent intent = new Intent();
intent.setComponent(
new ComponentName("com.WAPP", "com.WAPP.SetLocation.setLocationActivity"));
startActivity(i);
you should class ad to manifest.xml
for example of manifest.xml
in this example, i added SecondActivity.class
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.MyApplication">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SecondActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In Xamarin Android, make sure that your Activity class has an Activity attribute
[Activity(Theme = "#style/MyTheme")]
public class MyActivity : ActivityBase
{
...
}
With that you are making sure that your activity is registered in AndroidManifest.xml
I had the same kind of issue in the project . It wasted me almost a full day . i tried all the solutions that are mentioned above , but none of the solutions worked for me .
After all the hard work i just "Rebuild" the project and "clean" The project and it worked perfectly .
Note:
Before going through all the process u just needed to have a try to these options.
First of all, make sure that you have created activity and not the class. And, if it is activity then go to the manifest.xml file and look at the path of that particular file.
This worked for me absolutely well!!
https://forums.xamarin.com/discussion/104102/android-content-activitynotfoundexception-unable-to-find-explicit-activity-class
this is for reference
in your manifest you declared it as
.SetLoction.setLocationActivity
but
the package name is com.WAPP.SetLocation
so you need to prefix that again.
Intent i = new Intent();
i.setClassName("com.WAPP.SetLocation",
"com.WAPP.SetLocation.SetLocation.setLocationActivity");
startActivity(i);
This might be due to not registering your next activity XML file in the manifest. Register your next activity XML file in the AndroidManifest.xml file
<activity android:name=".NextActivity" />
Hope it helps.
Thia might be problem if ImageView is used :(
Intent intent = new Intent(context,ImageView.class);
intent.putExtra("imageurl",clients_document_return.getUrl());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
v.getContext().startActivity(intent);
and your class name might me Imageview.class
so first check all small capital in class name
Thanks :)
I have a problem with tabhost widget. I have some activities in tabs which are working fine. When I want to open a new activity from inside one of the tabs, runtime gives me the
Instrumentation.checkStartActivityResult(int, Object) line: 1504
ActivityNotFoundException
I put the activity in the manifest file and it's ok(I can run it if i put it in a tab). But when i try to fire the activity from another activity which is currently in one of the tabs, it get this exception. Any help is appreciated.
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".CoaActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainMenu"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".favorites"></activity>
<activity android:name=".FoodMenu"></activity>
<activity android:name=".Info"></activity>
<activity android:name=".Restaurants"></activity>
<activity android:name=".Home"></activity>
<activity android:name=".RestaurantInfo"></activity>
</application>
favorites, foodmenu, info, restaurants, home have their own tabs. But restaurant info doesnt have its own tab. And when i try to run restaurant info by an intent I have the exception.
I found a solution for my problem. You have to use a ActivityGroup object, that fires other Intent objects. There is a little bit tutorial here : http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity. Hope it helps..
I'm trying to use an explicit intent to display a MapView in my android app. Although I don't see anything wrong with my code, I keep getting a "NoClassDefFoundError" when I try to start my activity.
Basically, from my main activity (SetCriteria), I create the explicit intent when user presses a button :
Log.i(TAG, "Showing map..");
try{
Intent intentMap = new Intent(view.getContext(), AddLocation.class);
startActivity(intentMap);
}catch(Throwable ex) {
Log.e(TAG, "Error occured while trying to display map", ex);
}
My LogCat displays:
java.lang.NoClassDefFoundError: com.adm.AddLocation
...
Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
My Manifest looks like this:
<application android:label="#string/app_name" android:icon="#drawable/ic_launcher_red">
<uses-library android:name="com.google.android.maps"/>
<activity android:name=".SetCriteria"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddLocation"
android:label="#string/add_location">
</activity>
</application>
I have only one package: com.adm. So what could be wrong? I have no problem launching a map by using Intent(Intent.ACTION_VIEW, uri) but I want my specific activity dealing with the map.
You should remove the "." (dot) before your class name in the second activity declaration, so it would look like:
<activity android:name="AddLocation" android:label="#string/add_location">
From the manifest snippet it is not clear, what package you have defined.
You need to put it in the top-level manifest element:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adm"
>
<application android:icon="#drawable/icon" android:label="#string/app_name" ...
If you do not add that, the system will not use a package and your activity ".AddLocation" will end as "AddLocation" without a class, which is not the same as com.adm.AddLocation.
Just started working with android and ran into a small problem. I am have a TabActivity that is loading 3 other Activity classes. This works great. I then have a button on the other Activity classes that I would like to launch a MapActivity. When I do that I keep getting a Force Close.
I googled but I cannot figure out if it is the manifest file or something else. The idea is the tabs are showing location information and you click a button to plot it on the map and get directions.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_tab);
...
Button btnMap = (Button) findViewById(R.id.btnLaunchMap);
btnMap.setOnClickListener(mMapListener);
}
private OnClickListener mMapListener = new OnClickListener() {
public void onClick(View v) {
Intent mapIntent = new Intent(getApplicationContext(),LocationMap.class);
startActivity(mapIntent);
}
};
If I launch any other activity it works but not launching the mapactivity. If I take the mapactivity class and put it in a new project it works.
My manifest
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Locations"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name=".LocationNewYork"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".LocationChicago"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name=".LocationSeattle"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name=".LocationMap"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
thougths?
<action android:name="android.intent.action.MAIN" />
inside of the mapactivity's instance ACTIVITY field in the Manifest file does it.
So if you have a MapActivity named QMap, the following code in the Manifest actually works:
<activity android:name=".QMap"><action android:name="android.intent.action.MAIN" /></activity>
Hope it helped
I had the same problem, wanted to launch map activity from an other activity over onClick-event, the problem was: errors in the MapActivity
If you are using eclipse try to run "debug as" without setting any breakpoints