Can't find androidmanifest.xml - android

I am working on a Visual Studio Cordova project which works on Windows, iOS and Android, and looking for AndroidManifest.xml or a build settings file and couldn't find any. I tried building it with no errors, but still couldn't find the file. Any suggestions, where/what I should be looking for?

It should be in your project root inside platforms/android.

Cordova generates a AndroidManifest.xml in platforms/android, but it's going to be reseted with each rebuild. If you need to add some data to it, you will have to create your own AndroidManifest.xml in res/native/android that will be automatically merged to the one in platforms/android.
You can read (a bit) more in the official documentation: https://msdn.microsoft.com/en-us/library/Dn757053.aspx

Related

Unity3D Command line Build not accessing libraries and updating Android Manifest

I have a unity project with multiple android plugins.
The plugins are placed in the recommended folders /Assets/Plugins/Android/NameOfPlugin and each have their own AndroidManifest.xml and .project file.
I also have an AndroidManifest.xml in /Assets/Plugins/Android
When building out a .apk from any of the dev machines in studio, the AndroidManifest is correctly compiled into a single .xml file containing all required activities.
However, when building on a Mac Mini via commandline this does not happen. The AndroidManifest.xml is missing required code and the app doesn't work.
I have done fresh installs of everything, tried different configurations, loads of things but to no avail. Anyone have any ideas as to what might be going wrong?
One of Dan's colleagues here, and after doing a straight up text diff on the two "Editor.log" files of Unity's editor, there was one glaring line that was missing from the broken builder,
DisplayProgressbar: Android Library Support
Googling that lead me to http://answers.unity3d.com/questions/792979/android-library-support-build-issue.html who had already discovered the answer, which was damn near exactly the same as what we had suffered,
It appears having a "." in the name of a directory on the build path results in failure of the android-libraries to be correctly found and added to the StagingArea.
Moving our repository on the Autobuilder from ~/.jenkins/workspace/game_project to ~/game_project fixed the issue.
We've just done the same ourselves, and it's solved the issue.

Environment variable in settings.gradle not working with Android Studio

I do have a multi-module project with a library project in a different root path. As illustration you can imagine something like this:
/projects_home/projects/app_root
|--app/
| |--build.gradle
|--build.gradle
|--settings.gradle
/libraries_home/libraries
|--libA
|--build.gradle
In my settings.gradle file I am able to set the absolute path to the library project utilizing the projectDir attribute. This works just fine within the console as well as with Android Studio.
But if I try to use an environment variable it stops working with Android Studio. The settings.gradle for the example above would look like this:
include ':app'
include ':libA'
project(':libA').projectDir = new File("$System.env.LIB_ROOT", '/libraries/libA')
If I build with the graddle wrapper from the console, it still works. But AS stops working with the following error msg:
Gradle 'app' project refresh failed:
Configuration with name 'default' not found.
If I unset the environment variable, the build on console fails with the same msg:
* What went wrong:
A problem occurred configuring project ':app'.
> Configuration with name 'default' not found.
Therefore I guess that AS is somehow not be able to access the environment variables set with my ~/.bashrc
Does somebody of you maybe know a way how I can make AS aware of my environment?
Android Studio does read the environment variables. You can prove it by launching Android Studio from the shell in which those env. variables being specified instead of from X-window dash board.
The reason you did not have those variables is the X-window environment you were using did not read $HOME/.bashrc which contained those variables. This makes sense because bashrc is for Bash not X.
Assuming you are using GNOME or Unity, to launch Android Studio with those environment variables being specified, just modify the .desktop file of Android Studio (e.g. ~/.local/share/applications/android-studio.desktop):
Find this line:
Exec="/home/username/tools/android/android-studio/bin/studio.sh" %f
Change it to:
Exec=env LIB_ROOT=/libraries_home "/home/username/tools/android/android-studio/bin/studio.sh" %f
Note:
This modification just prepend env LIB_ROOT=/libraries_home to the original command. You must replace username with your own user name.
Update
If you have any questions, please leave a comment instead of editing the answer directly.
On Macs, Android Studio does not read environment variables for use in Gradle apparently. I believe this is the cause for confusion in the answers here - maybe it does on Windows.
In order to get Android Studio to read environment variables, I run the application from the command line:
> /Applications/Android\ Studio.app/Contents/MacOS/studio
The other answers here offer solutions other than using environment variables. For my situation, I'm using a library I didn't write that requires the use of an environment variable, and I'd rather not edit their code so it's easier to update later.
EDIT: And, I have a dock icon to launch Android Studio this way:
OSX: Add Dock icon for dedicated Terminal command explains how.
Android Studio doesn't read environment variables, so this approach won't work. Also, using the projectDir scheme in settings.gradle will probably cause problems. Android Studio has a limitation that all of its modules need to be located underneath the project root. If you have libraries that are used in multiple projects and they can't be placed under a single project root, the best advice is to have them publish JARs or AARs to a local Maven repository that individual projects can pick up.
Despite the answer from Scott Barta is correct, I realized there is a way to solve my problem and wan't to share this in case somebody else has the same requirement.
I am now using the gradle.properties file do define and use gradle properties instead of system properties. The documentation of this feature can be fined in the user guide
The solution to my original question now looks like this:
$USER_HOME/.gradle/gradle.properties:
LIB_ROOT=/libraries_home
The settings.gradle file has to be modified to use the gradle property instead of the system property:
include ':app'
include ':libA'
project(':libA').projectDir = new File(LIB_ROOT, '/libraries/libA')
This works fine for me, headless as well as with AS.
Some more words regarding the fact that I am working with modules which are not placed underneath one project root. Till now it looks like AS is not complaining about this. But I just started working with this structure and it may be that I will run into problems later. What I like about this is the more flat representation in AS which is more like I am used to have it with Eclipse.
What is also described in the user guide, is to set system properties with the gradle.properties file. I tried this also, but I did run into the same problems with AS using environment variables.
It works for me with the following steps:
Set your variable in Windows
Reboot
reach it in gradle build: System.env.MYVARIABLE
I faced the same issue in apple laptop after the Android Studio Bumblebee update. This seems to be happening due to some permission issue with the Android Studio.
The workaround is to add missing flag:
chmod +x /Applications/Android\ Studio.app/Contents/bin/printenv
You can check this issue tracker for more details.
You can set environment variable by appending:
-DYOUR_VARIABLE=variable_value
to ~/Library/Preferences/AndroidStudioX.X/studio.vmoptions that you can open by selecting Help -> Edit Custom VM Options... from Android Studio menu.
And then you can use it like:
System.env.YOUR_VARIABLE
in build.gradle or settings.gradle.
MAC OS Update
I confirm that I have Environmental Variables working on Mac OS Catalina
You just need to set it in the shell you are using. I was using zsh, and was trying to set ~/.bash_profile, so it wasn't working.
Example:
ZSH Profile

