I renamed my MainActivity class to DataActivity and added a new main activity class with IntelliJ IDEA. I changed the AndroidManifest.xml file to the following:
<application android:label="#string/app_name" android:icon="#drawable/icon">
<activity android:name=".DataActivity"
android:screenOrientation="portrait">
</activity>
<activity android:name=".MainActivity" android:screenOrientation="portrait"
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>
I uninstalled the app from my phone and deleted the compiler cache. At install, I get the following exception:
Launching application:
com.example.DataTest/com.example.DataTest.DataActivity.
DEVICE SHELL COMMAND: am start -n
"com.example.DataTest/com.example.DataTest.DataActivity"
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER java.lang.SecurityException: Permission Denial: starting Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10000000 cmp=com.example.DataTest/.DataActivity }
from null (pid=5882, uid=2000) requires null
What else should I do?
This post helped me where to look. In the comments, zeh claims that the SDK holds a refence to the original activity. I checked the launch configuration, and in my IDEA it has been altered from "Launch default activity" to "Launch activity: DataActivity".
It works now okay.
Change it to this to include the intent filters with your new main activity:
<activity android:name=".DataActivity"
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" android:screenOrientation="portrait"
android:label="#string/app_name">
</activity>
and remove "MainActivity" if it no longer exists. i.e. delete this:
<activity android:name=".MainActivity" android:screenOrientation="portrait"
android:label="#string/app_name">
</activity>
Related
I've been getting this error every now and then, and once I thought it was fixed, it just came back:
Error while executing: am start -n "com.example.wolfixfinal/com.example.wolfixfinal.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.wolfixfinal/.MainActivity }
Error type 3
Error: Activity class {com.example.wolfixfinal/com.example.wolfixfinal.MainActivity} does not exist.
Error while Launching activity
Failed to launch an application on all devices
I've made two or three other questions about this topic and it's getting annoying. I've tried removing the gradle and .gradle folder, removing the .idea folder and then rebuilding the project. I don't know what to do anymore.
How do I keep this from not happening, is it something I have to do all the time everytime I see this error.
Make sure than only ONE of your activities has the LAUNCHER and MAIN properties in your Manifest file. This file can be found under Android Project view: app > manifests > AndroidManifest.xml. The one you want to boot in is the one that should have these properties.
Like this:
<activity
android:name=".Splash"
android:exported="true">
<!--This will be the starting activity you want-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true"/>
NOT like this (2 activities in the manifest both have:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
):
<activity
android:name=".Splash"
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=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am new to Android Studio and I am trying to deploy an APK to my mobile device in order to test the app. I build the APK successfully but when I install the apk of the app in my device I couldn't see it or cannot be open. But I can see the apps in the app manager showing that I installed it.
here is the code in my manifest file.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Pasig NutriCare"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Looking for help.
Thanks in advance.
Did you checked Sort / Alphabetical / Custom ?
Also Check AndroidManifest.xml
Main Activity Should Contains :
Like :
<activity android:name=".SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
So change .SplashActivity to that you want And Remember to place dot . before it as i did
if you use sub Package Name place it , For Example :
your package is : com.example.myapplication
you create sub package as : activities
so in AndroidManifest.xml you have :
<activity android:name=".activities.SplashActivity"
...
</activity>
Make sure you specify the launcher activity for the app in your AndroidManifest.xml file:
<activity android:name=".YOURACTIVITY" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Did you specify the launcher activity for the app (in the AndroidManifest.xml)? If all else fails, you can also install the app manually using ADB (android debug bridge)
To install manually, Run this command from terminal/command prompt
adb install path_to_apk
I have finished my application in Android Studio but when I copy and paste app-debug.apk on my android phone it can't be opened after installation. Can anybody tell me what is wrong a what I need to do to make that app run. Btw when I was writting the code I was running it on my phone through USB cable without using AVD. Here is my AndrodiManifest:
<application
android:debuggable="true"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".SplashActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.category.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.category.MAINACTIVITY"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".InfoActivity"
android:label="#string/app_name">
</activity>
</application>
The problem is likely that your <intent-filter> elements are not correct.
Assuming SplashActivity is the first Activity the user should see when launching your app, your <intent-filter> should have an <action android:name="android.intent.action.MAIN"/> element. Note that your <action> element has the name android.intent.category.MAIN, which doesn't exist.
Your MainActivity's <intent-filter> also looks odd- android.intent.category.MAINACTIVITY doesn't exist, and you probably don't need to set the <category> (or an <intent-filter>) at all. See the documentation for CATEGORY_DEFAULT and determine whether you actually need it.
I've got a problem trying to do something in android studio and i'm not getting any progress.
When I try to call a the activity Menu from Main Activity Android studio give me this error message:
31490-31515/com.example.agr.companion E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-48434
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.agr.companion/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
at android.app.Activity.startActivityForResult(Activity.java:3390)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.app.Activity.startActivity(Activity.java:3561)
at android.app.Activity.startActivity(Activity.java:3529)
at com.example.agr.companion.MyActivity$1.run(MyActivity.java:26)
This is my manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation" >
</activity>
</application>
</manifest>
And this is how I try to start the new activity:
Intent intent = new Intent(getApplicationContext(), Menu.class);
finish();
startActivity(intent);
I'm very lost, I tried lots of things but I don't find anything helpful. I've made other projects in android studio that have the same code and it work. Recently I upgrade to android studio 0.8.0 and maybe something changes...
Thanks in advance for your help
Your problem is that you try to start the view.Menu class as an activity, probably due to a false import. Take a look at the exception. It states com.example.agr.companion/android.view.Menu.
If you don't use a menu view in your activity, I would remove the false import at the top and add the correct one (of your com.example.agr.companion.Menu activity).
Another option is to rename your Menu.java activity to MenuActivity.java in order to avoid confusion.
The third option is to use:
Intent intent = new Intent(getApplicationContext(), com.example.agr.companion.Menu.class);
Try
<activity
android:name="com.example.agr.companion.MyActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I've built an app that runs fine on the emulators, and says that it installs ok on the phone. However, on trying to run it an error pops up saying 'Application is not installed on your phone'. So I tried running the app through eclipse on the phone and I got this error in the console:
[2012-05-01 12:00:02 - MAD Assignment] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mad.assignment/.MainMenu }
[2012-05-01 12:00:02 - MAD Assignment] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.mad.assignment/.MainMenu } from null (pid=8204, uid=2000) requires null
From looking for the solution elsewhere it sounds as though it could be a problem in the manifest file, so here is mine:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mad.assignment"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
>
<activity
android:name="MainMenu"
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=".Diary"></activity>
<activity android:name=".Info"></activity>
<activity android:name=".MapMenu"></activity>
<activity android:name=".RSSMenu"></activity>
<activity android:name=".RSSFeedView"></activity>
<activity android:name=".MainMenu"></activity>
<activity android:name=".RSSDetailed"></activity>
<activity android:name=".DiarySchedule"></activity>
<activity android:name=".DiaryAddEntry"></activity>
<activity android:name=".DiaryEditEntry"></activity>
<activity android:name=".DiaryDetailed"></activity>
<activity android:name=".RSSDetailed"></activity>
<uses-library android:name="com.google.android.maps"/>
<activity android:name=".MapMain"></activity>
<activity android:name=".RSSFeedView"></activity>
<activity android:name=".MapWhatsNearPreferences"></activity>
<activity android:name=".RoutePath"></activity>
</application>
Any ideas what this security exception is pointing to? Thanks!
The java.lang.SecurityException you are seeing is because you may enter two entries pointing to same activity. Remove the second one and you should be good to go.
You may be declared the activity 2 times in the manifest with different properties, like :
<activity android:name=".MainMenu"> </activity>
and
<activity android:name=".MainMenu" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You should remove the unwanted one from the manifest
Set android:debuggable="true" under application.
You have an activity named
<activity android:name=".MainMenu"></activity>
Which is the Intent'ed activity from the launcher. But the activity to which you gave permission is "Mainmenu". Remove it. Add the permission and etc to the ".Mainmenu" which is blank now.
ie,
The 'activity' group should be
<activity
android:name=".MainMenu"
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=".Diary"></activity>
<activity android:name=".Info"></activity>
<activity android:name=".MapMenu"></activity>
<activity android:name=".RSSMenu"></activity>
<activity android:name=".DiarySchedule"></activity>
<activity android:name=".DiaryAddEntry"></activity>
<activity android:name=".DiaryEditEntry"></activity>
<activity android:name=".DiaryDetailed"></activity>
<activity android:name=".RSSDetailed"></activity>
<uses-library android:name="com.google.android.maps"/>
<activity android:name=".MapMain"></activity>
<activity android:name=".RSSFeedView"></activity>
<activity android:name=".MapWhatsNearPreferences"></activity>
<activity android:name=".RoutePath"></activity>
And remove the duplicates as well. Why did you add so many duplicate 'activities' ?