I get this error:
06-06 10:45:19.685: E/AndroidRuntime(554): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.Android.myApp/com.Android.myApp.Facebook.Example}; have you declared this activity in your AndroidManifest.xml?
But i have declared it in my manifest file. what might be the other reasons for such exception?
My manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Android.myApp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light" >
<activity
android:name=".SignUpActivity"
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=".SignInActivity"
android:label="#string/app_name" />
<activity
android:name=".HomeActivity"
android:label="#string/app_name" />
<activity
android:name=".selectCityActivity"
android:label="#string/app_name" />
<activity
android:name=".FeedListViewActivity"
android:label="#string/app_name" />
<activity
android:name=".SearchActivity"
android:label="#string/app_name" />
<activity
android:name=".IWantActivity"
android:label="#string/app_name" />
<activity
android:name=".DateActivity"
android:label="#string/app_name" />
<activity
android:name=".ShareActivity"
android:label="#string/app_name" />
<activity
android:name=".ShareProductActivity"
android:label="#string/app_name" />
<activity
android:name=".SharePriceActivity"
android:label="#string/app_name" />
<activity
android:name=".ShareStoreActivity"
android:label="#string/app_name" />
<activity
android:name=".ProfileActivity"
android:label="#string/app_name" />
<activity
android:name=".ShowMapActivity"
android:label="#string/app_name" />
<activity
android:name=".ParticularEntryActivity"
android:label="#string/app_name" />
<activity
android:name=".MyLocationActivity"
android:label="#string/app_name" />
<activity
android:name=".MapMarkerActivity"
android:label="#string/app_name" />
<activity
android:name=".BarcodeActivity"
android:label="#string/app_name" />
<activity
android:name=".BarcodeResult"
android:label="#string/app_name" />
<activity
android:name=".FeedbackActivity"
android:label="#string/app_name" />
<activity
android:name=".SplashActivity"
android:label="#string/app_name" />
<activity
android:name=".Example"
android:label="#string/app_name" />
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
You declared package name in the manifest as com.Android.myApp and Activity Name .Example.So android will search it from com.Android.myApp.Example.
But your activity is residing in "com.Android.myApp/com.Android.myApp.Facebook.Example".So give the activity name as .Facebook.Example or full path as given below
In the manifest
<activity
android:name="com.Android.myApp.Facebook.Example">
</activity>
you can also use
<activity
android:name=".Facebook.Example"
android:label="#string/app_name" />
I got a variation to this problem. I was launching an activity called "Settings" and getting the same error and making all the suggested changes to the manifest were not fixing the problem.
Thing is, in the calling activity, I was also using / importing android.provider.Settings, so from what I can see when trying to launch the activity it was getting confused between the two. Thus I changed this in the code rather than the manifest to include the full path:
Intent launchScr = new Intent(this, com.foo.bar.Settings.class);
And it worked. Of course, the other, and better, way to solve this particular issue would be to use better names for my activities.
HTH anyone with this variant of the problem.
Sometimes,It's due to existence of the same class name (second parameter of the Intent) in different packages.
I found also that this occurs when you call startService instead of calling startActivity and vice versa.
From your exception which one is your class - Facebook or Example Because, you declared in package in manifest as com.Android.myApp But, for facebook activity you declared com.android.myApp.Facebook.Example And,
If example is your activity means, you should declared your activity as com.Android.myApp.Facebook.Example Because, its from different package or your Activity name as Facebook.Example So better you can declare your Activity like below -
<activity
android:name="com.Android.myApp.Facebook.Example"
android:label="#string/app_name" />
This can happen on large projects when the cached manifest gets out of sync. I was able to fix it in the Android Studio terminal with ./gradlew clean and then in the Android Studio menu bar selecting File > Invalidate Caches / Restart for good measure
Just make sure your Activity is decorated with this attribute:
[Activity(Label = "Your App Name", MainLauncher=true)]
Note: Only Set MainLauncher if needed.
This works if you have an Activity object (which you need to launch):
intent.setClassName(CallingActivity.this, activityToLaunch.getComponentName().getClassName());
You need to use this code if you wish to change your class dynamically from string:
Intent intent = new Intent().setClassName(this.getPackageName(), "com.some.other.name");
or you can put result from array or any other instead of "com.some.other.name". Cheers!
Related
After i have created my own appplication class:
package com.example.bezzabarovaa.myapplication;
import android.app.Application;
import android.content.Context;
/**
* Created by bezzabarovaa on 04.08.2017.
*/
public class app extends Application {
public static Context context;
#Override public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
}
and have changed manifest.xml (changed application to app class)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bezzabarovaa.myapplication">
<app
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/AppTheme">
<activity android:name=".MainActivity"
android:label = "#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</app>
I`ve got a message Error running Unnamed: Default Activity not found
If I will change my classapp back to application in manifest.xml - everything is ok.
Where is a problem?
Thank you.
This <app is supposed to be <application you specify your custom app in here:
<application android:name=".app" ...
Check the documentation the name section says:
The fully qualified name of an Application subclass implemented for
the application. When the application process is started, this class
is instantiated before any of the application's components. The
subclass is optional; most applications won't need one. In the absence
of a subclass, Android uses an instance of the base Application class.
Full example (with your code):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bezzabarovaa.myapplication">
<application
android:name=".app"
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/AppTheme">
<activity android:name=".MainActivity"
android:label = "#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
Solved by clicking the "Sync project with gradle files"
I faced the same problem a while ago, after changing my default activity to another.
What solved it was invalidate caches and restart Android Studio:
File -> Invalidate Caches / Restart...
and then clicking on Invalidate and Restart.
Use below code snippet
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bezzabarovaa.myapplication">
<application
android:name=".app"
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/AppTheme">
<activity android:name=".MainActivity"
android:label = "#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You can get Android Studio not to complain by going to the "Edit Configurations" menu (tap "Shift" three times, type "Edit Configurations"), then change Launch Options > Launch to "Nothing".
I'll probably add a generic activity containing instructions, just to avoid any confusion.
Add below line in your manifest application tag
<application
android:name=".app"
...
</application>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.bluetoothlegatt">
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light">
<activity
android:name="com.example.android.bluetoothlegatt.DeviceScanActivity"
android:icon="#drawable/app_icon"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.android.bluetoothlegatt.DeviceControlActivity" />
<service android:name="com.example.android.bluetoothlegatt.BluetoothLeService" />
</application>
</manifest>
I solved the very same issue by following steps
Close Android Studio
deleting from :
C:\Users\your user name.android/log and gradle folder
C:\Users\your user name.gradle
from C:\Users[your user name]
Restart Computer and run Android studio (it Will take some time to rebuild)
I want to make register_activity is first run if application open. But, still MainActivity run first. Can anybody help me to fix this.
This is my Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.client18.dd">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.DayNight.NoActionBar">
<activity android:name=".register_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".signup_activity">
</activity>
<activity android:name=".MainActivity">
</activity>
</application>
</manifest>
When I see your Manifest file I can not see any faults. I suggest to do followings.
1) Uninstall app in emulator / device if its exists, and then run application.
or
2) Rebuild project with cleaning ( Build > Clean Project )
P.S.
If you could practice signup_activity > SignupActivity it is nice and best practice.
I'm working on an Android app and have just added the Splash Screen as I will be loading from SQLite on start-up...
After telling the AndroidManifest that I'd like to have my Splash activity as my LAUNCHER, it seems that it's changed the name that my app is downloaded under.
The app is now called Splash, has anyone had this problem before?
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.codedaykcrunningapp.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.codedaykcrunningapp.Workout"
android:label="#string/title_activity_workout" >
</activity>
<receiver
android:name="com.example.codedaykcrunningapp.Widget"
android:label="#string/app_name" >
</receiver>
<activity
android:name="com.example.codedaykcrunningapp.Splash"
android:label="#string/title_activity_splash"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Android is using the label name of your launcher activity so change that to your app name
change
<activity
android:name="com.example.codedaykcrunningapp.Splash"
android:label="#string/title_activity_splash"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
....
to
<activity
android:name="com.example.codedaykcrunningapp.Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
....
this will fix your problem
After telling the AndroidManifest that I'd like to have my Splash
activity as my LAUNCHER, it seems that it's changed the name that my
app is downloaded under.
BCOZ
If you have a "launcher activity" with [label name] & "application tag" also with a different [label name] then Android will take the [label name] from the Launcher Activity.
For more information you can see this android documentation.
The app name is set in the file Android Manifest, please check the item application and attribute android:label.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
...
</application>
I want to add another project to my app. But it uses its own "application tag" in AndroidManifest file. And one of its class extends Application
So the problem is I use my own "application" preferences. How can I integrate this new project's "application" preferences to mine ? Will I change somethings on "class extends Application" ?
<activity android:name="com.my.other.project.package.name.MyClassName">
by this you could add your other project activity.
Only the <manifest> and <application> elements are required, they each must be present and can occur only once.
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.animal.MainActivity"
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="myOtherPackageName.MyClassName"/> // here where you put your other package name.
</application>
help me to resolve this getting this exception
java.lang.RuntimeException: Unable to instantiate application delhi.roshanara.margapp.MargApp: java.lang.ClassNotFoundException: delhi.roshanara.margapp.MargApp in loader dalvik.system.PathClassLoader[/data/app/delhi.roshanara.margapp-2.apk]
It is searching MargApp Activity to open the project but there is no activity of this name. And I want to start my activity as .LoginActivity. Manifest file structure is given below:-
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="MargApp" >
<activity
android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".OrderMenuPage" />
<activity
android:name=".PartyOutstanding" />
<activity
android:name=".PartyPDC" />
<activity
android:name=".TakeOrder"></activity>
<activity
android:name=".ShowOutstanding"
android:screenOrientation="landscape" />
<activity
android:name=".ShowPDC"
android:screenOrientation="landscape"></activity>
</application>
I would try removing
android:name="MargApp"
if that didn't work try Cleaning up your project
Project>Clean
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:
Replace your application tag with this one...
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >