Android Studio creates app folder - android

I am working with Android Studio 1.1.0 on a MacBook Pro with OS X 10.9.5.
When I import projects (Eclipse) I find the source code is put under a folder named "app".
Ok, so far so good. The projects build and .apk files named app-debug.apk and app-debug-unaligned.apk are generated. They execute fine on the emulator and target device (Samsung Galaxy S5).
I wanted to rename the app folder as well as the .apk files.
The project name is tcpcommclient. I wanted to change the module name "app" to "TCP_Client". (not sure if I am allowed to do that).
I found the following in stackoverflow:
Why is my APK name generic?
Which said if I changed the folder name (app) I should also change settings.gradle. I did and that didn't work. I keep getting:
Error:Android Source Generator: [tcpcommclient] AndroidManifest.xml file not found
I looked through my project for instances of ":app" and found three of the:
workspace.xml
settings.gradle
app.imi
in which I changed to ":TCP_Client". I also notice that app.imi (should be manually renamed?) is still around under TCP_Client.
What also happens is that the folder "app" seems to be created by Android Studio even when I deleted it manually. Also another app.imi file is created there which contains the following text:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
It seems like somehow I have Android Studio configured for this project so that it wants to see the source and the AndroidManifest.xml under the "app" folder.
Is there a way to change the name "app" to another name (namely "TCP_Client") and have that be the name of the .apk file?
Thanks in advance.
Jim

To rename a module:
Rename the folder from app to TCP_Client
In settings.gradle, replace include ':app' by include ':TCP_Client'.
Then resync the project with the Gradle files.

This is because Android Studio is a stripped-down version of IntelliJ IDEA that only allows you to create Gradle projects, and the Gradle plugin is nowhere near ready for prime time.
The easiest thing to do is just use a mature product like IDEA or Eclipse. But if you must use Studio, it's useful to know that app is actually the name of the Gradle module that it creates without bothering to ask you for a name. If you want a different name, create another module with the name you want, then delete the app module.

Related

Android Studio Project with multiple gradle files (one for each flavor)

I am working on a project that has structure like
Project
|+.gradle
|+.idea
|+.navigation
|-app
|+build
|+keystore
|+libs
|-src
|+androidTest
|+Samsung
|+Motorola
|+HTC
|-app.iml
|-build.gradle
|-build-Samsung.gradle
|-build-Motorola.gradle
|- ** How to add build-HTC.gradle file here? **
...
...
As you can see, there is specific code in Samsung and Motorola directories (not expaned above) and there are specific gradle files (build-Samsung.gradle and build-Motorola.gradle) in addition to build.gradle file.
I have to follow this structure and have to add another vendor specific flavor for say HTC. How do I create "build-HTC.gradle" file in directory structure above in Android Studio.
Sorry, this might be very basic question but I was not able to find anything online and if I right-click on my src directory and chose New, I dont see option for gradle file.
Thanks

android studio settings.gradle duplicated, not recognized.

My android studio project is ostensibly error-free and (usually) builds just fine. But as seen in the following picture, there is a set of files that shows up twice in the file tree:
...once at the same level as the root project folder, and once within the project folder. NOTE: The actual files on the file system are ONLY located within the project folder.
In Android Studio, when I try to edit the settings.gradle within the project folder, it tells me "This folder does not belong to a Gradle project. Make sure it is registered in settings.gradle.", as shown here:
So, I try to instead edit the settings.gradle outside the project folder. In that case the Non-Project Files Access window comes up: this file is not part of my project. As shown here:
Who knew Android Studio was designed by Franz Kafka! But seriously, has anybody seen this? Or do you have any thoughts? Because of this issue, I can't add any new libs, so it is quite a show-stopper.
You may be interested to know that there in my git repo, there are existing versions of several auto-generated files including app.iml and project.iml and some other files from .idea/. When I git checkout back to the ones in the repo, the duplicate-file-trees briefly disappear. (I am still unable to access/edit settings.gradle, though).
If you want more information let me know. Thanks!

How to point android build system at different android.jar file

