Error have you declared this activity in your AndroidManifest.xml? - java

Pleas Can anyone explain whats the problem in this?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.crud.datapegawai, PID: 4989
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.crud.datapegawai/com.crud.datapegawai.AddEdit}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2065)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1727)
at android.app.Activity.startActivityForResult(Activity.java:5320)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
at android.app.Activity.startActivityForResult(Activity.java:5278)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
at android.app.Activity.startActivity(Activity.java:5664)
at android.app.Activity.startActivity(Activity.java:5617)
at com.crud.datapegawai.MainActivity$1.onClick(MainActivity.java:46)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
<?xml version="1.0" encoding="utf-8"?>
<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.DataPegawai">
-->
<activity android:name=".list_row" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.DataPegawai.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

From the log :
{com.crud.datapegawai/com.crud.datapegawai.AddEdit}; have you declared this activity in your AndroidManifest.xml
It means that there is an activity that you are using, but it was not declared in the android manifest. Every time you create an activity, you also need to declare this activity in the android manifest file. As you can see in your android manifest:
<activity android:name=".list_row" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.DataPegawai.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
There is a <activity> declaration. So in order to fix your problem, you need to declare com.crud.datapegawai.AddEdit in your manifest file. Something like this:
<activity android:name=".list_row" />
<activity android:name="com.crud.datapegawai.AddEdit" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.DataPegawai.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
For more details -> https://developer.android.com/guide/topics/manifest/manifest-intro

Related

Activity cannot be cast to android.app.Application

