How to change build tools version in Android Studio 3.0.1? - android-studio

I just upgraded my Android studio from 2.3 to 3.0.1. But I get this error message(I have already installed API 27 ) and don't know how to fix it, because I couldn't find the the build tools version in new version of android studio!
Error:Failed to find Build Tools revision 26.0.2 Install Build Tools 26.0.2 and sync project
The gradle files are changed, also the project structure has only one tab!
Edit:
this is the content of `app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.m.finalocr"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
As you can see, there is no buildToolsVersion in it. So, why my android studio looks for this specific version(26) of that when I have the 27 version installed on my computer? Also, where can I see the buildToolsVersion "26.0.2" and change it tobuildToolsVersion "27.0.3" ` ?

Your project is looking for Build Tools version 26.0.2, but you haven't yet downloaded and installed it on your computer.
To download it, go to Tools > Android > SDK Manager, then click on the "SDK Tools" tab at the top of the new window. Then select the "Show Package Details" checkbox in the lower right-hand corner. Finally, scroll down to where you see 26.0.2, check the checkbox next to it, and click "OK" to begin the install process.
If you want to change the Build Tools version in your project, that is specified in project's build.gradle file (in the 'app' module). Open the file and either add or update the Build Tools version you want to use by adding/updating the following property in the 'android' section:
android {
buildToolsVersion "27.0.3"
...
}

Related

how to get compileSdkVersion equal or higer than the options shown

I'm making an app with ads in it with AdMob: https://developers.google.com/admob/android/quick-start?hl=he.
In order to that I need a "compileSdkVersion 28 or higher", so when I tried to change it by doing:
right-click on "app" > open module settings > compile SDK version, I was shown that the maximum option is: compile SDK version 27, and not 28 the minimum requirements for Google AdMob
also here is my build.gradle(Module: app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.admin.minesweeperyannai"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-ads:19.4.0'//Google AdMob dependency
}
Also, I checked on their website and found out that I cant use lower versions than 19.4.0 or 18.1.0 (I didn't understand which one is the minimum but both of them didn't work).
This is the error I get when I try to use one of those versions:
error: failed linking references.
And I know my code is good because I've tried using the version: "play-services-ads 17.1.1" and it worked but only with test ads and not real ads, so to sum up I would like to know how to get Compile Sdk Version 28 or higher in order to show ads on my app.
This menu showing you the versions that you already installed it
so to get version 28 or 29 you need to install it
The first option is to change it from build.gradle file for example
android
compileSdkVersion 29
defaultConfig {
.....
minSdkVersion 21
targetSdkVersion 29
}
....
}
Or from SDK Manager select show package details and install Android SDK Platform 28 or 29 then select it from the Compile Sdk Version menu

Android studio AAPT: error failed writing to R.txt: the data is invalid

I am having an issue with building new projects on android studio. I keep on getting the error:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
AAPT: error: failed writing to 'D:\Libraries\Documents\AndroidStudio\SocketTest\app\build\intermediates\runtime_symbol_list\debug\R.txt': The data is invalid. (13).
Here is my project build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.sockettest"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
This problem only occurs on new projects I try to build and isn't an issue on older ones.
I have read through R.txt': The data is invalid. (13) which leads to Long package name build error in Android Studio which still does not solve the problem.
I only encounter this issue while using windows 10 (update 1909), and not while using android studio on ubuntu. I am running android studio version 3.6.2
I know this is a year late but could it be an antivirus blocking it? This is what Avast came up with:
In case someone new to android studios like me does not know how to downgrade Gradle and plugin, here's how (windows):
Select File>Project Structure.
Type in (3.6.3) the Android Gradle Plugin Version.
Type/select (6.0) from dropdown menu the Gradle Version.
Hit OK to Save.
Android Studios will download and set up the new Gradle for the current project. This resolved the data is invalid error for me.
Was getting the same error. I realized it had something to do with the Gradle version I was running, even though I usually stick to the stable channel of releases. I ended up downgrading to plugin version: 3.6.3 & Gradle version 6.0. I had previously been on plugin version 4.0.0 & Gradle version 6.1.1.
I don't know if this was for sure the same issue, this was happening to any projects on my Win10 PC (ver 2004) that were running that Gradle version.
Please follow this :
Uninstall your System(Windows OS)anti virus and most probably it will work.
I already solved by adding this in my dependency
implementation 'com.android.support:design:28.+'
I had a similar issue trying to build an ionic capacitor app with android studio. I later discovered that one of the directories' names in the project's path has space in the name.
I just copied the project into another directory to form a path that has no space and recompiled the project and the error vernished.

