buildToolsVersion is not specified - android

I'm getting "Error: buildToolsVersion is not specified"
I've seen many people get this error but it has either been due to buildtooslversion not being specified in the module build.gradle or apply plugin being in the top level.
Top level build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
}
Module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.tst.test_app"
minSdkVersion 9
targetSdkVersion 28
}
}
dependencies {
compile project(':test_app_lib')
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-core:9.6.0'
}
apply plugin: 'com.google.gms.google-services'
It's been a year since I touched this code. I previously built ok. I updated android studio and SDKs and switch to target SDK28. That's pretty much all I changed.

add google() above jcenter() inside
repositories {
google()
jcenter()
}

You don't need to say which build tools are you using when you are using Android Pie
You only need to have something like this:
compileSdkVersion 28
defaultConfig {
applicationId "your.app"
minSdkVersion 18
targetSdkVersion 28
versionCode 0
versionName "1.0"
}
And please update your dependencies from compile to implementation, like this:
implementation 'com.google.firebase:firebase-core:16.0.3'
If your minSdkVersion is currently below 14, you will need to set it to 14 or higher. This is a limitation introduced in 26.

It ended up that buildToolsVersion was not specified in the LIBRARY (test_app_lib). When I added that, the error went away

Related

Android Gradle error while importing old project

I am importing one project which was created by another person a long time ago. And when I import I get these errors which I resolved but now I am stuck with this below error while syncing app Gradle file which I don't know how to resolve.
My build.gradle (app module)
buildscript {
repositories {
maven {
url 'http://repo1.maven.org/maven2'
}
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
repositories {
maven {
url 'https://github.com/donnfelker/mvn-repo/raw/master/'
}
maven {
url 'https://jitpack.io'
}
mavenLocal()
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "in.co.blab"
minSdkVersion 14
targetSdkVersion 22
versionCode 8
versionName "1.5"
multiDexEnabled true
resConfigs "en"
resConfigs "nodpi", "hdpi", "xhdpi", "xxhdpi"
}
}
What shall i do.
below is error
Error:Execution failed for task ':app:processDevDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
First, you need to change compileSdkVersion, buildToolsVersion, targetSdkVersion to same version. Change them to version 25:
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "in.co.blab"
minSdkVersion 14
targetSdkVersion 25
...
}
}
In case you're using Android Studio >= 3.0, change you build gradle tools to version 3.0.1 (you better move this to your project build.gradle):
buildscript {
repositories {
maven {
url 'http://repo1.maven.org/maven2'
}
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
and update your gradle inside gradle-wrapper.properties to gradle-4.1-all.zip.
Last, move the following line to the end of your app build.gradle:
apply plugin: 'com.google.gms.google-services'

Gradle sync error after changing build platform

When I opened my project it first said I had no build platform tools for version 26 which I changed to 25.0.3 now I am getting this issue:
Error:(22, 0) Could not find method android() for arguments
[build_83ss0a431bhzra8y3dug13x1y$_run_closure3#6184756f] on root
project 'AssetTrack' of type org.gradle.api.Project.
How to solve this issue can anybody help ?
This is my build.gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 22
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 21
}
productFlavors {
}
}
dependencies {
}
even all of dependencies are gone
Close Android Studio and manually navigate to your project's root directory from windows explorer. Open the file build.gradle with notepad and cut the android closure:
android {
compileSdkVersion 22
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 21
}
productFlavors {
}
}
Back to the project's root directory goto the /app folder. Open the build.gradle file with notepad and paste the android block there so that it becomes:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 21
}
productFlavors {
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
Finally, Open the Android Studio and sync the gradle.
Move these into your app.gradle file
android {
compileSdkVersion 22
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 21
}
productFlavors {
}
}
de

Can not import facebook-sdk 4.0.1

I have android studio 1.1.0 and i just created a new project and i'm trying to import new facebook-sdk 4.0.1 but can not do this, I followed Facebook Getting Started
But can not get it work. My app structure
My build.gradle(Project: MyApplication) file is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
//mavenCentral()
}
}
My build.gradle(Module: app) file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.hema.myapplication"
minSdkVersion 9
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.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
}
Finally the error message is:
Error:(28, 13) Failed to resolve: com.facebook.android:facebook-android-sdk:4.0.1
Show in File<br>Show in Project Structure dialog
Edit I added mavenCentral() in the repositories closure in build.gradle(Project: MyApplication) file but not working with same error message.
I solved the problem, It was in my Gradle settings >> Unchecked Offline work
Actually i got the same problem and i solved it ..
1 : File > Import Module ..find facebook-android-sdk-4.0.1 then Finish
2 : Go to File > Project sturucture > dependecies tab > Module Dependencies select :facebook
3 : SYNC project and Rebuild
IF you got error like Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION after rebuilding
go to facebook/build.gradle and change this part
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
to your sdk version like
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
Add mavenCentral() in the repositories closure in your build.gradle file and sync.
Connect your laptop or computer with Internet connection.
It happened with me. I tried everything but at last when I commented laptop with Internet connection it worked.

