I haveSecurityException: Permission Denial error - android

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.

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".

Google Maps NoClassDefFoundError

I'm working on an android project in which one of the activities includes a Maps view. I'm only after doing the code for displaying a simple Google Map but I bumped into this NoClassDefFoundError. I have checked some similar questions and tried the suggested solutions but still won't work. I have activated the Internet permision in the manifest file and the user library for the application. Does anyone have any suggestions on what might be the problem? Here's the activity code:
package com.mad.mylit;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class LocationsActivity extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
And here's my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mad.mylit"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".MyLitActivity"
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=".MapsActivity"></activity>
<activity android:name=".MyProfileActivity"></activity>
<activity android:name=".BusActivity"></activity>
<activity android:name=".EventsActivity"></activity>
<activity android:name=".LocationsActivity"></activity>
<activity android:name=".NotesActivity"></activity>
<activity android:name=".TimetableActivity"></activity>
<activity android:name=".MondayActivity"></activity>
<activity android:name=".TuesdayActivity"></activity>
<activity android:name=".WednesdayActivity"></activity>
<activity android:name=".ThursdayActivity"></activity>
<activity android:name=".FridayActivity"></activity>
<activity android:name=".CaherdavinActivity"></activity>
<activity android:name=".RaheenActivity"></activity>
<activity android:name=".UniversityActivity"></activity>
<activity android:name=".SplashScreen"
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>
All of the activities are in the same package.
Try to get new maps API key with your personal keystore.
Have you recently updated your ADT plugin?
Here and here are some talks about same prblem..

ActivityNotFoundException but already declared in the Manifest

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.

changing launching activity

i want to change my launching activity.for the moment my manifest is this:
<application android:icon="#drawable/iconbj" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".Main" android:label="#string/app_name" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity" android:screenOrientation="landscape"></activity>
</application>
now I have created another activity which is a splash screen and i want to launch this instead of Main so I tried this way:
<application android:icon="#drawable/iconbj" android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".Splash" android:label="#string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Main" android:label="Main"
android:screenOrientation="landscape">
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity"
android:screenOrientation="landscape"></activity>
</application>
but i get thisproblem with permission:
[2011-03-31 16:32:44 - BlackJackNuovo]
ActivityManager:
java.lang.SecurityException:
Permission Denial: starting Intent {
act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
flg=0x10000000
cmp=com.phinet.android.blackjack/.Main
} from null (pid=-1, uid=-1) requires
null.
please help me :)
Update
NO WAY. I did this way:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.phinet.android.blackjack" android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:icon="#drawable/iconbj" android:label="#string/app_name"
android:debuggable="true">
<activity android:name="com.phinet.android.blackjack.Splash" android:label="Splash"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.phinet.android.blackjack.Main" android:label="Main"
android:screenOrientation="landscape">
</activity>
<activity android:label="com.phinet.android.blackjack.DemoPlayActivity" android:name="DemoPlayActivity"
android:screenOrientation="landscape"></activity>
</application>
</manifest>
but it seems to lunch always the Main activity,this is the concole log:
[2011-04-01 10:57:10 - BlackJackNuovo] Uploading BlackJackNuovo.apk onto device '9000d365e767'
[2011-04-01 10:57:16 - BlackJackNuovo] Installing BlackJackNuovo.apk...
[2011-04-01 10:57:32 - BlackJackNuovo] Success!
[2011-04-01 10:57:32 - BlackJackNuovo] Starting activity com.phinet.android.blackjack.Main on device 9000d365e767
[2011-04-01 10:57:32 - BlackJackNuovo] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.phinet.android.blackjack/.Main }
[2011-04-01 10:57:35 - BlackJackNuovo] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.phinet.android.blackjack/.Main } from null (pid=-1, uid=-1) requires null
WHY?
<activity android:name="Main" android:label="Main"
android:screenOrientation="landscape">
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity"
android:screenOrientation="landscape"></activity>
Should still have the leading .
<activity android:name=".Main" android:label="Main" android:screenOrientation="landscape">
</activity>
<activity android:label=".DemoPlayActivity" android:name="DemoPlayActivity"android:screenOrientation="landscape">
</activity>
This is stating it has a relative path to your Classes. You could make absolute references if you wished, i.e. "com.your.app.Main"

Categories

Resources