I´ve recently imported a project I knew was working before into Eclipse. After I try to install the project it says
09-13 11:55:43.628: E/AndroidRuntime(7880): Caused by: java.lang.ClassNotFoundException: cz.ursimon.heureka.client.android.prj.heureka.activity.MainActivity in loader dalvik.system.PathClassLoader[/mnt/asec/cz.ursimon.heureka.client.android-1/pkg.apk]
but I can´t find out what the problem is. First I thought it is the common problem with new ADT update, but I tried checking the PrivateLibraries in Order and Export according to other solutions, I cleaned my project several times and I can´t see anything wrong in my AndroidManifest file.
Anyone with a solution? :S
My AndroidManifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cz.ursimon.heureka.client.android"
android:installLocation="preferExternal"
android:versionCode="26062"
android:versionName="3.0"
>
<activity
android:name=".prj.heureka.activity.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask">
Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using.
Clean all projects afterwards and Run your project
In your manifest file define the whole class path of your activity as below for your activity.
Also make sure your package defined is correct and in that pacakge your MainAcivity class resides.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cz.ursimon.heureka.client.android"
android:installLocation="preferExternal"
android:versionCode="26062"
android:versionName="3.0"
>
<activity
android:name="cz.ursimon.heureka.client.android.prj.heureka.activity.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask">
</manifest>
Related
I'm new to android app development with Android Studio and I came across this error when trying to run my app
Error: AndroidManifest.xml doesn't exist or has incorrect root tag
I found out that my AndroidManifest.xml file had some weird characters in it
Can someone please help me out here.. Thanks
Somehow your AndroidManifest get corrupted. AndroidManifest should contain root application details and other project settings like as follows. Please try again
by creating new project.
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Happy to hear that you start to develope app for Android.
And I suggest you can re-create a project, and the problem will disappear.
Have fun.
I hope this solution will help
this problem in your version of Android Studio
upgrade it to 3.3.RC3 and the problem will disappear
I read all the suggested answers below and mostly suggests that you create a new project because your manifest also looks very new.
It's very important to understand and memorise the body of the Android Manifest so in future you won't mess up again and can quickly debug your Manifest if some of the body went corrupted or accidentally deleted.
Creating a new project from scratch is time-consuming..
I had the same error lately and
I solved this by clicking Sync projects and gradle files.
I tried all stuff but this resolve my issue:
When i open my AndroidManifest.xml file i release that doesn't contain the the code i wrote on it.so i write click the file go to show in explorer where i found my old code so copy paste and the problem resolved!!
Guys If Nothing is working in your case like me then for protecting your hard work and your efforts You can do one thing very common but very helpful i.e.
Make a new Android Project
Go to android project Directory of your previous project.
In my case- C:\Users\knegi\AndroidStudioProjects\Projectapp
Than go to main Directory inside your Previous project.
In my case- C:\Users\knegi\AndroidStudioProjects\Projectapp\app\src\main
Copy all files from main Directory and paste them into main Directory of New Project.
Now all set open our new project and Run.
I wanted to give Kotlin a shot. I converted my java classes to Kotlin and corrected some errors. If I try to build, the following error comes up:
Error:Execution failed for task ':app:generateDebugInstantRunAppInfo'. Cannot find main merged manifest.
This is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mdrueke.kniffel">
<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=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
</activity>
<activity android:name=".Setup_Activity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Thanks for your help!
I’ve been experimenting with Kotlin development in the just-released Android Studio 3.0 Canary 1 and get the “Cannot find merged manifest” error every now and again. I’ve found that selecting Build -> Clean Project solves the problem for me.
Clean Project is worked for me in Android Studio 3.0 canary version
In my case, I'm using Android studio 3.0 Canary 2, first i try Build -> Clean Project still not solves the problem for me, then I close the project and open it again, Alhamdulillah it's solves the problem
I tried both cleaning the project and close-opening it, but they don't work in my case.
After editing the manifest (not a functional change) now project runs.
Because Build -> Clean Project, restarting Android Studio or reinstalling app may not work, the simplest solution was to change AndroidManifest.xml, e.g. add or delete white space.
Here is reported issue: https://issuetracker.google.com/issues/62336754.
As mentioned there, it will be fixed in Android Gradle Plugin 3.0.0-alpha5.
You can solve this problem by uninstalling the app you're currently working on and running it again on Android Studio.
Tried the given solutions but wasn't successful. So for the mean time until this bug gets fixed I am going for the commandline
./gradlew clean install<your_build_variant>
Example:
./gradlew clean installDevDebug
I am getting an error which reads The activity 'MainActivity' is not declared in AndroidManifest.xml
What is the problem here?
I got this error when moving a lot of files, to fix just resync your gradle files.
File->Sync Project with Gradle Files
Try to go to File->Invalidate Caches / Restart and choose invalidate and restart ,it worked for me
Sometimes when moving or renaming files, you can have broken XML files. My case that the ic_launcher.xml was corrupt. I regenerated that and worked just fine.
Check every XML in your proyect.
You are most likely just missing the below from your AndroidManifest:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
Here is a full example of an AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pejner.myapplication">
<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"
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>
</application>
</manifest>
this happened for me when my laptop suddenly shut down when working with project. if you see your activity declaration in your manifest, do not open any xml files. they maybe broken and corrupt after opening files.
so do these steps:
delete all .iml files from your project
go to Files => invalidate cache / Restart
Rebuild your project gradle
finally if problem still exists, go to Files => Sync project with gradle files
https://stacklearn.ir
This can be only two reason,
the bold one, missing extend statement
class MainActvity extends AppCompatActivity
or
you are using a wrong package name to register your activity so just in this case use ALT+Space then studio will show the options itself.
All of my XML file were cut in half for some reason, I'm not sure when it happened (I use Git VCS, so maybe that). I had to go through each of them and restore the code.
It have three ways to resolve
1:-
Go File->Invalidate Caches / choose invalidate and restart ,it works
2:-
If you make MainActivity make sure you have onCreate method in it and extend with AppCompatActivity .
3:- And last option sync project with Gradle file
Follow these steps:
File => Invalidate Caches / Restart...
Files => Sync project with gradle files
If the steps above don't work, write:
com.example.(project name).MainActivity
It should work, worked for me.
For those cases the you recently changed the android:allowBackup settings, make sure you also set the tools:replace="android:allowBackup" in case some of your dependency have it declared in them to override it. I wouldn't know this solution until I manually execute Gradle > app > cleanbuild > lintFix
The exact error I received was:
Error: Attribute application#allowBackup value=(false) from AndroidManifest.xml:41:9-36
is also present at [com.kaopiz:kprogresshud:1.2.0] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:39:5-254:19 to override.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.YOURPAKAGE">
<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.YOURPAKAGE">
<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>
</application>
</manifest>
NOTE:
Replace your AndroidManifest.xml file code with the above code and you just have to change the name of your package at those places where I have mentioned (YOURPAKAGE) hopefully the problem will be solved
replace in your AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.justjava">
<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>
</manifest>
You should try this
<activity
android:name="com.example.stockquote.StockInfoActivity"
android:label="#string/app_name"
/>
For more detail you can check hereActivity declare
Thanks everyone for taking the time out to help a beginner.
I found out that I had somehow misspelled the Package in MainActivity.java
When I corrected it the error was gone.
Thank you all.
I was getting an error "The activity 'MainActivity' is not declared in AndroidManifest.xml", even though it was correct in the manifest file.
My problem was that when I created the project I had to mark the item "Use AndroidX artifacts".
If you see that error occur after upgrading versions of IntelliJ IDEA or Android Studio, or after Generating a new APK, you may need to refresh the IDE's cache.
File -> Invalidate Caches / Restart...
I was working on my project suddenly my laptop restarts i tried lot of methods but i was not able to fix it.
But at the end i did it
do these steps and let me know it is working or not?
1. File > Invalidate Cache and restart the the android studio
2. Build > Clean Project and then Rebuild project
3. Sync project with gradle files
if it is still showing you error try these steps
1. Create new activity
Remember to clink on checkBox Launcher Activity
Hope this will Fix your problem
In the end go to AndroidManifest.xml and change New activity Default to previous activity
In my case, none of the answers helped. Luckily, I remembered that I added a variable in build.gradle, which I tried to access from MainActivity.
Problem was that this new variable wasn't present in AndroidManifest.xml. Once I added the variable to AndroidManifest.xml, the problem was solved.
This is an odd one. For me I had to open Edit Configurations (run configuration) and select <no module> under the Module drop-down. Then reselect my project under the Module drop-down and Apply. It the built and ran just fine.
Had the same problem with a project which I just downloaded the starter code for
an app , everything looked fine in the AndroidManifest.xml , I just deleted the com.example.android.(yourappname).MainActivity and wrote .dMainActivity and it worked.
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)
I created a new blank activity from Eclipse's 'New' menu.
I didn't get any errors, and the activity looks to have been correctly populated in the manifest, however, no java class file has been created.
I get the impression that within Eclipse, the class should have been auto-created and auto-populated with the onCreate and onOptionsItemSelected method templates.
Why didn't Eclipse automatically create the class for me?
Manifest code as requested:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstandroidapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myfirstandroidapp.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="com.example.myfirstandroidapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstandroidapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstandroidapp.MainActivity" />
</activity>
</application>
The fastest solution: keep the Activity in your manifest, but create the java class by right-clicking your package -> new -> class -> DisplayMessageActivity and then extend the Activity class and add the missing methods. Note that the class name have to match the one declared in the manifest
EDIT
After you've done it, clean the project by selecting project -> clean and check if there are any error messages left
I needed to uninstall Eclipse and install the sdk (adt bundle) from http://developer.android.com/ which comes bundled with eclipse to resolve this issue.
I found that my original set-up not only failed to create source files, but was also unable to create new android projects, even though it managed to create the first project successfully. Something must have happened to ruin the set up, no doubt, something I did but cannot trace.
What worked for me...
In eclipse, go to Help >
Install new software... > Work with: https://dl-ssl.google.com/android/eclipse/
Hit enter, checkmark "Developer Tools" and "NDK Plugins".
Let it download and install. I had to delete "myfirstapp" and remake it.
Restart Eclipse once it has downloaded and installed.
Having that issue and actually doing it over again helped me understand more about the syntax used in the lessons that I've already been through before.