Android Studio: A mess of Gradle build versions and compilation errors

When I import projects from github into Android studio I see various errors related to the gradle version. For all the miseries of Eclipse I dont ever remember needing to do an upgrade every time to all sorts of different reasons. Usually it was SDK only.
I see a lot of errors along the lines of:
Error:failed to find Build Tools revision 21.1.0
Install Build Tools 21.1.0 and sync project
Failed to apply plugin [id 'com.android.application'] Gradle version 2.1 is required. Current version is 2.2.1. If using the gradlewrapper, try editing the distributionUrl in /Users/Mac1/Downloads/u2020-dagger2 /gradle/wrapper/gradle-wrapper.properties to gradle-2.1-all.zip
It seems odd that a system designed to reduce the complexity of dependencies would demand the installation of old versions of gradle or build tools. Why does this kind of thing happen. Does this mean it has no build tools or just not that version? Does it mean it must be the old version? It certainly seems to be encouraging backward compatibility by insisting in installing old versions of everything. Gradle, build tools etc. I don't mean to be rude, so I'll keep quiet about what I think of this. In the meantime, what are we supposed to do?
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
Here is project level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 21
buildToolsVersion '21.1.0'
defaultConfig {
applicationId 'dagger.demo'
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
}
First, make sure you have the latest Gradle version or atleast 2.2.1. Then update your build.gradle:
Top build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3' // <-- updated
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
App build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 22
buildToolsVersion '21.0.0'
defaultConfig {
applicationId 'dagger.demo'
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
}

Adding ActonBarSherlock in Android Studio

I am trying to add ActionBarSherlock to my existing app. This is not as easy as I thought. I have been doing this for two days now. I have tried every tutorial for 2 pages of Google results. Here is what I have after following this tutorial.
My project Structure
ActionBarSherlock/actionbarsherlock/ build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
ClashMMAProject/ClashMMA/ build.gradle
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
compile project(':libraries:ActionBarSherlock:actionbarsherlock')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
setting.gradle
include ':ClashMMA', ':libraries:ActionBarSherlock:actionbarsherlock'
Dependancies
My Error
I have done a lot of research and I can't get anything to work. I get an error every time, so there is something I don't understand correctly. Please help. Thanks for your time.
Update
Ok after the suggestions, this is what I have in ClashMMAProject/ClashMMA/ build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
This is producing an error:
Gradle: Execution failed for task ':ClashMMA:processDebugManifest'.
> Manifest merging failed. See console for more info.
I also struggled with this, as it seemed every tutorial or answer I followed left some small detail out that a beginner doesn't know as something to automatically do. Here is how I eventually got ABS added to my project:
1.Don't download ABS at all. You can completely add it by modifying your existing build.gradle file. Not your project's build.gradle, but your inner folder that is the parent folder of your src directory.
2.Open SDK Manager and make sure you have Android SDK Build-tools 18.0.1 (later versions might also work).
3.Model your build.gradle file after mine. This is the exact build.gradle file I am using that works. Make sure your minSdk and targetSdk match what is in your manifest:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
4.Make sure you are using gradle 1.8 in gradle-wrapper.properties:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
5.Sync project with gradle files by pressing the button:
The ActionBarSherlock author has provided a .aar file, so you will no longer need to build the library that you have in your libraries folder. You can change your build.gradle to be something like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/Parse-1.3.1.jar')
}
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Note the actionbarsherlock aar file in dependencies, and the removal of the library dependency. (I also see that your gradle is at 0.5.+ and your buildToolsVersion is at "17.0.0", the most recent versions are 0.6.+ and "18.1.1", but you can work on those once ABS is working for you).
Now you can safely remove your libraries/ActionBarSherlock, which you will no longer need, and change your settings.gradle file to:
include ':ClashMMA'
Hope this helps.

Categories

Resources