How to push project source code to BitBucket repository from Android Studio

Hi Guys, In this post, I’ll give details about push project source code to Bitbucket repository from Android Studio.

When you started working on a project in Android Studio, you may want to store the project code to safe remote server. For this purpose its recommended to use Bitbucket repository system. Which will allow you to create repository and push all source code safely. Important feature it’ll provide you all Git features with Project management system. So you can create Multiple branches and Tags and manage your source code safely even with multiple developers working on a same project.

You need to have BitBucket Login for creating new repository, If you not have you can create a Bitbucket login here. After creating Account, Login to BitBucket website and Create a new repository. And get the link for new repository. It’ll be used in Android Studio later.

Ok, Now Open Android Studio with your project source code. Go through the below steps to Push project.

In Android Studio, Go to VCS menu -> Select Enable Version Control Integration…

project source code

You’ll see Popup to select version Control System. here select Git and click OK.

You’ll see your Project files changes to orange colour.

Now right click Project, it will display a menu. Goto Git->Select Add

After clicking on Add, Project files will change to green colour

Now Again right click on Project and in menu Go to Git-> Select Commit Directory…

It’ll display a Commit Changes dialog, Enter your Commit Message and click Commit.

Now right Click on Project Source Code, in menu Go to Git-> Select Repository -> and then Select Push… or else you can type shortcut keys¬†Ctrl+Shift+K .

You’ll Push Commits dialog, In this dialog you’ll see master –> Define Remote.

Click on Define Remote, It’ll display a Define Remote dialog. In this dialog paste the URL(that is taken in Bitbucket after creating repository). And click OK.

It’ll show all the Committed files and message you entered before when committing directory. Now Click on Push. It’ll push all code files to Bitbucket repository.

Now if you go to bitbucket website in a browser and open your repository and refresh it. You’ll see project source code pushed safely to your repository.

That’s it.

Hope it helps somebody.








Could not resolve, Android Studio

While implementing Push Notifications, I get this error Could not resolve all dependencies for configuration

I’ve installed¬†Google Play Services and Google Repository using SDK manager

not resolve

and added the following dependencies in gradle file

