Default activity not found error when following Android Studio beginner guide - android

Im trying to add upward navigation while following the beginners tutorial to android studio here. However, when I try to run it, it gives me the error:
Error running 'app':
Default Activity not found
The code in my AndroidManifest.xml file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp">
<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=".DisplayMessageActivity"
android:parentActivityName=".MainActivity">
<!-- The meta-data tag is required if you support API level 15 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
</manifest>

There could be a number of things going on here. I would first suggest that you check all naming references to the layout and the code behind with a discerning eye. Sometimes with editing, you can inadvertently change and rename a file by adding or deleting letter in the name. Also, from time to time, when working with a IDE, a state of modification can go stale in which you can sometimes do a clean/build or a restart of the IDE. Pending updates to the IDE may be a culprit as well.
As a best practice, you should version your code. This will help alleviate most issues such as this. Check out the following link to Android's recommendations on this practice.
https://developer.android.com/studio/publish/versioning

Related

"Session 'app': Error launching activity" all of the sudden?

I am currently running into this issue without even knowing why.
It was working fine yesterday and I just added more code to each activity.
I have already perfomed "Invalidate Cache/Restart" and Restarted my computer.
Note that I did not change anything in the Manifest.xml nor have I added a new activity to the Project.
Here's the AndroidManifest.xml file.
<?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/AppTheme">
<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=".RegisterActivity" />
<activity android:name=".MainScreenActivity" />
<activity android:name=".StatisticsActivity" />
<activity android:name=".UnlockablesActivity"></activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
Any help would be greatly appreciated.
Edit: I have already tried to Rebuild and Clean multiple times. Same error.
The error is a little pop-up on the left corner saying "Error running app: Default Activity not found".
When setting the Default Activity in the settings to Nothing, this error appears in logcat when accessing a different activity.
It is not the full log but you can see that it references Line 25 in LoginActivity (the supposed Default Activity) which leads to its onCreate() function.
I've had exactly the same error a week ago, here's the link to my question. I couldn't find the origin of the error, it is probably a bug with Android Studio (I've had the same thing with all my projects).
I've resolved it by deleting the .AndroidStudio hidden directory in your user folder. Keep in mind, it deletes all the settings you've set before and it will reset Android Studio from scratch.

MainActivity NoClassDefFoundError

I seem to be having a similar problem to a myriad of the community; however, I don't seem to have the same symptoms (or at the very least, my Google-fu is not allowing me to find it).
Long story short: The app is giving me java.lang.RuntimeException: Unable to instantiate activity.
From what I understand this can only be caused by improper order of loading libraries or by missing the file in the AndroidManifest.xml.
Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.alexanderlyons.livingpokedex">
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Here is a link to my repository for those wanting to build it themselves. If anyone can give me insight as to what might be wrong.
Note: This may be due to my .gitignore, as the last time I built, it was on my main tower. I am only running into this issue on a remote machine.
TL:DR - My MainActivity is not loading, it exists in the AndriodManifest.xml, and I am only using gradles to load files, not local jars.
Your problem can be caused by different things, but the most common of it is you having too many libraries loaded, with too many methods.
You should enable multidex in your app, here's the guide:
multidex
A quick tutorial:
Add "multiDexEnabled true" to your gradle config (under target sdk version, for example).
Add this to your dependencies:
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
And make sure you application extends this:
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
Either via code or via manifest.
Edit:
Test the project with the build tools 22, sd version 22 and target 22. Also, use the support libraries 22.+

Error while fetching http://schemas.android.com/apk/res/android

Ok so I was going through a tutorial online, then when i tried to change my build.gradle file to compileSdkVersion 21 instead of 23 everything lost the plot and now all my previous projects etc are all showing errors.
In the AndroidManifest.xml the 2 http lines and all the android: are all red and the the activity opening tag has a red squiggly line under it also. I have zero idea what i have done wrong! Almost like internet has gone? Just a noob so i have no idea please help!
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/tools"
package="com.site.project" >
<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>
</application>
</manifest>
This answer extends #adelphus'.
A new app\build\intermediates\manifests\full\debug\AndroidManifest.xml would have listed these errors. Close and reopen the AndroidManifest.xml file from the project pane under app > manifests.
Hope this works for you.
You have duplicate schema definitions for the xmlns:android namespace in your manifest file - only one schema per namespace is allowed and I suspect the compiler is getting confused by the duplicate entry.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/tools"
package="com.site.project" >
should be:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.site.project" >
The namespace schema definitions are important - they are used to define attribute prefixes. Because your duplicate entry is invalidating the android namespace, all attributes prefixed with android: will be wrong - this is why all the android: attributes have an error (red line) displayed.
Alternatively, just remove the tools namespace completely if you're not using any attributes with the tools: prefix in your manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.site.project" >
you need download jdk here "https://www.oracle.com/technetwork/java/javase/downloads/index.html"
then go to File > Project Structure > here you config path jdk default C:\Program Files\Java\jdk-11.0.2 . Hope this works for you
I think you have two AndroidManifest.xml files to change it. Just rename the debug AndroidManifest.xml and that solution works for me.
Search for the AndroidManifest.xml file(s). on the project ParentPath. if there are multiple, keep one and delete the others.(usually find many other)

Android Studio Development - Even the default app won't work -

I have decided to try to learn some Android App Development however I am unable to follow even the most basic tutorial. My problem is that what ever I seem to do, the compiler complains about about the Manifest.
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
However, this happens when the project is completely unchanged from when Android Studio created it.
The Manifest is below which is also unchanged but is copied below any way.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Toby.projecttoolkit" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Home"
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>
Can somebody shed some light on why this might be happening? Any help in this area would be really appreciated.
Many thanks
Toby
I had a similar issue, and I resolved it by changing the package name to begin with a lowercas later i.e use toby.projecttoolkit instead of Toby.projecttoolkit.
Apart from that the Manifest file looks fine.
Refactor the package, clean, refresh and build the project. Make sure your project as no errors and try to run it.

Android "application not installed" error on tablet, not on phone

I have scoured the internet for this, but none of the "answers" I have found so far have fixed it for me. My app installs and runs 100% on my phone, which runs Android 4.1.2. It appears to install ok on my tablet too, which runs Android 4.3. But when I try to run it on the tablet, I get the "Application is not installed" error. What is even stranger is that if I run it using the App Manager inside ES File Explorer, it runs fine!
So my suspicion is that Android 4.3 is more strict about something that 4.1.2 lets through. But what? I just can't find it. And why it should run from within ES File Explorer is just weird. The app manifest is below. I have tried several different values for the target SDK, but nothing makes any difference. The app is signed using the Export Wizard in Eclipse, using a certificate created there.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="marshallarts.wordfinder"
android:versionCode="10"
android:versionName="1.10" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:permission="android.permission.WRITE_EXTERNAL_STORAGE"
android:theme="#style/AppTheme"
android:hasCode="true" >
<activity
android:name=".StartActivity"
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=".EnterActivity"
android:label="#string/title_activity_enter"
android:theme="#android:style/Theme.Dialog">
</activity>
<activity
android:name=".PlayActivity"
android:label="#string/title_activity_play" >
</activity>
</application>
</manifest>
Would add as a comment but don't have enough rep at the moment.
Have you changed your default launcher activity in your project recently? It could be that the link in your Android Home application is referencing the old activity.
Well I have solved this at last. It was (of course) my error - I had not correctly understood how to specify the app's permissions, and had not set them properly in the manifest. Corrected that, and it now runs happily. It is still a minor mystery why it ran on my phone - seems to me it should not have - but no matter, I am now on the right track.

Categories

Resources