ActivityNotFoundException but already declared in the Manifest - android

HY!
I always get the ActivityNotFound Error, but i already have my Activity declared in the Manifest.
Whats wrong?
Error:
10-17 20:28:24.881: ERROR/AndroidRuntime(2141): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}; have you declared this activity in your AndroidManifest.xml?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.supplierplan"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name = "android.permission.INTERNET"> </uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".view.Login"
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=".view.LVEntries"></activity>
</application>
</manifest>
Calling:
Intent i = new Intent (Login.this,LVEntries.class);
i.putExtra("JSON", array.toString());
startActivity(i);

The problem is in how you are naming the Activities in you Manifest file.
I'm guessing your class files are named Login.java not view.Login.java, am I right? If so change this:
<activity android:name=".view.Login" android:label="#string/app_name">
To This
<activity android:name="Login" android:label="#string/app_name">
Do the same for LVEntries
If they are named like view.Login.java then remove the prepended view. in the name.

Related

android sdk product flavors - activity not found when I start a new activity using intent

I have a working app to which I have added 2 product flavors. This app has a menu on the first screen which allows the user to choose the next activity, which I load with an intent.
Here is AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.alpha.aloedu.MainActivity"
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="com.alpha.aloedu.guideddrawing.GuidedLetterDrawingActivity"
android:label="Guided Letter Drawing"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.buildvocabulary.BuildVocabularyActivity"
android:label="Image Plus Word"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.findthepicture.FindThePictureActivity"
android:label="Find the Picture"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.findtheletter.FindTheLetterActivity"
android:label="Find the Letter"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.fillintheletter.FillInTheLetterActivity"
android:label="Find the Letter"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.EndActivity"
android:label="End Activity"
android:screenOrientation="portrait" />
<activity
android:name="com.alpha.aloedu.AdminActivity"
android:label="Admin Activity"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
/>
</application>
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:requiresSmallestWidthDp="480"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
Here is the relevant portion of the gradle file:
productFlavors {
de {
applicationIdSuffix ".de"
versionName "1.1de"
}
fr {
applicationIdSuffix ".fr"
versionName "1.1fr"
}
}
Here is the source tree:
Here is the code where I load the next activity:
Intent intent = new Intent();
intent.setClassName("com.alpha.aloedu", newClassName);
currentActivity.startActivity(intent);
currentActivity.finish();
I have set a breakpoint on the second line and "newClassName" has the correct value. However, when I run the "deDebug" variant, I get an error on the third line:
android.content.ActivityNotFoundException:
Unable to find explicit activity class
{com.alpha.aloedu/com.alpha.aloedu.guideddrawing.GuidedLetterDrawingActivity};
have you declared this activity in your AndroidManifest.xml?
The class GuidedLetterDrawingActivity does exist in the main source tree, and also in AndroidManifest.xml.
Thank you for any help you can provide.
You must declare activities of each flavor in its manifest file
...\src\ de \AndroidManifest.xml
...\src\ fr \AndroidManifest.xml
Declare each new activity in manifest. Even if you change the name you have to modify the manifest file.
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".new_Activity"
android:label="#string/app_name"/>
<activity
android:name=".new_Activity2"
android:label="#string/app_name"/>
</application>
This has to be declared in main java file
Intent intent = new Intent(MainActivity.this, newActivity.class);
startActivity(intent);
Intent intent1 = new Intent(MainActivity.this, newActivity2.class);
startActivity(intent1);
execute the intent block of code as per your requirement in the same or different functions.

Cause of Error Message "Error:(27) Tag <manifest> attribute package has invalid type 4."

When trying to build my app, I get the following error message: "Error:(27) Tag <manifest> attribute package has invalid type 4." Any ideas on what is causing this? Here is a copy of my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dummy.tanc">
<application
android:supportsRtl="true"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity
android:name="com.google.example.games.tanc.MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think it is because, in your manifest, you've set your package name (line 2) to be
package="com.dummy.tanc"
and in when defining the activity (line 18), you've used
android:name="com.google.example.games.tanc.MainActivity"
Because of this mismatch, the issue could be arising. Change the line 18 to
android:name="com.dummy.tanc.MainActivity"
It means attribute package has type float but not string.
I guess your package name contains only numbers, something like package="1.0".

I haveSecurityException: Permission Denial error