dependencies {
   compile ''

When I run the app, I see following error,

Could not resolve all dependencies for configuration ':library:_debugCompile'.
> Could not resolve
Required by:
:library:unspecified > >
> No cached version of available for offline mode.

After searching solution for a while, I found the issue is due to this ¬†“You need to make sure you have Android Support Repository up to date – that is where Android Support Library dependencies are resolved.”

So, I installed Android Support Repository,

and Rebuild app… Fixed the issue.

Hope it helps somebody..

ref link:

Generate signed APK file with Specific name Android Studio

In Android Studio, when clicked menu Build-> Generate Signed APK file, the dialogs displayed for generating APK file, doesn’t allow you to edit the APK file name. It just applies default app name to build file, unlike ADT Eclipse.


We have to write Groovy code in Gradle build file to, Generate singed APK file with Specific name.

Here i’m just giving an example how we can write it.
For eg: If your app name is helloWorld, If you generate APK build file, it will creates helloWorld-release.apk file. But if you want to generate Apk file with appending version name, and change filename like “HelloWorld-1.0v.apk”.

In project open build.gradle file, you should have defaultConfig as below

defaultConfig {
    applicationId "com.sample.helloworld"
    minSdkVersion 14
    targetSdkVersion 14
    versionCode 1
    versionName '1.0'

in this build.gradle file, define a method just above the dependencies, as below

def appendVersionName(variant, defaultConfig) {
    variant.outputs.each { output ->
        if (output.zipAlign) {
            def file = output.outputFile
            def fileName ="helloWorld-release.apk", "HelloWorld-" + defaultConfig.versionName  + "v.apk")
            output.outputFile = new File(file.parent, fileName)

        def file = output.packageApplication.outputFile
        def fileName ="helloWorld-release.apk", "HelloWorld-" + defaultConfig.versionName + "v.apk")
        output.packageApplication.outputFile = new File(file.parent, fileName)

dependencies {
    compile files('libs/android-support-v13.jar')
    compile ''

then search for buildTypes, and call the appendVersionName method as shown below,

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

            applicationVariants.all { variant ->
                appendVersionName(variant, defaultConfig)


That’s it. Now Goto Build-> Generate a Signed APK… just follow the dialog, click Finish, and you will see APK file created with your specified name.

Hope it helps somebody…

Cheers.. ūüôā

ref link & credits:

You may also interested in

Gradle error, Could not find method jcenter() for arguments [] on repository container

Could not find method jcenter()

When i tried to see project dependencies using gradle command in Android Studio Terminal, I get following error,Could not find method jcenter() for arguments [] on repository container.

project_path>gradle -q dependencies app
FAILURE: Build failed with an exception.
Build file 'projectpathbuild.gradle' line: 4
What went wrong:
A problem occurred evaluating root project 'ProjectName'.
> Could not find method jcenter() for arguments [] on repository container.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

i search for a solution and i see, this issue is due to AndroidStudio using old gradle, in which jcenter() is not supported. Not really sure about exact fix for this. But this following command worked fine,

project_path>gradlew -q :appName:dependencies
+--- project :simplecropimagelib
+--- project :library
| --- -> 6.5.87
| --- -> 21.0.2
| ---
--- (*)

*the appName you can see in settings.gradle file.

Hope it helps somebody…



Add jar as library to Project, Android Studio

Add Jar file to a Project in Android Studio

Here are the steps to add Jar file to a Project in Android Studio

  • Put the jar file into the libs folder

add jar

  • Right click on jar file¬†and select ‘Add as library’.


  • It’ll show a dialog showing modules in the project. Select a module to which you want add jar file.


  • Android Studio, automatically writes compile files('libs/<yourjarfile>.jar'); in gradle file dependencies and starts syncing and build file. And you are ready to use jar file classes.
  • If you see any issues, do a clean build might fix the issue.

Hope it helps somebody…

ūüôā Multiple dex files define, Android Studio

After moving an Eclipse project to Android Studio work space, and build project (Make Project), I see Build successful but when I run the project… I get the following exception,¬† Multiple dex files define

Multiple dex files

Error:Execution failed for task ':<projectname>:dexDebug'.
> Failed to run command:
<home>AppDataLocalAndroidsdkbuild-tools21.1.2dx.bat --dex --no-optimize --output <home>AndroidStudioProjects<projectpath>buildintermediatesdexdebug --input-list=<home>AndroidStudioProjects<projectpath>buildintermediatestmpdexdebuginputList.txt
Error Code:2
Output: UNEXPECTED TOP-LEVEL EXCEPTION: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;

after so much of struggle I found the issue is with dependencies of project gradle build file

dependencies {
compile project(':simplecropimagelib')
compile project(':library')
compile ''
compile files('libs/acra-4.5.0.jar')
compile files('libs/android-support-v13.jar')
compile files('libs/core.jar')
compile files('libs/httpmime-4.2.3.jar')
compile files('libs/opencsv-2.3.jar')
compile files('libs/xstream-for-android-1.0.0.jar')
compile files('libs/zxingjar.jar')
compile ''

I find, this error occurs when you have the same library/directory included more than once in your build.gradle’s dependencies.
and in the above code, the issue is due to this line

compile files('libs/android-support-v13.jar')

which is included by other library project.

So, I just commented that line and run the Project, fixed the issue.

Hope it helps somebody… cheers.. ūüôā

note: If the dependency is declared as a dynamic version (like 1.+), Gradle will resolve this to the newest available static version (like 1.2) in the repository.

Useful Keymap Shortcuts and Settings Android Studio Tips

Hi Guys,
As an Android developer, At a point of time we must have hardly move to Android Studio IDE, as Google no more supporting ADT with Eclipse. As a beginner to Android Studio its hard to find and understand some of keymap shortcuts and settings in it, which are completely different from ADT Eclipse keymaps. Here are few Android Studio Tips, Keymap shortcuts and settings useful for a developer.

Javadoc comments

  • To generate javadoc comments,
    type /** and then press Enter key over a method generates a comment

Organize imports

  • To organize imports,¬†Ctrl + Alt+ O and at times it may not work as expected.
    So, Go to Settings-> and in IDE  settings panel expand Editor -> Auto Import -> Java and make the following changes:
    change Insert imports on paste value to All
    mark Add unambiguous imports on the fly option as checked


 Power save mode

  • If you are not seeing red underline for code errors as ¬†highlighted code, you may be turn ¬†on¬†Power save mode
    So, Go to File-> uncheck Power Save mode


Line numbers

  • If you want to see Line numbers in a code file you can turn on/off by right clicking on workspace left border and Check Show Line Numbers. This applies only for the active file. And these Line numbers will disappears if you close file.


  • ¬†If you want to see Line numbers permanently Go to File-> Settings-> left panel in IDE Settings expand Editor-> select Appearance-> and on right panel¬†check Show line numbers


Quick definition lookup

  • To open a quick definition lookup, i.e. If you want to see the full method implementation when mouse hover on a method call statement, press Ctrl+Shift+I. below is sample screenshot



  • For single line Comments/UnComments press Ctrl + /
    For multi line Comments/UnComments press Ctrl + Shift + /


  • To format code with correct indentation press Ctrl + Alt + L¬†. This keymap works for Java, XML design files too.

Find All Usage

  • To Find(or Search) Usage of a variable¬†or¬†class or method in whole project, place cursor on that search variable or method or class, and press¬†Alt +F7. And you can see all occurrences of the searched item, in a tab opened at the bottom ¬†of editor.

Use soft wraps

  • To apply word wrap go to Settings-> in IDE Settings select Editor ->and in right panel check Use soft wraps in editor.


or you can just turn on/off word wrap by select as below..


Lower/Upper case

    • To apply Lower/Upper case for a text in WorkSpace editor, Select a text which need to Uppercase, and Press Ctrl+Shift+U, the text will changed to Uppercase, If you press again same keys, text will changed to Lower case.

Enable ADB Integration

    • If your appliation not showing in Debuggable Applications, you may not see your app log cat properly.app_not_recognizedto see your application in Debuggable applications drop down, you should Enable ADB Integration. Goto Tools-> Android-> Click Enable ADB Integration. You will see your app list in debuggable applicationstools_44

I’ll add more soon..

Hope it helps somebody.

You may be also interested in

‘gradle’ is not recognized as an internal or external command when installed Android Studio

‘gradle’ is not recognized as an internal or external command

While trying to run a gradle command, I see ‘gradle’ is not recognized as an internal or external command. It took me sometime to know the Gradle executable path, after installing Android Studio. Hence, thought to share so it may help somebody…

The gradle executable is usually installed here(when installed by Android-Studio):


<user_home_dir>, refers to the user directory, eg. C:Users/myuser

<version>, refers to installed gradle version number like 1.6 or 1.7 etc

the whole path looks like below


You have to set this kind of path in Environment variable PATH. And then close and reopen the cmd Prompt. Now you can able to run gradle commands

try, and you can see following details
>gradle -v
Gradle 1.6

Gradle build time: Tuesday, 7 May, 2013 9:12:14 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_21 (Oracle Corporation 23.21-b01)
OS: Windows 8 6.2 amd64


not recognized

You may be also interested in

Unmappable character for encoding UTF-8 in Android Studio

After importing project from eclipse into Android Studio i have got the following error Unmappable character for encoding UTF-8

Error: unmappable character for encoding UTF-8

Solution for Unmappable character for encoding

To fix this issue, in Android Studio, Open the File with the encoding issue. Go to File menu-> Select File Encoding ->
You’ll see a Drop down list of different Encodings, Select more ->

then Select UTF-8.

and then you will see a dialog with Reload and Convert buttons, Select Convert option.

Unmappable character
and build the project.

Solves the issue

Another way to change File Encoding is, ¬†You can see at the right bottom menu as shown in below image, click on it; displays a list of encodings. then just follow above steps…

And To convert File Encoding for whole project, Select Settings icon in menu bar

On left Panel  Goto Project Settings -> select File Encodings -> change the Project Encoding to UTF-8


Hope it helps somebody…

Cheers (Y)

You may also interested in