I'm using git, and creating lots of git branches for new features on a project I'm working on. Every once in a while, I'll create a new branch off master as usual (let's call this broken-branch, and this error appears:
Android Source Generator: [demo] AndroidManifest.xml file not found
I'll create a new branch off master, cherrypick the changes on broken-branch onto this one, and everything works fine. Why do I get this error, and how can I avoid it?
This happened to me today.. I clicked "Sync Project with Gradle Files" and all went fine.
While my IDE is IDEA13 with maven. Work fine with maven in command line, while using IDEA run( shift + F10) show this error. I do as below and fix this:
1.Open .iml in the project root.
2.Find some line like:
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="true" />
3.Remove this line or change value to false.
This is my work way.
May Help.
I use IntelliJ Idea and found next solution:
in the root of the project (in catalog with root build.gradle) create file settings.gradle which consist include ':app'
Than go to IDE and run Gradle - refresh.
I know the problem in IDEA because you create a new project with Java configuration (not android, but with android sdk dependency)
File > New Project > Java (Java Module) > Project SDK Android 4.X
Here is the solution :
File > New Project > Android (Application Module)
If you are using Maven, backup the project and close it. Open IntelliJ and select Open..., choose the pom.xml file and then select yes to open this project. Because there is already a project a popup should appear, choose 'Delete Existing Project and Import'.
Note: I'm using IntelliJ Community Edition version 13
When I get "AndroidManifest.xml file not found" error I clean and then refresh the project and these steps seem to fix the problem.
It happens to me when I don't have .iml file to open the project. It's very easy to fix, you just need to close the project and reopen it taking care of select build.gradle file before click open.
I hope it helps somebody.
This worked for me.
My project already had a settings.gradle file.
I simple had to add the line include ':app' . N ow i can build and do everything.
open IDE
project
|--->build automatically
uncheck it
clean the project
check build automatically opriot
I just had this problem while trying to build the swagger code gen project. For whatever reason IntelliJ thought I should have an Android facet. Removing this facet allowed the entire project to build.
If in case, you encounter an error which shows:
AndroidManifest.xml file is not found
All that you have to do is reinstall the flutter package and the error is resolved!!!
Go File,Project Structure or press Ctrl+Shift+Alt+S,
Go Facets, Select your android project, in the structure there are configuration files, folders. Image of structure tab (before)
Location of AndroidManifest file was like this:
D:\Programming\Dart Flutter Projects\tip_calculator\AndroidManifest.xml
Change the location like this.
Image of structure tab (after)
Changed it to here:
D:\Programming\Dart Flutter Projects\tip_calculator\android\app\src\profile\AndroidManifest.xml
flutter upgrade --force
Helped me.
Works for you?
I'm trying the new Android Studio. I've exported a project from eclipse, using the build gradle option. I've then imported it in Android Studio. The R.java file under gen has a j in a little red circle on it. And in my source files, I get "cannot resolve symbol R" wherever I have a reference to a resource, e.g. "R.layout.account_list" etc.
I have never used Intellij before. Would appreciate any help as there obviously aren't many answer yet about Android Studio. Thanks!
Press F4 into Project Structure, Check SDKs on left
Click Modules ---> Source Tab, check gen and src as sources
PS: The answer over a year old and the menus have changed.
File -> invalidate caches
then
Restart application
None of the answers on the web so far have helped. Build > Make Project did not work for me. For me it was as simple as choosing this other option (on Android Studio 1.3.1):
Build > Make Module 'module name'
In my case I had an Activity file imported from Eclipse that had the line:
import android.R;
So all of my R classes were resolving to the SDK, as soon as I commented out that line everything compiled correctly to my package. I only noticed the issue when I was moving the project from my Mac to my Windows machine.
This issue starting occurring for me when I started working with build.gradle to incorporate the data necessary (signingConfigs) to build a signed .apk. After what appeared to be a successful build from the command line, I discovered that going into any class using R.* that all R.* references were unresolved.
The answers here didn't help me. I decided to re-import the project and it magically fixed the issue. File/Import Project... and select the build.gradle file in my apps root folder. I would love to know why re-import fixed this :)
This is probably due to a failed resource build
Once the issue is fixed, a mere Build > Rebuild Project will do the trick
Goto File -> Settings -> Compiler now check use external build
then rebuild project
I've been frustrated on many occasions with this problem, especially when intergating a project library as part of another project. In the most recent occurrence of this plagued problem, my Android lib project was using a WebView. It turns out that Gradle builds the R.class file in a sub directory called "web" whose path does not have anything to do with my source code path. When I imported this, my problem was gone. What have I learned? In the future, simply do a file search for R.class and note the path where it is located. Then import the package into your code using that path. It really sucks that you have to manually perform this. Gradle should automatically import packages it generates.
I was also facing the same issue and I went through lot of answer on stackoverflow. Then i found one solution which help me resolve this issue.
Check package name in AndroidManifest.xml file. I forgot to change it while copy pasting another project into new project.
At first check if there is import android.R; in top of your class this happens when auto import in enable in android studio.
after that comment all lines of your code that you use R variable (you can comment entire class or ...)
then run application it regenerates R variable and you can uncomment your code.
Here's what worked for me in IntelliJ (Not Studio), in addition to the replies presented above:
You need to attach an Android facet to an existing Android module. To do this, select the module from the module list in 'Module Settings', hit the '+' button on top and select 'Android'. See https://www.jetbrains.com/idea/webhelp/enabling-android-support.html.
The solution is to open project structure window. [by press command+; on mac ox s. i don't what's the key shortcut for other platforms. you should be able to find it under "File" menu.]
and click "Modules" under "Project settings" section, then your project is revealed, finally mark the generated R.java as Sources.
I am using Intellij idea 14.0 CE.
The generated R.java is located at build/generated/source/r/debug/com/example/xxx
Really not easy to find for the first time.
Follow the five steps below:
Step 1 ===>Delete(CTRL X) the additional tag(s) in XML manifest file.
Step 2 ===>Open Build-->Clean project.
Step 3 ===>Open XML manifest file and past the last additional tag(s) like:
Tag Manifest file example:
(<uses-permission android:name="android.permission.VIBRATE"></uses-permission>)
Step 4 ===>Step 2 again.
Step 5 ===> Open Tool-->Android-->Sync project with 'Gradle'.
I have had the same problem but after all the steps it's work for me.
On IntelliJ 14
Check if the generated sources are excluded. Usually in Project Structure -> [module] -> Paths -> Compiler output: "Inherit compile output path"
My problem was that I had file 'default.jpg' in drawable folder and for some reason every resource was not resolved. Fixed after deleting that file!
You should check all your files if it don't have errors and again rebuild your project in:
Build > Rebuild Project.
Or in:
File > Settings > Build, Execution, Deployment > Compiler
Check use external build and after rebuild the project.
After you tried Clean and Rebuild without success, check your res folder for corrupted files.
In my case a corrupted .png file caused all the trouble.
Regarding the following, from Crossle Song's answer
Press F4 into Project Structure, Check SDKs on left
Click Modules ---> Source Tab, check gen and src as sources
Despite the message "We will provide a UI to configure project settings later....etc" this worked for me.
None of these answers helped me!
My problem was not a problem! The program could compile completely and run on the device but the IDE has given me an annoying syntax error. It has underlined the lines of codes that included "R.".
The way that I could solve this issue:
I just added these three classes in "myapp/gen/com.example.app/" folder:
BuildConfig
package com.example.app;
public final class BuildConfig {
public final static boolean DEBUG = true;
}
Manifest
package com.example.app;
public final class Manifest {
}
R
package com.example.app;
public final class R {
}
I solve that problem setting JAVA_HOME, CLASSPATH.
People sometimes skip JAVA_HOME and CLASSPATH when setting Java_path.
So try to check Environment Variable.
CLASSPATH -> .;
JAVA_HOME -> C:\Program Files\Java\jdk(version) or where Java installed
and then check the xml file which can have error(Do not naming well-known things such as button,text etc)
In my case (Linux, Android Studio 0.8.6 ) the following helps :
File > Project Structure > Modules > select main module > select its facet > Generated Sources
change value of "Directory for generated files:"
from
MY_PATH/.idea/gen
to
MY_PATH/gen
Without that code is compiled, apk is build and run successfully
but Android Studio editor highlights mypackage.R.anything as "cannot resolve" in all sub-packages classes
I had the same problem and got it fixed by deleting an extra library.
To do try this solution go to File > Project Structure (on a mac you can use the command "Apple ;")
Then select app on the left tab. Go to the dependencies tab and delete the extra library.
check the build tools version in build.gradle(for module app). Then go to android sdk manager see if the version is installed if not install it or change the build tools version to the one which is installed like below.
android {
buildToolsVersion "22.0.1"
..
..
..
}
The solution posted by https://stackoverflow.com/users/1373278/hoss
above worked for me. I am reproducing it here because I cannot yet comment on hoss' post:
Remove import android.R;
from your activity file in question.
My setup:
Android Studio 1.2.2
Exported project from one Mac to Git (everything was working). I then imported the project on another Mac from Git. Thats when it stopped resolving the resource files.
I tried everything on this thread:
invalidating cache and restart
Delete .iml files and .idea folder and reimport project
Clean and Rebuild project
Nothing worked except removing import android.R; from my activity java file.
To avoid this issue in the future add .idea folder to your .gitignore file. There is a nice plugin from git for gitignore in Android Studio. Install this plugin and right click in .idea > Add to .gitignore
just clean project and then sync your project with gradle file.
In my case, I found that "android.R.layout.account_list" was referenced instead of "R.layout.account_list". Simply remove "android." can fix the problem. Hope this help because sometimes you may overlook when you are too focusing.
In my case:
I had to Copy Reference the R file; i.e. right click gen/<package>/R and Copy Reference. Then paste that over the R in your code where it fails to resolve.
That solved it for me (after trying everything else here). Still not sure why it worked to be honest.
I had this same issue. The package name was wrong in two of the following three files. I manually updated the package name and everything started working again.
gen/com/example/app/BuildConfig.java
gen/com/example/app/Manifest.java
gen/com/example/app/R.java
I'm not sure what caused them to change as I've never modified these files before.
Had this error when importing project from Eclipse. The reason was some of the xml files had errors. Check ALL your XML files for errors. Including androidmanifest.xml, and values, themes, styles, layouts folders, etc. Warnings in xml are ok, but errors will generate this error.
Afterwards, do a Clean Project and rebuild.
For me, with Android Studio 1.5.1, the solution was to recreate the whole project with a slightly different name.
I think it didn't handle the app name "Kommentator_AS", because several places the package was named"Kommentator" instead.
I'm really annoyed by eclipse ! I'm trying to use external project as a library (Sliding menu from J. Feinstein). The import of the library in eclipse is ok, but when I open the properties of my project and add it as a library, It doesn't work.
Eclipse tell me that it's ok, but when I build the project, I have an error telling me that eclipse can't find library.apk.
If I check the properties again, there is a red cross id front of my library.
Here is a little screenshot from the the properties window in eclipse.
http://snag.gy/4jnKk.jpg
Try to remove this row, and using "Add" connect your library project to current project.
If you have .jar file, copy it to libs folder and use "Properties - > Java Build Path - > Add jars".
I solved the problem by myself... I was using Egit plugin as CVS and it mess up something !
Now I'm using a console to handle git, and I've no problems anymore.. Thanks anyway :)
I was trying to build my android application after adding an image, that i planned on using, to the drawables folder.
The project worked perfectly fine before, but after running the project, an error message showed up saying, Unparsed Aapt Error. The error shows up on the src folder.
I have tried to Clean my project but the R.java class just disapears.
Any suggestions on how to fix this problem????
1) clean project
2) close project
3) try again, if still fails: repeat 1 & 2 and then:
4) exit Eclipse and re-enter.
5) set the target in the run configuration to manual and try
There is a bug filed for this error - http://code.google.com/p/android/issues/detail?id=14607
Till its resolved we need to bear with the issue.
I found another "fix" for this issue in the Android Developer's Google Group that explains that sometimes the error has been resolved but eclipse is simply unaware of it.
Apparently in this case you can also simply delete the error by right clicking it.
Right click on your project > properties > android > in project build target : select android 5.0 with API level 21 or select the same android version with api level which is set in android-support-v7-appcompat project.
The api level and android version should be same in android-support-v7-appcompat as well as in your project.
Reason: Android SDK or Platform SDK are not consistent with Eclipse plugin.
Solution:
Open Android SDK Manager and update: Android SDK & Android Platform SDK
Open Eclipse and update plugin
I tried all these steps and nothing was fixing the appt error 138 that I was getting. As it happens, I was using TFS plugin at work and at some point the encoding of one of the xml file was changed from 0 on the server to ASCII on the local copy. I had to rollback to the last change set before the problem and then make sure to overwrite the offending file with the version from the server with encoding 0 to fix the problem.
In most cases changing the image file qualifier from PNG's to png's will fix the Android "Unparsed aapt error(s)"
Actually the problem arises when we paste the image in drawable folder. The image name must contain only [a-z0-9_.] letters. I mean file names anywhere in "res" must only contain lowercase letters, numbers, or underscores. The link https://teamtreehouse.com/forum/beginners-android-app-help explains it very well.