In my team, we developed a library in Eclipse with ADT plugin.
We have a "big" demo application and several "mini" applications using the library to test different aspects.
Since the official IDE for Android is now Android Studio and ADT plugin seems to be abandoned (last update on October '14), we are studying the migration to Android Studio.
On Eclipse, we can load projects from different locations in the disk within the same workspace. We like this because this allows us to have our library project loaded aside with our demos and we can also load temporal projects in the same workspace referencing the project library.
I see there are two ways to migrate, but I find cons in both:
Importing the Eclipse project directly into Studio
This option works but:
This changes the folders structure of all the projects. It copies the eclipse projects into the Android Studio project folder, and this would mean making changes to our internal repository.
If we want to add a temporal project to test it with our library, we'd need to import it so it will also be copied next to the "main" library and demos.
Exporting the Eclipse project from Eclipse as a Gradle project.
This option keeps the folder structure of our Eclipse projects (#1 above) but #2 above is still valid here and I also get this error when I try to Import a project from a different location.
Error:FAILURE: Build failed with an exception. * What went wrong: Task
'compileDebugSources' not found in project ':TestMemCons'. * Try: Run
gradle tasks to get a list of available tasks. Run with --stacktrace
option to get the stack trace. Run with --info or --debug option to
get more log output.
So, can we migrate to Android Studio keeping the folder structure and allowing us to load other Eclipse/Android Studio projects in the same instance so they can reference our library project?
Answering my own question...
So, can we migrate to Android Studio keeping the folder structure and
allowing us to load other Eclipse/Android Studio projects in the same
instance so they can reference our library project?
I found you can add a temporal project as follows:
Copy the temporal test project where you want it, it only has to be inside your main project tree.
Add the test project relative path to the settings.gradle file of the main project. Ie, if you moved the test project to \Demos\Tests\Test1:
include ':Demos:Tests:Test1'
So you can have something like this:
include ':Sources:Android' //library
include ':Demos:Android' //Features Demo
include ':Demos:Tests:Test1' //Test1
Create a build.gradle file for the test project. Ie, \Demos\Tests\Test1\build.gradle:
apply plugin: 'android'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':Sources:Android')
}
android {
compileSdkVersion 7
buildToolsVersion "21.1.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
In this case, I'm adding a dependence to my library, that is a library module in the main project at \Sources\Android.
So, if you want to keep your folder structure, you can go for the option 2 "Exporting the Eclipse project from Eclipse as a Gradle project" and still load test/temporal projects as described above.
The only problems I see here are:
This is less automatic than it was with Eclipse.
In Eclipse you could remove the test project when done and the project was still in the disk but the workspace was clean again. In Android Studio, with the technique above, you should remove the test entries from the settings.gradle in your main project and remove the test project folder to get the main project clean as before the test.
Related
My Android project contains some property files in the package structure. To read this property I use MyClass.getResourceAsStream("someProperties.xml"). MyClass has no access to a Context.
After migrating to Android Studio the someProperties.xml is not moved into the resulting package structure. Therefore my code can't find the file.
What can I do to read my file again? How can I modify the gradle build to have the file copied to my package structure again or is the a possibility to read resources without a context and put the file into assets?
I guess you have not specified within gradle where those resources are located.
Defaults are different in Eclipse ADT and Android Studio.
Here are defaults for Eclipse (when java sources already in src/main/java)
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
see MAKE ANDROID ECLIPSE PROJECT READY FOR ANDROID STUDIO, YET KEEPING IT ACCESSIBLE FOR ECLIPSE USE TOO
I have a project that I already run in Android Studio.
After I've opened the project in Android Studio I got the message:
Migrate Project to Gradle?
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
More Information about migrating to Gradle
Don't show this message again.
Following the link of More Information about migrating to Gradle although I'm already on Android Studio I've followed the option Migrating from IntelliJ Projects .
Since I've already have a build.gradle file at the root of my project I've modified to include some dependencies.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile "com.android.support:support-v4:18.0.+"
compile "com.android.support:appcompat-v7:18.0.+"
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
As instructed, i've ran gradle assembleDebug on the Android Studio terminal windows but was getting some errors. To solve this errors I had to create a local.properties with sdk.dir=C:\\Program Files (x86)\\Android\\android-sdk and remove the android-support-v4.jar file from the /libs folder and from the Libraries->libs from the Project Structure.
I now ran again gradle assembleDebug and this time it finishes without any errors.
I've restarted Android Studio but after restarting I've saw that on the External Libraries of the project there were no support-v4 and appcompat-v7 and in one of my classes I have the import android.support.v4.widget.CursorAdapter; marked as error since Cannot resolve symbol Cursor Adapter.
If I press the button Sync project with gradle filesi got the message: The project MyProject is not a Gradle-based project
Can someone help me figuring out how to solve this?
Here is my project Structure
The project thinks it's still a non-Gradle based project; it's not the presence of the build.gradle file that makes it Gradle-based, but it's how the project was set up in the first place. You'll need to re-import your project to finish the conversion to Gradle.
First, though, it looks like you don't have a settings.gradle file; it looks like you need one. Since you've set up your project as a single-module project, then you can put the file in your project's root directory, next to build.gradle. It should contain this:
import ':'
In the future if you add more modules to your project you may want to convert it to a multi-module directory structure, but you don't need to worry about that now. In any event, now you need to do the re-import in Android Studio:
Close your project
Back up your project
Delete the .idea folder in the root directory of the project
Delete all the .iml files in your project
Import your project in Android Studio, and in the dialog that prompts you for a file, choose the build.gradle file.
After this you should be good to go.
In my case, when I tried to open an existing gradle project and AS didn't recognize it like a gradle project, the problem was inside settings.gradle file. settings.gradle was corrupt because, for some reason, the semicolon was missing. The right structure is include ':app'; where app is the name of the project's module.
Also, if you need, you can put more than one module, like this: include ':module1', ':module2', ':module3';
I hope it could help someone.
In my case: Step 1: Project Structure > Settings.gradle (Open it and add-- include ':app'; .
Step 2: Goto Gradle Tab (It normally present in Left or Right of Android Studio) > Then click to Refresh All Gradle Project
Step 3: Bang....... I hope its work.(Its works for me)
All I did was to try importing the project with the "import Gradle, Eclipse ETC" option at the start window of Android Studio, selected my gradle-incompatible project to import, and then it did import by asking me automatically if I wanted to make a gradle build project and voila it did import correctly this time with no errors.
The process is pretty straightforward, nothing to fiddle around with nasty settings, just follow the IDE auto-fixes and it will work.
At last that worked for me!
Just check if you are importing the right folder which contains .gradle and .idea folder
click on File
Click on Import Projects
Click on Users then AndroidStudioProjects
Choose your Project then Click OK
NOTE: If you are moving from eclipse to Android Studio then you have do exactly same thing but choose the eclipse projects.
I'm trying to get a new PhoneGap application setup and running inside Android Studio with the Gradle build system.
At the moment I have successfully created the PhoneGap project and imported into Android Studio. It all appears to be working fine, but I cant work out how to move it to the Gradle build system, or even if its possible.
Can anybody help?
I managed to do this.
You need Android Studio and the Eclipse ADT version, as well as Cordova/PhoneGap all set up.
Import the Cordova project into Eclipse.
Go to File -> Export... -> Generate Gradle Build Files.
Click next to get past the "Import Instead?" screen.
Select both your Android project and the CordovaLib project to export and click Next.
Once this completes, open Android Studio.
Go to File -> Import Project...
Select the build.gradle file for the main Android project, which was generated by Eclipse, and click OK.
After the import, you may get some warnings about a newer gradle version in use, just check your settings and it seems to work itself out.
At this point, you should have a project structure that is your main project, but with CordovaLib as a module.
Now you can open the build.gradle file in the main project directory and change it to this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CordovaLib')
compile 'com.android.support:appcompat-v7:19.+'
}
You should now be able to convince Android Studio to compile.
An extra tip would be to create a script to run "cordova prepare" and add that to the module's run configuration as an external tool. Make sure to synchronise the whole project before deploying the APK to a device or emulator.
I am new to Android Studio and still getting used to the AS project structure and Gradle.
Using Cordova 4.1.2
Android Studio 1.0.1
1) I created the app using the Cordova CLI:
cordova create CordovaAndroidApp
cd CordovaAndroidApp
cordova platform add android
this version of Cordova created the build.gradle and settings.gradle files.
2) From Android Studio splash screen I selected "Start a new Android Studio project"
On the second screen I checked the Phone and Tablet box; on the third screen, I chose "Add No Activity"
3) In this new Android Studio application, from the Project view in the left panel with the top level of the project selected, I selected File -> Import Project. In the popup "select Eclipse or Gradle Project to Import", I chose to the Cordova project directory, clicked down to the platforms / android directory, and selected the build.gradle file, then OK.
I was able to build and run the basic Cordova project (just the splash screen) with no problem.
I am trying to almost 2 days to add AndEngine to Android Studio but unable to do so. I tried the following two methods, neither worked.
1st Try
I download the AndEngine code from GitHub Link -- this is NOT a Gradle Project
and tried to add it to my Android Studio build.gradle and settings.gradle, but i get this error, my screenshot: https://postimg.cc/image/5mcvpvsar/
(I think I am getting this error because AndEngine is not a gradle project - HOW TO MAKE IT A GRADLE PROJECT??)
2nd Try
I have also tried adding the andengine.jar (file I just googled for) in /libs folder and do right-click --> "Add as Library" but still I cannot do "import org.andengine...." in my project files.
All tutorials available online are in Eclipse, I am using Android Studio.
I am not even able to start.
UPDATE: Yes, I gave up using Android Studio for AndEngine! Took me 15mins to do this in Eclipse, compared to the unsuccessful weekend (which i will never get back!) I spent on Android Studio
I use this techique: I set this in my settings.gradle
include 'andengine'
project(':andengine').projectDir = new File(settingsDir, '../relative/path/to/andengine')
that is in the root directory of the project (I think gradle has already created it for your main project).
In AndEngine use a build.gradle like the following for the AndEngine project
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
and add in the dependencies of your project
compile project(':andengine')
Maybe you have to close and reopen Android Studio, but normally for me this works.
BTW after have write the answer I see that someone has opened a pull request for a gradle build file.
I created a tutorial for this - How to add Andengine, Andengine Tile Map, Andengine PhysicsBox2D to Android Studio 0.8.9.
Here is the link, I hope everything works - https://docs.google.com/document/d/1zk2QjNiPvkj52G4qSVivEPrLfkCUVqmnCVH8TfsnER8/edit
ANDENGINE WITH ANDROID STUDIO 0.8.9
Note: I am using the AnchorCenter brach and TortoiseGit to get all the files.
Download Andengine from github using TortoiseGit: https://github.com/nicolasgramlich/AndEngine
After the dowload use TortoiseGit to switch to branch GLES2-AnchorCenter
Create new project in Android Studio
Create new module:
Select File -> New Module -> Android Library
Set Application name to AndEngine
Set Module Name to AndEngine
Set Package Name to org.andengine
Set Minimum SDK 14
Target SDK 19
Compile with 19
Theme None
Keep clicking next until module is created (no difference what you pick)
Enter the folder where you have downloaded Andengine, enter src/org/andengine and copy all the files inside.
Paste the copied files into your new module in your project src/java/org.andengine. After pasting everything remove tha MainActivity that was created on default
Enter the folder where you have downloaded Andengine, copy AndroidManifest and paste it into your new module (src/main)
Add the module to the project:
Select File-> Project Structure -> app-> Dependencies
Click the “+” button and pick “Module Dependency”
Select from the list your AndEngine Module
Check your project gradle in app folder (build.gradle) and make sure you have a line like this under dependencies - compile project(':AndEngine')
You should now be able to use AndEngine in your project
ANDENGINE TMX TILED MAP EXTENSION WITH ANDROID STUDIO 0.8.9
Note: We do this the same way like with Andengine but we change a few things:
Download AndengineTMX from github using TortoiseGit: https://github.com/nicolasgramlich/AndEngineTMXTiledMapExtension
After the dowload use TortoiseGit to switch to branch GLES2-AnchorCenter
Create new project in Android Studio
Create new module:
Select File -> New Module -> Android Library
Set Application name to AndEngineTMXTiledMapExtension
Set Module Name to AndEngineTMXTiledMapExtension
Set Package Name to org.andengine.extension.tmx
Set Minimum SDK 14
Target SDK 19
Compile with 19
Theme None
Keep clicking next until module is created (no difference what you pick)
Enter the folder where you have downloaded AndengineTMX , enter src/org/andengine/extension/tmx and copy all the files inside.
Paste the copied files into your new module in your project src/java/org.andengine.extension.tmx. After pasting everything remove tha MainActivity that was created on default
Enter the folder where you have downloaded AndengineTMX, copy AndroidManifest and paste it into your new module (src/main)
Add the module to the project:
Select File-> Project Structure -> app-> Dependencies
Click the “+” button and pick “Module Dependency”
Select from the list your AndengineTMX Module
Check your project gradle in app folder (build.gradle) and make sure you have a line like this under dependencies - compile project(':AndEngineTMXTiledMapExtension')
You should now be able to use AndEngineTMXTiledMapExtension in your project.
ANDENGINE PHYSICSBOX2D WITH ANDROID STUDIO 0.8.9
Download this file - http://d-h.st/FyC
Unzip the file
You should have 2 jar files, copy them to your project app/libs
Right click on andenginephysicsbox2dextension.jar and select “Add as library” (or something like this)
Open your build.gradle in your app folder
Under dependencies add compile files('lib/physicsbox2d_so_files.jar')
You should now be able to use PhysicsBox2D in your project.
As the question's answers havn't been accepted yet, and I know people are still searching for solutions to this, I found this great website with very very clear and concise instructions to import AndEngine to your Android Studio projects. Here's the link:
http://geq-i.blogspot.com/2014/02/how-to-setup-andengine-in-android-studio.html
All credits go to the user who created this page. I can attest to the fact that this is working perfectly. I JUST used this website after trying 10s of different ways.
Only thing to note on the link is the last part:
$ cd <project folder>/AndEngine/src/main
$ rm -r java/org
$ mv org java
This part is copying the org folder from . to ./main/java. Best way to do this is to just drag and drop the org folder into main/java when the project has finished building once.
Hope this helps!
Well i had the same problem - This helped me to solve it.
http://www.makethegame.net/android-andengine/how-to-setup-andengine-with-android-studio/
Check out this tutorial on how to use andengine in android studio
http://javaprogrammernotes.blogspot.in/2014/05/settings-up-andengine-in-android-studio.html
Brief Summary of the Tutorial(Check out the full tutorial if you face any issue):
Let's assume that you already have created a project and it has default structure. First create folder named third_party in the root directory of the project. Then in third_party directory create subdirectories called andengine and andenginebox2d. I assume that you already downloaded or cloned AndEngine and Box2d extension for it. Put AndEngine and AndEngineBox2d in andengine and andenginebox2d directories respectively. Create file named build.gradle in andengine directory and andenginebox2d directory. Build.gradle files is a file that tells gradle how to build your project.
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-project.txt')
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Open settings.gradle that is located in your project's root directory and add two lines to it:
include ':third_party:andengine'
include ':third_party:andenginebox2d'
Next open build.gradle which locates in app directory and add
compile project(':third_party:andengine')
The final step is to open AndroidManifest.xml in andegine and andenginebox2d directories and make them look like this:
<!--?xml version="1.0" encoding="utf-8"?-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.andengine">
<application>
</application>
</manifest>
application block is needed because of bug in manifest merging tool.
That's it! Now clean your project and press run. Everything should work just fine.
I've an app that needs to be build multiple times with different resources for different customers (branding, configuration, and pre-loaded data change between customers).
In the wake of this year's Google I/O I've heard about the new Gradle-based Android build-system. So I thought, it would be a good idea, to realize this one-source/multiple-apks scenario using a Gradle build script.
Now here comes my question: How can I get started using Gradle for building while sticking to Eclipse? All the reads I found online point to converting the project to the still immature Android Studio. I'd like to put off migrating to Android Studio until that's declared "safe" for production use by Google.
Ideally, I'd like to be able to hook the build script(s) to the Debug and Run Configurations of Eclipse, very much the same way as I can pick and choose different build targets for debugging and archiving in XCode. If that's possible, what steps are required to make that work?
I apologize for the noobish quality of these questions, but for me this is actually quite an undiscovered country. Any help is appreciated.
Edit:
Our team has migrated to Android Studio in late October 2013 and since version 0.4 were are encountering fewer and fewer bugs. If your organization is not super-conservative about adopting pre-1.0 environments for development, I'd encourage you to jump into the cold water and try working with Android Studio and its Gradle build system. The only important thing missing IMHO is decent support for unit-testing.
It is possible to use 2 build systems (Eclipse + gradle based). Just make sure output folders are different (bin for ADT, build for gradle).
(Update for TL;DR : check Nodeclipse/Enide Gradle for Eclipse
(marketplace) )
File -> Export -> Generate Gradle build files will just add build.gradle with content below (but check versions). No existing files are changed.
com.android.tools.build:gradle version should be the latest.
For gradle type gradle build as said in http://tools.android.com/tech-docs/new-build-system/user-guide. Try gradle tasks for more. (On my slow Internet connection it took 1 hour! for gradle to download all needed dependencies)
Vogella tutorial http://www.vogella.com/articles/AndroidBuild/article.html is not yet ready. Other online tutorials are not really finished http://www.jayway.com/2013/02/26/using-gradle-for-building-android-applications/
Eclipse ADT is not yet using gradle, I think it will be polished within Android Studio first. It would be not so wise to start using evolving technology in both IDEs at the same time.
See build.gradle example below. If you already mastered gradle, then maybe Wizards is not needed at all.
For the latest build.gradle template for classic Android project check gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 8
buildToolsVersion "19.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
ADT-Bundle does not come with Eclipse Marketplace, so update site could be used.
Update p2 repository for Gradle Integration for Eclipse is
http://dist.springsource.com/release/TOOLS/gradle
But as of version 3.4.0 it does not provide Editor for .gradle files.
So there is no sense of having it for Android development.
I would go with default ADT build, having gradle as secondary build for experimentations
and keeping an eye when flow of bugs on http://tools.android.com/tech-docs/new-build-system becomes rare. (That should be around formal 1.0 version)
UPDATE: 2014-04-15
Alex Ruiz's (from Android team) Blog about Android, Gradle & ADT
Android’s Gradle Model
Instead of creating IDE-specific Android/Gradle models, we decided to have an IDE-agnostic representation of a Gradle project. This way, we have a single source of information that is easier to maintain. IDE integration will be implemented as a plug-in for each supported IDE (in our case, Eclipse and IDEA.) The main benefit of this approach is that we can release the Gradle plug-in independently of the IDE integration plug-ins. For example, we can ship a new version of the Eclipse plug-in that has several bug fixes, without affecting the Gradle side of Android.
As of April 2014 eclipse-gradle plugin is not compatible with android-gradle plugin:
As answered in Issue 57668 by Android team (raised by #arcone)
Project Member #2 x...#android.com
The eclipse plugin is not compatible with the android plugin.
You will not be able to import an Android gradle project into Eclipse using the default Gradle support in Eclipse.
To make it work in Eclipse we will have to change the Gradle plugin for Eclipse, the same way we are modifying the Gradle support in IntelliJ
That is Android team is working on gradle plugin for IntelliJ and gradle plugin for Eclipse needs to be updated too.
There is effort at Nodeclipse to smooth the transition times. And continue to develop in Eclipse while still experimenting or fully using gradle.
Nodeclipse/Enide Gradle for Eclipse
(marketplace)
Some screenshots for Gradle for Eclipse:
Install Gradle:
a. http://gradle.org/gradle-download/
b. Choose 2.1 from previous releases section.
c. Unzip at convenient folder.(Ex : D:\Graddle\gradle-2.1)
d. Set system environment variables.
i. GRADLE_HOME as D:\Graddle\gradle-2.1)
ii. GRADLE_OPTS as -XX:MaxPermSize=512m
iii. %GRADLE_HOME%\bin to Path
iv. Set ANDROID_HOME ( Ex: D:\android-sdk)
v. Append “%ANDROID %\platform-tools” to path.
e. Open command prompt and check gradle is set. May use gradle -version to check.
Install Gradle eclipse PlugIn:
a. Launch Eclipse
b. Help > Eclipse Market Place
c. Search “gradle”
d. In that choose “Nodeeclipse/enide”
e. Select all listed, accept & install.
f. Restart eclipse once installed.
Set Gradle & Java Homes :
a. Launch eclipse.
b. Window > Preferences > Gradle EnIDE
c. Set these if not set :
i. Gradle home to use is set ( Ex: D:\Graddle\gradle-2.1)
ii. Alternate JAVA_HOME to use is set ( Ex : C:\Program Files (x86)\Java\jdk1.7.0_60)
iii. JVM options for GRADLE_OPTS is set to “-XX:MaxPermSize=512m”
Build the Project:
a. Expand APK in eclipse Java explorer.
b. Right click on build.gradle
c. Run As > Gradle GUI
d. Comand Line : gradle clean build
e. Wait for build to complete : First time build will take several minutes.
f. If Build dex error or Java heap space error :
i. Open build.gradle in editor.
ii. For multi dex builds- Set appropriate javaMaxHeapSize based on your java (javaMaxHeapSize=1024M for 32bit Java,2048M for 64bit Java)
iii. May comment signing (//apply from: "$rootProject.projectDir/jenkins_config/gradle/signing.gradle";) to avoid signing for debug build.
iv. Build again after these fixes.
Install Build On device:
a. Connect the device to m/c.
b. Right click on build.gradle
c. Run As > gradle installDebug Gradle Android start
d. Wait for install to complete
Debug Build:
a. Launch the app
b. Attach the debugger (DDMS>Devices > App).
c. We able to debug on few devices checked.