Android Studio is giving multiple errors since API 22 updated - android

I am getting multiple errors in my project, previously it was working fine. I tried may things changing the target api changing dependencies, i dont know why it is not working. Please help me out.

Change your build.gradle file to this,
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.name"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
.......
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:6.5.87'
}
Now clean and rebuild the project.

Related

Deleting cache did not solve Error:create service of type TaskArtifactStateRepository

Building this App.
I got the following error and tried solutions for deleting chache and .gradle files folder, but it is not solved.
Error:Could not create service of type TaskArtifactStateRepository using TaskExecutionServices.createTaskArtifactStateRepository().
> Unexpected lock protocol found in lock file. Expected 3, found 0.
build.gradle file(tried with tools version 26.~ too):
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "edu.cmu.sphinx.pocketsphinx"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.1"
}
}
dependencies {
implementation project(':aars')
implementation project(':models')
implementation 'com.android.support:appcompat-v7:27.1.1'
}

attr/colorError not found error when using com.android.support:recyclerview-v7:26.0.0-beta2

I'm using Android Studio 3.0 Canary 4. I imported the recycler view library. Then it comes out the attr/colorError not found message.
This is app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.robyn.myapplication"
minSdkVersion 19
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 {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:recyclerview-v7:26.0.0-beta2'
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
}
Whenever I add the two libraries implementation 'com.android.support:recyclerview-v7:26.0.0-beta2' and
implementation 'com.android.support:appcompat-v7:26.0.0-beta2', it comes out this error message:
I tried clean and rebuild, the error message is still there. I checked res/values/colors, the color values are there. Why I get this color error? If I want to use recycler view, what version of library should I import?
Change the following details it will work fine,
compileSdkVersion 26
buildToolsVersion "26.0.0-beta2"
Also upgrading compileSDKVersion and buildToolsVersion to 26 (it was 25) fixed the issue for me:
compileSdkVersion 26
buildToolsVersion '26.0.2'
...
dependencies {
...
compile 'com.android.support:appcompat-v7:26.0.2'
}
In general, make sure to keep all the versions consistent (compile, build, appcompat libraries).
This is to ensure compilation and stability on runtime (one can also see lint warning about the latter if lint finds differnet support library versions)
Revision 26.0.0 Beta 2
Please note that 26.0.0-beta2 is a pre-release version. Its API
surface is subject to change, and it does not necessarily include
features or bug fixes from the latest stable versions of Support
Library.
For your problem you can use "26.0.0-beta2" . It will be better if you use Stable Version .
pasting following code at Android/build.gradle bottom helped me:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
}
}
}
}
I've seen the same error when my app is on appcompat-26 and tries to include an Android library which in turn uses appcompat-25.
My solution has so far been to keep the app on 25 as well.
I have no idea if it's supposed to be like this. Surely you must be able to publish a library that uses the support lib version X and have it run in apps using support lib version X+1.
I am using AS 3.0-beta7 so maybe it's resolved on stable 3.0 which was released a few days ago.
Just change the minSdk:
e.g.:
android {
compileSdkVersion 26
buildToolsVersion "26.0.0-beta2"
defaultConfig {
applicationId "com.parse.starter"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
}
Hope this helps
I found this "attr/colorError" error occurred when I had created product flavours and had put the "legacy" after the "current" in my build.gradle (in "app" folder). When I put the "legacy" before the "current" (as shown below) then the error went away. Maybe the lower "versionCode" or "Sdk" versions need to appear first?
flavorDimensions "legacycurrent"
productFlavors {
legacy {
dimension "legacycurrent"
versionCode 98
minSdkVersion 9
targetSdkVersion 25
compileSdkVersion 25
}
current {
dimension "legacycurrent"
versionCode 99
minSdkVersion 14
targetSdkVersion 26
compileSdkVersion 26
}
}
FWW - For future searchers, I've added the code below to my root build.gradle to search down through dependencies and fix them to match my root project. There are probably caveats and reasons why this is a bad idea, but it consistently works for me.
subprojects {
afterEvaluate {subproject ->
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
this code in android/build.gradle fixed my error.
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 31
buildToolsVersion "30.0.2"
}
}
}
}

Changing minsdk version in android studio to enable use of RecyclerView

I am new to android development, and just learning. I am trying to create something with a RecyclerView, and the tutorial tells me I have to add these Gradle dependencies to my app's module:
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
When adding them to the build.gradle file, I get an error saying I have an incompatible compileSdkVersion. I changed compileSdkVersion 24 to compileSdkVersion 21 but the error doesn't go, and I get an error on these:
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
These are the rest of the settings that seem applicable to the sdk version in that file. Do I need to change any of those also in order to it to be compatible?
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "uk.ac.ncl.legacymakingv4"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
You should always use the same version of everything in the com.android.support group. Therefore change your cardview and recyclerview to use the same 24.0.0 version.

Android studio compiledsdkversion 23 is not working

I have recently updated android studio which brought me many problems.
whenever I create a new android project the gradle scripts(Module:app) is displaying the below code
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.listproject"
minSdkVersion 17
targetSdkVersion 23
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:23.+'
}
here the above compiledsdkversion 23 provides me
Error:Failed to find: com.android.support:appcompat-v7:23.+ Open
File:open.dependency.in.project.structure">Open in Project Structure
dialog
Because before upgrading I had compiledsdkversion as 21 and it does not provide any problem in gradle sync task.
But when I manually modified the compiledsdkversion to 21 it worked correctly.But every time when I create a new project it has been set to 23.Is there any way to make 21 as default or any corrections for compiledsdkversion 23 itself.
I have another doubt before upgradation my restful services projects worked correctly after this upgradation I am facing many problems.
Even HelloWorld application is not running.But if I manually change the compiledsdkversion to 21 everything is fine.Please provide me a solution for making the compiledsdkversion to 21 by default.
> compile 'com.android.support:appcompat-v7:23.+'
The "+" in "v7:23.+" means to take the newest "v7:23" version. If you have no internetconnection this fails.
either reestablish an internetconnection while building or replace the package with a fixed versionnumber that your system has locally cached when there was an internet conntection (i.e. com.android.support:appcompat-v7:23.0.1)
You are using the appcompat (and other support libraries) v23, please compile your project with API 23.
Change in your build.gradle the compileSdkVersion to 23

error while importing stackblue into Android Studio project

I'm trying to import and add android stackblur into a android studio project, but it is missing the ScriptC_blur class.
I also added the following values to build.gradle for android gradle plugin v0.14.1. However, it doesn't resolve the issue
android {
compileSdkVersion 21
buildToolsVersion '21.1.0'
defaultConfig {
...
minSdkVersion 11
targetSdkVersion 21
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
...
dependencies {
...
compile files('libs/renderscript-v8.jar')
...
}
}
I also followed this thread, but I had no luck to get it to work. Any advice and suggestions will be greatly appreciated

Categories

Resources