I have created an "extended" android.jar file that includes classes that are only known internal to the Android system using this guide. In the guide, the author suggests creating a new platform in android-sdk-linux/platforms/ to build against that includes the extended android.jar file.
The problem I have with this is that I want to be able to keep this file in version control as part of the build system (and I would rather not keep the entire Android SDK in version control). So what I would like to do is to simply keep the extended android.jar in version control with my app, and then at build time, have my build system point to the extended android.jar instead of the one kept in android-sdk-linux/platforms/android-/. Is this possible, and if so, what's the best way to go about doing this?
The way to do this is as follows:
In the build.xml file for your app, there should be a line that looks something like this:
<import file="custom_rules.xml" optional="true" />
This allows you to import a file in your build that enables you to customize build rules. You may or may not have this file, depending on if you've customized your build already.
To point the build at your custom android.jar file, you can make the custom_rules.xml file look something like this (or just add the line containing the classpath if you already have created a custom_rules.xml file):
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules" default="debug">
<property name="java.compiler.classpath" value="custom_libs/android.jar" />
</project>
Obviously the value you enter for the classpath depends on your build system. I simply added a "custom_libs" directory next to the custom_rules.xml file, and placed my custom android.jar in there.

Appcelerator titanium push Notification using C2DM?

I am using Appcelerator Titanium Version 1.8.0 have anyone tried push notification using google's C2DM.if so help me to create Sample push notification.
It is not that difficult: Here is steps for it...
Clone project from github
Find build.properties
Modify all paths to fit the paths (and versions) in your environment
Optionally you need to download and install the android sdk from here http://developer.android.com/sdk/ndk/index.html
Open console in module root and type ant and hit enter
The build process should end with something like build successfully
In the module directory, you will find the build result in the dist folder
Open that folder, unzip the com.findlaw.c2dm-android-0.1.zip
A folder is created: modules/android/com.findlaw.c2dm/0.1
copy the content of modules/android/com.findlaw.c2dm/0.1 to the folder [your_project]/modules/android/com.findlaw.c2dm/
Copy timodule.xml to the root folder of your project (where the tiapp.xml is located)
Open tiapp.xml and replace all occurences of com.findlaw.c2dm with your app id, except of the line including this:
com.findlaw.c2dm.C2DMReceiver
Register the module in tiapp.xml:
<modules>
<module platform="android" version="0.1">com.findlaw.c2dm</module>
</modules>
14. Use the module in your code as described in the example of the module
For more check this communication of our team member...
Your Module folder should not inside the Resource folder

Android Library assets folder doesn't get copied

I am creating an Android library and it has an assets folder with images.
When I use it in another project the assets doesn't get copied.
Anyone else had this issue?
The new Android Build System that is based on Gradle supports asset folders in library projects!
With ANT based builds it's still not possible:
Library projects cannot include raw assets. (See docs)
But you could
copy the assets manually
or even patch the aapt tool (see http://devmaze.wordpress.com/2011/06/26/enabling-assets-in-android-libraries/)
It is possible to put assets into resulting library jar by small fix:
Put "custom_rules.xml" into you library project home (near the build.xml):
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<target name="-post-compile" if="${project.is.library}">
<echo>Post Compile: add assests from ${asset.absolute.dir} to ${out.library.jar.file}</echo>
<jar destfile="${out.library.jar.file}" update="true">
<zipfileset dir="${asset.absolute.dir}" prefix="assets" excludes="**/*.java ${android.package.excludes}"/>
</jar>
</target>
This will pack your library assets into you resulting library jar. As result, these assets will be included into resulting .apk of your application.
Checked on Android SDK Tools Revision 21.1.0 on OSX
From Eclipse and ANT you can reference the same "assets" folder from multiple projects.
This allows your source tree to have a single copy of the assets files, but have them included in multiple APKs.
See Android: targeted res folders for debugging in eclipse
From ProjectA I was able to reference ..\ProjectA\Assets from ProjectB.
On Eclipse (under Windows at least, I've not tried on Linux yet), I had to create a new variable to reference ..\ProjectA and use that variable in "Linked Folder Location". If I attempted to use ".." in "Linked Folder Location" eclipse wouldn't accept it.
For those using IntelliJ IDEA, you can make a change to your application module's packaging settings to include depedent assets. Note, this was done on version 14.0.2 of IntelliJ Community edition. My main application module now inherits files form my library project's assets folder as if they were right in the main project!
Right click application module > Open Module SEttings. Select Android tree node on module > Packaging Tab. Check "Include assets from dependencies into APK"
Note: I've never used Android Studio, but I would guess there is a similar setting for this in that application.
start by creating android lib project, close after creation. this'll prevert autobuild
use cmd terminal on windows android command is batch file
add tools to path
C:\Users\user_bss>PATH=%PATH%;C:\adt-bundle-windows-x86-20140321\sdk\tools
Generate build.xml for ant
android update project -p C:\Users\user_bss\Documents\Workspace\SDKAdvanced -n SDKAdvanced
notepad custom_rules.xml add the code from above don't forget end tag
run "ant debug" or "ant release" to build
you'll see classes.jar in bin dir this is your packed lib

Categories

Resources