-3

I have project which needs to be ported in Gradle build, I have done most of work but not able to change the target SDK for the build, since my application is heavily dependent on third party SDK. It is present in addons directory of SDK manager.

Here is the Eclipse project structure

eclipse structure

project build target in eclipse is

project build target eclipse

The Gradle project structure is

gradle structure

build.gradle in app directory

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.name.appname"
        minSdkVersion 15
        targetSdkVersion 22
        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:22.2.1'
}

I have following queries

  1. Where to make the changes in which file or directory?

  2. Do I need to add addon library sdk in the gradle build, If yes, then where??

Thank you for being helpful and down voting, at-least explain why you down voted.

Akhil Jain
  • 12,808
  • 13
  • 51
  • 88
  • Is this a library project you are using with full source code or are you including it as a precompiled @AAR via your gradle file? – Kuffs Jul 27 '15 at 11:19
  • http://stackoverflow.com/questions/19465049/changing-api-level-android-studio try this once. – RamBabu Pudari Jul 27 '15 at 11:22
  • @RamBabuPudari : the answer you suggested no where contain option to change build target, NOT the android sdk version number. – Akhil Jain Jul 27 '15 at 11:29
  • @Kuffs no it is not library project, its not aar. It is actually Addon from 3rd party vendor. Just so you understand have added the 3rd party sdk/addon in "addon directory" of sdk manager like google api addons. hope i am clear – Akhil Jain Jul 27 '15 at 11:32
  • Looks like the addon is already compiled and so you cannot change the build target as it does not get built. – Kuffs Jul 27 '15 at 12:05
  • @Kuffs what can I do?? how to fix these? – Akhil Jain Jul 27 '15 at 12:05
  • Why would you want to change it? Does it not work as it is? If it does not then contact the developer and request an updated version. – Kuffs Jul 27 '15 at 12:08
  • @Kuffs It works in eclipse/ ADT. But, I am porting the project to gradle build. So I don't know or figure out how to change project build target in Android Studio. No it does not work in android studio as it is not able to file necessary file present in 3rd party SDK – Akhil Jain Jul 27 '15 at 12:15
  • Again I would contact the developer or read the documentation to see how to implement the library using Gradle.Most likely you would need to use the "Dependencies" tab of the "Project Structure" dialog within Android Studio. (Right click project and choose "Open Module Settings") – Kuffs Jul 27 '15 at 12:22
  • @Kuffs: thanks for all the help :) , I will see what I can do. – Akhil Jain Jul 27 '15 at 12:24

2 Answers2

2

This is what need to change in order to compile through different sdk, In your build.gradle present in app directory. E.g \app\build.gradle

Change the compileSdkVersion. For eg

android {
    compileSdkVersion 'TazTag:TazPad3 Add-On tuvalu_01.01.346:16'
    // the sdk version mentioned above is the sdk which you want to add
    // please specify correct sdk to build with
    buildToolsVersion "22.0.1"
}

Use compileSdkVersion to number when you are going for Android as project target.

Thank you to all who down-voted, without even understanding the problem, you helped me...I did by myself.

Feel free to query if you anyone have trouble regarding the solution.

Akhil Jain
  • 12,808
  • 13
  • 51
  • 88
  • Do I have to change only **compileSdkVersion**? What are **buildToolsVersion** and **targetSdkVersion** in *defaultConfig*, should I leave them as they are? – Shaharyar May 15 '16 at 12:47
0

You need to change the value for targetSdkVersion on your app build.gradle file.

defaultConfig {
        applicationId "uk.co.myapp"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
Nilanchal
  • 5,842
  • 8
  • 39
  • 69