question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
farfromrefugcommented, Dec 20, 2018

This is fixed in latest cli versions

1reaction
rosen-vladimirovcommented, Sep 27, 2018

Hey @farfromrefug , We are still testing the behavior and issues that might occur with the current case. But yes, you should be able to use it in a plugin. You can also set the following in your app.gradle (at the root fo the file):

project.ext.supportVersion = 28.0.0

In case you want to set it from a plugin, I recommend you to put something like this in your include.gradle:

def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "28.0.0"
// You can also add some check here that the `supportVersion` is at least 28.0.0
dependencies {
	compile "com.android.support:appcompat-v7:$supportVersion"
	compile "com.android.support:recyclerview-v7:$supportVersion"
}

Using the code above will allow the application author to control the version from a single place (project’s app.gradle for example).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Known issues with Android Studio and Android Gradle Plugin
To fix this issue, upgrade your Android 11 emulator to version 9 or higher by navigating to Tools > SDK Manager. In the...
Read more >
Android Studio error "Installed Build Tools revision 31.0.0 is ...
In SDK Manager, deselect 31.0.0 and try installing an older version (e.g., I've tried 30.0.3) and update "buildToolsVersion" in build.gradle to ...
Read more >
Android SDK tools are corrupted - Visual Studio Feedback
Hello! Using lastest version of macOS hosted agent, and trying to build an Android App with cordova, I'm getting the following issue: Build-tool...
Read more >
How to Fix “Failed to install the following Android SDK ...
Step 1: In Android Studio go to Tools > SDK Manager. Step 2: Go to the SDK Tools tab as shown in the...
Read more >
Gradle build fails with build tools 31.0.0 - Unity Forum
Android Gradle Plugin 4.0.1 used in all latest Unity 2020LTS, 2021.1 and 2021.2 versions does not work with Android SDK build-tools version ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found