can't get gradle to accept java-client-6.0.0-BETA1.jar in android studio 3

I'm new to android studio. I'm trying to get Android Studio Gradle to build with appium's java-client-6.0.0-BETA1.jar. I'm implementing appium. I believe android studio is install right. I've downloaded the recommended files for appium, selenium-server-standalone-3.8.1.jar, selenium-remote-driver.jar, selenium-java-3.8.1.zip and anything else I can see needed. Appium server is installed and working. An android emulator is running and working.
I get this error:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Repositories\ApkProjects\EndToEndAndroidTest\app\libs\java-client-6.0.0-BETA1.jar
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:550)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.lambda$convertToDexArchive$1(DexArchiveBuilderTransform.java:488)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing io/appium/java_client/touch/TapOptions.class
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
I've tried the recommended fix - makes no difference. I've updated guava-23.3-android also which was giving similar errors.
The gradle.build file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.nwri.endtoendandroidtest"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// compile 'com.google.guava:guava:23.3-android'
}
I've searched the web and can't find anyone having this issue. Here is a screen shot if that helps:
Android studio
Setting Source Compatibility and Target Compatibility to 1.8 in Project Structure dialog helped me.
While manual adding
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
did not help.

android clicking debug chooses release variant

In Android Studio, when I click the "debug" icon in the tool bar, gradle is appearing to try to make a release build.
First, it shows me the "edit configuration" popup. At the bottom, it has a message "the apk for your currently selected variant (app-release-unsigned.apk) is not signed. Please specify a signing configuration for this variant (release).
Why is it trying to use "release" when I click "debug"? Obviously I changed something, I wish I knew what...
Here's my app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
compileOptions.encoding = 'UTF-8'
defaultConfig {
applicationId "com.perinote.camera"
minSdkVersion 15
targetSdkVersion 24
renderscriptTargetApi 20
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:support-v4:24.0.0'
testCompile 'junit:junit:4.12'
}
Solved by deleting the .idea directory. After it was regenerated, my builds were correctly produced.
I also completely removed and reinstalled Android Studio and the SDK. However, the debug build was still messed up after that.

New Android Studio + New project - Failed to resolve

I am trying to make my first Android App.
Downloaded and installed the Android Studio, and followed the tutorial to start a new simple "Hello world" app, just to get started, and see that everything works.
But it does not.
I have not written one single line of code myself, so the source is completely generated by Android Studio itself.
I get this error:
Failed to resolve: com.android.support:appcompat-v7:25.+
and
Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
When creating the project, I choose API level 15.
In the SDK manager, I have both API level 15 and 25 installed ( I think 25 was default installed, and I have installed API 15 or vice versa).
I have googled a lot, and tried different SDK's, but always the same error. No matter what versions I try to use, it fails with the same message.
Why doesn't the very first tutorial work?
I am a bit confused, if it is so difficult to make the first "Hello world" app :0)
Screenshor of error
Thanks in advance !
Go to File -> Settings -> Build,Execution,Deployment -> Build Tools -> Gradle and then uncheck Offline and then resync the project and rebuild even if all of the above doesn't work try reinstalling the whole setup
#Rahul
Here is the Screenshot of my Tools installed.
Google Repository installed too
Screenshot of Tools
#Rahul Kumar
My build.gradle below.
Project is created using API 15 as minimum.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "dk.surlution.app3"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.+'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
}

Resources