IntelliJ IDEA - Can't build anything, always get "package R does not exist"

I'm trying to use IntelliJ IDEA to work on an Android app with a colleague that swears by it, but I'm unable to build any of the Android projects he sends me because whenever I try a build I get an error saying package R does not exist.
I have been trying out everything I can think of. Examples and other things to note are:
Making sure I have a version of the local.properties file pointing to the root of my Android SDKs folder.
Fiddling with various settings in the project structure dialog (I won't list them all).
The project I'm working on has two library projects with also use the R class and they work fine.
The intellisense within the IDE recognises the R class and comes up with the stuff I expect.
Any help would be greatly appreciated. I feel I'm missing something basic.
I am brand new to IntelliJ so I apologize if this doesn't work for you. I was experiencing the same problem and the solution was to add an Android Facet to your project.
(I am on a Mac, so directions here may be slightly off, and there are probably better ways to find this window, if so let me know!)
Right click your project and go down to Open Module Settings (seems F4 also works)
Select Facets in the far left column
Click the + button
Add an Android Facet to your project, and VOILA!
You may need to import your Rs now, which could be a huge pain... so hopefully someone can chime in with an easy way to auto-import
Hope this helps someone!
Another possible solution to those listed here is to check that the package name in your AndroidManifest.xml matches that of your actual package:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.yourpackagename" >
My package was building fine until I refactored the package name, everything refactored except for the package name in manifest file (see above) which caused the error "Package R does not exist".
If you run into this with a package that has been building before you need to "Rebuild".
Build->Rebuild Project . Deleting gen does not do it since IDEA saves the actual generated R somewhere else.
In my case, I added some classes from another project and I had to add the import to the R package from my actual project:
import com.youcompanyname.yourprojectname.R;
I've started playing around with IntelliJ since I've had issues with the new Android Studio and wanted to try something that was a little more stable (I've never really used either before). I ended up getting the dreaded “package R does not exist” error. In my experience, this is usually something messed up in an XML file. For me, the problem was actually with the AndroidManifest.xml file for an Android Library Module that I had created for ActionBarSherlock. For whatever reason, when it created the AndroidManifest.xml file it didn't bother to use the AndroidManifest.xml file that came with ABS and it put the following in:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ActionBarSherlockLibrary_4_3_1"
android:versionCode="1"
android:versionName="1.0">
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<activity
android:name="ACTIVITY_ENTRY_NAME"
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>
When I created this Module I chose File > New Module...
I then Selected Library Module under the Android section and for the Content Root I browsed to the location of the files for ABS (Other fields auto filled in correctly and I didn't change them).
I then clicked finish and it prompted me if I wanted to keep the local file or the memory file for project.properties.
I chose to keep the local file and it didn't prompt me for any others after that.
I have no idea why it messed up the AndroidManifest.xml file (maybe what I did above was wrong...???), but to fix it I just copied the original AndroidManifest.xml that I had downloaded with the library and replaced the messed up AndroidManifest.xml file. After that I did Build > Rebuild Project and it resolved the “package R does not exist” errors.
One other thought, #xbakesx mentions the Facets settings, and for any modules you are using as libraries, you should make sure that "Library module" is checked under Facets for that Module. I had some issues with that at first when I was trying to figure out how to configure libraries in IntelliJ/Android Studio (I've really only used Eclipse).
I just restart IntelliJ and it magically solved.
Try it first.
Had same issue - the issue was the Manifest file was did not have the default Activity setup properly.
To all the hopeless people who have reached this far down the answers: I feel your pain. I have spent an hour doing nothing but trying all those things above as well as proposals from other sources. I have checked all my xml resources twice, cleaned caches, rebuilt a dozen times, even restarted the entire machine. Here is what actually worked for me:
Under 'Build Variants' (lower left corner), I selected a different Build Variant (in my case release instead of debug) for the target that had the missing R problem. Solved it.
I've refactored the packagename and intellij didn't update it in the manifest.
So if you've refactored the packagename then go to the manifest and update the attribute "package" in the root of the xml file save and rebuild it. If any errors occur then it's probably a wrong packagename in the import (at least this was my case) so just fix them
hope this helps anyone
In my case I had to delete the intellj compiler cache. on my windows machine it was somelike this:
%USERPROFILE%\.IdeaIC12\system\compile-server\<my project>
Try create new project and select "Create project from existing sources"
Adding my $0.02 just in case someone else has the issue I did. In my case I had generated the "Hello world" application using IntelliJ and forgot to change the package name from "com.example." I then used IntelliJ to refactor the package name. This caused the error to start happening.
So I did a global search for "com.example" and it was found in the AndroidManifest file as mentioned by others. However, changing this did not fix the problem. "com.example" was also found in "workspace.xml" under the ".idea" directory. I changed all the occurrences their, did a rebuild and then it started working again!
This seems like a bug in IntelliJ.
In Android Studio, my problem was when i copy pasted a class to use as a template to make another similar class, it asks to automatically import a bunch of stuff, most of which was not going to be related to the new class, so i said cancel. with it it left out import com.your.packagename.R; so R wasnt actually being imported into the file i was trying to use it in.
can be fixed with an alt-enter when clicking on R (it should be highlighted in red)

Using the new "manifestmerger" property in Android

In the newest version of ADT (version 20 preview 3), they say that it's possible to make the libraries' manifest file become mergeable with projects that use them:
Automatic merging of library project manifest files into the including
project's manifest. Enable with the manifestmerger.enabled property.
How and where do I use it? I can't see content assist helping with me on this anywhere.
Add the following line to your project.properties file of your application project.
manifestmerger.enabled=true
Introduced with Android SDK Tools, Revision 20 (June 2012):
https://developer.android.com/studio/releases/sdk-tools
Build System
* Added automatic merging of library project manifest files into the including project's manifest.
Enable this feature with the manifestmerger.enabled property.
If you want to merge android library project manifest and your current project manifest, you have to add manifestmerger.enabled=true in your project.properties file where you referred your library project. But, you should be confirmed some point like ADT version, Also Minimum and target SDK should be same as library project.
FYI:
manifestmerger.enabled=true won't merge the manifest files if you are using eclipse export signed App.
As noted here it seems to be a bug.
http://code.google.com/p/android/issues/detail?id=34623
It was a bit of a hassle for me to set up merging correctly as well. (restarting eclipse, open close project..) To find out if merging is working take a look at the file in ../Your_Main_Project/bin/AndroidManifest.xml. If merging worked you will see the complete result in this file.
EDIT: This bug was fixed in ADT v20.0.1 (Juli 2012): http://developer.android.com/tools/sdk/eclipse-adt.html
I was facing some errors during manifest merging (R.java file went missing) so alternately I explicitly copied the manifest contents (e.g. I copied just the activity contents) from the library project manifest and put them in my main project manifest. That resolved the error and everything seems to be working well so far. Let me know if anyone feels this is not a recommended alternative to manifest merging.

default.properties not being created

I am using InteliJ Idea Community edition to develop android apps. I was trying to write UnitTests for a HelloWorld App as described in link text
. However I keep on getting an error
Found main project package: com.example.helloandroid
Found main project activity: .HelloAndroid
Error: Unable to load the main project's default.properties
On going through the files that were created by InteliJ Idea, I saw that all the files as mentioned in d.android.com/guide/developing/other-ide.html#CreatingAProject are being created except for defaul.properties and build.properties.
Is there any way we can create these files?
I had the same problem you're describing as I'm also developing using IntelliJ and these are the steps I followed to create a valid default.properties
1) Create a project using Android (with no IDE) the instructions are here. I created using exactly the same information than in my original IntelliJ project but looking at the resulting file it was not that important.
2) Copy the default.properties to your own project
In order to create the project you will have to know the id of the target you are using, you can obtain the list by executing android list targets.
Once I created the project I opened the default.properties file and the only thing important there was the target, in my case Project target.target=android-8
Hope this helps although your question is stackoverflow since a long time already.
Regards
PS: if I knew how to attach a file you wouldn't require to follow the above steps as the resulting file has no project specific information except for the target (if you want me to send it to you just tell me)
This is a bug and has been fixed but the fix has not been released yet:
http://youtrack.jetbrains.net/issue/IDEA-69343?projectKey=IDEA&query=android+default.properties

Categories

Resources