How to import android existing android project (or) non gradle project (or) android example project in android studio


So you have downloaded some sample android project , trying it to import into Android Studio to run it right, however android studio doesn't import so easily, you have make some customization to run it, follow these below steps to import non-gradle project into gradle project



  • First Download any sample project unzip it and copy to our workspace folder
  • Then, go to Android Studio click file --> import project --> select your downloaded folder --> ok
  • Then, make a settings.gradle file and copy this
  • include ':Name of your project'
  • Then, make a local.properties file to include your sdk path, all projects in my android studio link to below sdk path, so edit and change this to your path
  • sdk.dir=/home/umidtech/android-studio/sdk
  • Then,last but not the least make a build.gradle file and copy this
  • buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.0'
        }
    }
    apply plugin: 'android'
    
    repositories {
        mavenCentral()
    }
    
    
    
    android {
        compileSdkVersion 17
        buildToolsVersion "18.1.0"
    
        defaultConfig {
            minSdkVersion 7
            targetSdkVersion 17
        }
    
        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/
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src//... 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')
        }
    }
    
    dependencies {
    
        compile 'com.android.support:support-v4:18.0.+'
    }
    
  • In the above build.gradle file change your dependencies and other tools according to your project
  • Then, click on "sync project with project file" (or) build your gradle file.

Comments

Popular posts from this blog

How To Record Audio in Moto G Without Any Third Party Apps

How to Unistall Software (or) Programs in Ubuntu Using the Terminal

All the Questions Answered About Rs.500 and Rs.1000 In this Frequently Asked Question Document