Hakan Ergin
Hakan Ergin

Reputation: 13

How to import project to Android Studio

I have this repository ( https://github.com/udacity/Just-Java/tree/Lesson_2 ) that I'm trying to import. I extract the folder from the zip file that I downloaded from there. Then I try to use "import project" function on Android Studio, but I am not sure which exact folder/directory to select for import. When I use the main directory I unzipped, it takes about half an hour to load it and then gives me an error saying "failed to find target with hash string 'android-24' in: [i]my appdata folder[/i]

I have very slow connection at the moment, so it takes ages to download this Android SDK Platrom 24. I am running the latest version of the Android Studio.

Upvotes: 1

Views: 98

Answers (2)

AAryan
AAryan

Reputation: 20140

This is your app module build.gradle file, change in this file according to what you have in your SDK.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24           // Change what SDK Version you have
    buildToolsVersion "24.0.2"     // Change buildTool Version

    defaultConfig {
        applicationId "com.example.android.justjava"
        minSdkVersion 15
        targetSdkVersion 24         // Change targetSDK, can be same as compileSdk
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.0'  //Change appcompact version
}

Upvotes: 0

niknak
niknak

Reputation: 146

So the 'build.gradle' file (Assuming you are using gradle) would specify which is the target Android SDK.

Now I suppose you have some Android SDK and the corresponding build tools already installed. These would then not require a download. But then gradle requires an internet connection to actually search for libraries that it should download to satisfy the dependencies of the project.

Now once you have figured out which Android SDK and build tools you have, you can make the change in the build.gradle file. (This would be in the /app/). You would have to make an edit here.

       compileSdkVersion 21 *replace with the version you have*
       buildToolsVersion "21.1.2" *this should also start with the compileSdkVersion number*

Hope this helps!

Upvotes: 2

Related Questions