I am getting the following error:
ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.optionpricing/.optionListNew } from null (pid=1160, uid=2000) requires null
I am new to programming in Android and I could not make sense of the other postings related to my problem. I wonder if there is an issue with the optionListNew class? Can someone lend a hand so I can move on to completing my app. Also, the app runs in my virtual device, and I only get this error when I try to test it on my actual phone.
Any ideas are appreciated. Below is the manifest file.
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.optionpricing" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".optionListNew">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OptionPricing"/>
<activity android:name=".optionListNew"/>
<activity android:name=".futureOptionActivity"/>
<activity android:name=".currencyOptionActivity"/>
<activity android:name=".gapOptionActivity"/>
<activity android:name=".gapOptionList01"/>
<activity android:name=".barrierSingleUpInActivity"/>
<activity android:name=".testActivity"/>
<activity android:name=".barrierlistview"/>
<activity android:name=".barrierSingleDownInActivity"/>
</application>
</manifest>
You added "optionListNew" activity twice in the manifest file.. remove below activity by deleting this line
<activity android:name=".optionListNew"/>
Your Manifest.xml code will become
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.optionpricing" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".optionListNew">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OptionPricing"/>
<activity android:name=".futureOptionActivity"/>
<activity android:name=".currencyOptionActivity"/>
<activity android:name=".gapOptionActivity"/>
<activity android:name=".gapOptionList01"/>
<activity android:name=".barrierSingleUpInActivity"/>
<activity android:name=".testActivity"/>
<activity android:name=".barrierlistview"/>
<activity android:name=".barrierSingleDownInActivity"/>
</application>
</manifest>
optionListNew is present twice in the manifest. Remove the second.

SecurityException at starting intent of a new empty Activity

I have developed a little project using just one Activity, and now, I'm trying to add a new one, but, I recieve this error when I'm trying to launch the project on my device:
Running com.android.gl2jni/.TestActivity... 1> Starting: Intent {
cmp=com.android.gl2jni/.TestActivity } 1> 1>
java.lang.SecurityException: Permission Denial: starting Intent {
flg=0x10000000 cmp=com.android.gl2jni/.TestActivity } from null
(pid=2935, uid=2000) requires null
I'm not trying to call the new Activity, and I have developed an empty Activity to check why I can't launch the app.
This is my Manisfest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.gl2jni">
<uses-feature android:glEsVersion="0x00020000"/>
<uses-sdk android:minSdkVersion="9"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:label="#string/gl2jni_activity">
<!--main activity-->
<activity android:name=".GL2JNIActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--BT device list activity-->
<activity android:name=".TestActivity"
>
<intent-filter>
</intent-filter>
</activity>
<!--
<activity android:name=".BluetoothDeviceListActivity"
android:label="#string/select_device"
android:theme="#android:style/Theme.Dialog"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
/>
-->
</application>
</manifest>
And this is the empty activity class:
package com.android.gl2jni;
import android.app.Activity;
import android.util.Log;
import android.os.Bundle;
public class TestActivity extends Activity {
#Override protected void onCreate(Bundle icicle) {
LogConsole.print( "HI, I AM TestActivity" );
}
}
I suppose that I have to modify something else more, but I don't know what...
Thanks in advance for the help.
You've specified an empty intent filter for TestActivity. An empty intent filter matches NO intents. Remove these lines from the block for TestActivity:
<intent-filter>
</intent-filter>
Also, in onCreate() of TestActivity you must call super.onCreate(), otherwise Android will crash it.

Getting SecurityException when trying to install appWidget in HomeScreen

am having a little trouble here. i don't know why i am getting a SecurityException, when trying to install my AppWidget on the home screen?. i don't know what will help to solve this but here is the simplified logcat output and my Android Manifest for starters:
11-30 18:02:16.454: ERROR/AndroidRuntime(287): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.appwidget.action.APPWIDGET_CONFIGURE cmp=com.MuchachaApps.WeatherViewer/.WeatherForecastConfigure (has extras) } from ProcessRecord{44e58dc8 287:android.process.acore/10001} (pid=287, uid=10001) requires null
11-30 18:02:16.454: ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1218)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1206)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1214)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.startActivityForResult(Activity.java:2749)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.startActivityForResult(Launcher.java:969)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.addAppWidget(Launcher.java:1148)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.onActivityResult(Launcher.java:379)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.dispatchActivityResult(Activity.java:3828)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityThread.deliverResults(ActivityThread.java:3325)
11-30 18:02:16.454: ERROR/AndroidRuntime(287):... 11 more
My Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MuchaaApps.WeatherViewer"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<service android:name= "weatherForecast"></service>
<activity android:name=".WeatherForecastConfigure" android:label="#string/app_name"></activity>
<receiver android:name="WeatherWidgetProvider" android:label="Weather Forecast">
<intent-filter>
<action android:name= "android.appwidget.action.APPWIDGET_UPDATE"></action>
</intent-filter>
<intent-filter>
<action android:name="com.MuchaaApps.WeatherViewer.WEATHER_UPDATE"></action>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/weather_appwidget_info"></meta-data>
</receiver>
</application>
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
if you need any other information, please let me know. Thank you
Do you have a configuration Activity that's supposed to come up when you add the widget to the launcher? If so, you need to add an APPWIDGET_CONFIGURE action to your intent-filter. If not, you need to remove the android:configure attribute from your appwidget-provider XML.
Having one but not the other is the problem.

Categories

Resources