When I start the application, it force close.
This is the LogCat:
java.lang.RuntimeException: Unable to instantiate application com.blocktrekacademy.officialblocktrek.Authentication: java.lang.ClassCastException: com.blocktrekacademy.officialblocktrek.Authentication cannot be cast to android.app.Application
[UPDATED] : This is my AndroidManifest.xml:
...
<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/AppTheme">
<activity
android:name=".Authentication"
android:label="#string/title_activity_authentication"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is my Authentication.java
package com.blocktrekacademy.officialblocktrek;
import ...
public class Authentication extends AppCompatActivity {
...
First, remove android:name=".Authentication" property in <application> tag.
Your Authentication class is an Activity, not an Application. So, you have to declare it as such:
<application>
...
<activity android:name=".Authentication"
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
That intent-filter declares the Activity as the "main" activity, so it will be launched when your app starts.

ClassNotFoundException: Didn't find class "com.yandex.metrica.MetricaEventHandler". Unity plugin

App crashing on testers devices, but not on mine. I trying install appmetrica plugin, but it isn't work, stats of appmetrica console is null and this error, placing above.
I can't find the solution of this error. Can you please give the permanent solution. I have no idea how to solve it can you help me. Thanks sorry of my english.
1 - java.lang.ClassNotFoundException
in: dalvik.system.BaseDexClassLoader.findClass
Tjava.lang.Error: FATAL EXCEPTION [main]Unity version : 4.7.2f1
Device model: samsung SM-T116Device fingerprint: samsung/goyave3gxx/goyave3g:4.4.4/KTU84P/T116XXU0AQA2:user/release-keysCaused
by: java.lang.RuntimeException: Unable to instantiate receiver com.yandex.metrica.MetricaEventHandler:
java.lang.ClassNotFoundException: Didn't find class "com.yandex.metrica.MetricaEventHandler"
on path: DexPathList[[zip file "/data/app/coloring.book.app-1.apk"],
nativeLibraryDirectories=[/data/app-lib/coloring.book.app-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2648)
at android.app.ActivityThread.access$1700(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5584)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)Caused by: java.lang.ClassNotFoundException:
Didn't find class "com.yandex.metrica.MetricaEventHandler"
on path: DexPathList[[zip file "/data/app/coloring.book.app-1.apk"],
nativeLibraryDirectories=[/data/app-lib/coloring.book.app-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2643) ... 10 more
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="coloring.book.app" android:installLocation="preferExternal" android:theme="#android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="true" android:hardwareAccelerated="true">
<activity android:name="com.neatplug.u3d.plugins.common.NPUnityPlayerActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:launchMode="singleTask" android:screenOrientation="sensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
<activity android:configChanges="keyboardHidden|orientation" android:label="#string/app_name" android:name="com.unity3d.player.UnityPlayerActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.VideoPlayer" android:label="#string/app_name" android:configChanges="keyboard|keyboardHidden|orientation" />
<activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen">
</activity>
<activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen">
</activity>
<activity android:name="com.facebook.LoginActivity" android:configChanges="keyboardHidden|orientation" android:theme="#android:style/Theme.Translucent.NoTitleBar">
</activity>
<activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true">
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ 844957685613468" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<activity android:name="com.neatplug.u3d.plugins.facebook.FriendPickerActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:label="#string/app_name" />
<activity android:name="com.neatplug.u3d.plugins.facebook.LeaderboardActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:label="#string/app_name" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.yandex.mobile.metricapush.pluginunity"/>
</intent-filter>
</receiver>
<receiver
android:name="com.yandex.metrica.push.core.notification.MetricaPushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.yandex.metrica.push.action.NOTIFICATION_ACTION"/>
</intent-filter>
</receiver>
<service
android:name="com.yandex.metrica.push.gcm.MetricaInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="com.yandex.metrica.push.PushService"
android:exported="false">
</service>
<meta-data android:name="ymp_gcm_project_number" android:value="number:gcm_number"/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<!-- AppMetrica Services and Receivers -->
<service android:enabled="true" android:exported="true" android:name="com.yandex.metrica.MetricaService" android:process=":Metrica">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.yandex.metrica.IMetricaService"/>
<data android:scheme="metrica"/>
</intent-filter>
<meta-data android:name="metrica:api:level" android:value="52"/>
</service>
<receiver android:enabled="true" android:exported="true" android:name="com.yandex.metrica.MetricaEventHandler">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
</application>
</manifest>
Could you please give more information about the devices on which that crash occurs (model, OS version)? It seems like a problem could be related with obfuscation or multi-dex.

RuntimeExceptionjava.lang.RuntimeException: Unable to instantiate activity ComponentInfo

I have declared LoginActivty in menifest.xml . The following is the menifest.xml of my android project .
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sdc.android.milestone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
<activity
android:name="LoginActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MainActivity"/>
</application>
</manifest>
My Activity is stored like this :
But I am getting this exception :
03-07 13:18:29.118: E/ActivityThread(30283): RuntimeExceptionjava.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sdc.android.milestone/com.sdc.android.milestone.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "com.sdc.android.milestone.LoginActivity" on path: DexPathList[[zip file "/mnt/asec/com.sdc.android.milestone-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/com.sdc.android.milestone-1/lib, /vendor/lib, /system/lib]]
Build Path :
Why am I getting this exception ? Please help me .
You can't set two main activity as below:
<action android:name="android.intent.action.MAIN" />
this is wrong..
your Mainfist.xml should be like:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="LoginActivity"/>
please follow this.
https://developers.google.com/identity/sign-in/android/sign-in
you made mistake adding google sign in button

Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed with multiple errors, see logs

My code was compiling before but stopped working and is giving this error
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
log
java.lang.RuntimeException: Activity name cannot be empty. at
com.android.tools.idea.model.MergedManifest$ActivityAttributes.(MergedManifest.java:579)
at
com.android.tools.idea.model.MergedManifest.syncWithReadPermission(MergedManifest.java:418)
at
com.android.tools.idea.model.MergedManifest.access$000(MergedManifest.java:55)
at
com.android.tools.idea.model.MergedManifest$1.run(MergedManifest.java:331)
at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:945)
at
com.android.tools.idea.model.MergedManifest.sync(MergedManifest.java:328)
at
com.android.tools.idea.model.MergedManifest.getActivities(MergedManifest.java:464)
at
com.android.tools.idea.run.activity.DefaultActivityLocator.lambda$computeDefaultActivity$97(DefaultActivityLocator.java:78)
at
com.intellij.openapi.project.DumbService$1.run(DumbService.java:89)
my manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:header=".MyApplication"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:header=".ui.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:header="android.intent.action.MAIN" />
<category android:header="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:header=".ui.ResponseActivity"
android:label="#string/title_item_detail"
android:parentActivityName=".ui.MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<meta-data
android:header="android.support.PARENT_ACTIVITY"
android:value=".ui.MainActivity" />
</activity>
</application>
what could be the cause of this?
Use this for your main activity because name field is required to identify an activity not the header so replace every header with name field
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
instead of this
<intent-filter>
<action android:header="android.intent.action.MAIN" />
<category android:header="android.intent.category.LAUNCHER" />
</intent-filter>
So it will
<activity
android:name=".ui.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and do the same for other activities too
You have to write android:name=".ui.activityName" in your activity tag of manifest file for each of the activity.
Hope this helps!

Crashing App Fatal exception main [duplicate]

This question already has answers here:
...have you declared this activity in your AndroidManifest.xml
(3 answers)
Closed 7 years ago.
Hi I have tried to add a class to my tabbed fragment and it is throwing an error, I thought at first that I was being stupid because I had not added the activity to the manifest but after I did it didn't work. How do you add an activity top the manifest and is the below error throwing this exception
ON: main
Process: com.androidbelieve.drawerwithswipetabs, PID: 14861
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidbelieve.drawerwithswipetabs/com.androidbelieve.drawerwithswipetabs.BradClass}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1793)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1515)
at android.app.Activity.startActivityForResult(Activity.java:4026)
at android.app.Activity.startActivityForResult(Activity.java:3973)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:829)
at android.support.v4.app.Fragment.startActivity(Fragment.java:897)
at com.androidbelieve.drawerwithswipetabs.LeagueOne$1.onItemClick(LeagueOne.java:41)
at android.widget.AdapterView.performItemClick(AdapterView.java:339)
at android.widget.AbsListView.performItemClick(AbsListView.java:1544)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3721)
at android.widget.AbsListView$3.run(AbsListView.java:5660)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
This is how I wrote my activity
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<activity
android:name=".LeagueOne"
android:label="leagues"></activity>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues"></activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Change your manifest to:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"/>
<activity
android:name=".LeagueOne"
android:label="leagues"/>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Your manifest.xml has some wrong.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name">
</activity>
<activity
android:name=".LeagueOne"
android:label="leagues"></activity>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
If you want to use MainActivity as luncher,you can move intent-filter to MainActivity block.
Change your manifest to the given below, you put activity under activity thats the main problem all activity should be declared separate.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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>
<activity
android:name=".LeagueOne"
android:label="leagues"></activity>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues"></activity>
</application>
Add Activity in Manifest this way:
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories