Skip to content

bug(android) plugin built with wrong sdk/tools versions #1123

@NickIliev

Description

@NickIliev

From @farfromrefug on July 25, 2018 15:27

I have a plugin which needs the very last support library.
Consequently I set up include.gradle with the correct version. You can see it here

However when I build through my app it fails because the plugin is built with the wrong versions.
If I print the corresponding gradle call:

/gradlew -p /myappfolder/platforms/tempPlugin/nativescript_material_components assembleRelease -PcompileSdk=android-27 -PbuildToolsVersion=27.0.3 -PsupportVersion=26.0.0-alpha1

The build.gradle within the temp folder does not take into account the targetSDk or compileSDKVersion that I have set-up in include.gradle. Only the dependencies are correct.


buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

apply plugin: 'com.android.library'

def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : 24 }
def computeBuildToolsVersion = { ->
    project.hasProperty("buildToolsVersion") ? buildToolsVersion : "27.0.3"
}

android {
    compileSdkVersion computeCompileSdkVersion()
    buildToolsVersion computeBuildToolsVersion()

    defaultConfig {
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
}

dependencies {
    def supportVer = "27.0.1"
    if (project.hasProperty("supportVersion")) {
        supportVer = supportVersion
    }
    compileOnly "com.android.support:support-v4:$supportVer"
    compileOnly "com.android.support:appcompat-v7:$supportVer"
}

dependencies {
    compile "com.android.support:appcompat-v7:28+"
    compile 'com.android.support:design:28+'
}

That build.gradle should have targetSDKVersion, compileSDKVersion, buildToolsVersion setup in that order:

  • if the app app.gradle has a version use this one
  • if not and if the plugin has a version, use the plugin version
  • use the default version

BTW in the default app `build.gradle``` the applying

The order should be

setAppIdentifier()
    applyPluginGradleConfigurations()
    applyAppGradleConfiguration()

User app configuration should always overrule.

Right now I can't seem to find a way to compile my app with that module. Any help would be appreciated

Thanks

Copied from original issue: NativeScript/nativescript-cli#3773

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions