Android beginner here...
I'm getting all sort of rendering errors, and eventually concluded it's got something to do with my gradle dependencies.
Now I found a nice tutorial which I've been following, http://www.android4devs.com/2015/06/navigation-view-material-design-support.html but I'm running to a problem extending it further, and there is something I don't think I understand.
Should I not be using the latest stable version of any library I can? Surely these libraries are backwards compatible?
If I am supposed to use the older version of library, to match the compile sdk (which I understand to mean I'm compiling for backwards compatibility, and supporting, say, lollipop API 21-22) then:
I would need a place to see a complete list of all versions of all libraries (which I cannot find), and
I would not be able to use new features like RecyclerView which only came in at Marshmallow API 23.
Am I missing something?
build.gradle (module app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.myFirstApp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
...
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
Error message
The support library should not use a different version (26) than the compile sdk version (22).
You are using
compileSdkVersion 22
and
compile 'com.android.support:appcompat-v7:26.1.0'
error you are getting is because you are using compat version 26 while compileSdkversion is 22
You should update to compileSdkVersion to 26 and android studio will download required files so that your error will be removed. If you cannot update your compilesdk version to 26. Then change support library version to 22.2.1
compile 'com.android.support:appcompat-v7:22.2.1'
Got list of support libraries from link
https://developer.android.com/topic/libraries/support-library/rev-archive.html
and
https://developer.android.com/topic/libraries/support-library/revisions.html
Related
I have just finished working with my android project and decided to publish it on Google Play Store. When I uploaded the signed APK file in the production tab of Google Play Console, I faced the following issue:
Here is the gradle information:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.parma.torupee"
minSdkVersion 26
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(include: ['*.jar'], dir: 'libs')
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.android.support:design:26.1.0'
compile 'com.jjoe64:graphview:4.2.1'
}
I have developed the application in Android Studio 3.0.1(did not update). I tried changing the targeted SDK to 29 but then I received errors for implementation 'com.android.support:appcompat-v7:26.1.0' and implementation 'com.android.support:design:26.1.0' lines in the gradle file.
How can I change the target SDK to 29 such that it supports the latest version and also support API level 26(Oreo)? Any help would be highly appreciated!
Compile SDK Version
The Compile SDK Version is the version of Android in which you write code. If you choose 9, you can write code with all the APIs in version 28.
Minimum SDK Version
Android operating system (OS) versions are backward-compatible. If your minSdkVersion is set to Android version 22, your application will run on Lolipop (5.1) and above .
Target SDK Version
You should set the targetSdkVersion to the most recent version of Android that you have tested on.
Whenever a new version of Android comes out, you will want to update the targetSdkVersion to the latest Android version and test your app to fix any problems. If you don’t google may force you to update it. This allows you to use the new security patches commonly applied for most of the OS versions.
Increasing your target sdk doesnt affect the minimum version number you have defined.
EDITED : Updated comment on support library
If you want to update your target SDK to 28 then it might be easier as you could use the below support libraries
com.android.support:support-compat:28.0.0 but if you plan to use target sdk as 29 then you have to migrate all your support packages to androidx libraries .
https://developer.android.com/topic/libraries/support-library/packages
For easier migration you could follow the stesp give here https://developer.android.com/jetpack/androidx/migrate
Let me know if this helps
You could use:
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:29.0.0'
I'm getting the error:
WARN - ect.sync.idea.ProjectSetUpTask - Failed to find Build Tools revision 26.0.2
It is actually an error breaking my build but this wasn't copyable so I found this line in the log (the only place I could find reference to "26.0.2"
I've searched (Ctrl-Shift-F) for 26.0.2 everywhere and found just 2 occurrences of 26 in one file, the "app" level build.gradle:
android {
compileSdkVersion 26
defaultConfig {
targetSdkVersion 26
...
Which I changed to 27, my build tools is 27.0.3 which I use for other projects, I don't want another build tools. How can I communicate this to Android Studio?
Credit to https://stackoverflow.com/a/47425748/866333, I hope this offers easier sign posting:
android {
compileSdkVersion 27
// Add the following line, Android Studio is quite good for filtering bloat.
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
...
I actually had to add a line, so I don't know where AS was reading 26.0.2 from, but this fix has worked on 2 of my projects. Oh, and because I'm now using the support lib (because its 2018):
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
will be on the wrong versions, fix by replacing the 3 occurrences of "26.1.0" with, eg, "27.1.1", as that was what the error messages was hinting at.
I am facing a strange issue, i installed latest appcompat-v7:23.0.0
Where as i got to know i must not need it but i need to go with appcompat-v7:22.2.1 or appcompat-v7:22.0.0
I updated my gradle as per my needs but it always pickup appcompat-v7:23.0.0 which is not required, any one guide me how can i resolve this issue?
Since you are using
compile 'com.google.android.gms:play-services:+'
you are using the latest version compile 'com.google.android.gms:play-services:8.4.0' which has a dependency with support libraries v23.
You have to compile with API 23.
Change this line:
compileSdkVersion 23
If you don't want to use the api23 you can use a specific version like as
compile 'com.google.android.gms:play-services:7.8.0'
In general is not a good practice the use of + in your dependencies because you can't replicate the build in the future with the same libraries and you don't know which version you are using.
Also you can use api23 with Httpclient.
Just use:
android {
useLibrary 'org.apache.http.legacy'
}
More info here.
The useLibrary requires the gradle plugin 1.3.0 (classpath 'com.android.tools.build:gradle:1.3.0') or higher.
AppCompat (aka ActionBarCompat) started out as a backport of the
Android 4.0 ActionBar API for devices running on Gingerbread,
providing a common API layer on top of the backported implementation
and the framework implementation. AppCompat v21 delivers an API and
feature-set that is up-to-date with Android 5.0
You can use
compile 'com.android.support:appcompat-v7:22.0.1'
Finally
android {
compileSdkVersion 22
buildToolsVersion '22.0.1' // You can set buildToolsVersion '23.0.1'
Advice
You should use
compile 'com.google.android.gms:play-services:7.8.0' // or 8.4.0
Good Approach : Use latest Version .
you need to download the latest support repository from internal SDK
manager of Android Studio or from the stand alone SDK manager. Then
you can add compile 'com.android.support:appcompat-v7:23.0.1'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId ""
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0' // or 8.4.0
}
Edit
You can use this classpath
classpath 'com.android.tools.build:gradle:1.3.0'
Then Clean-Rebuild-Restart-Sync your project . Hope this helps .
I am trying to make runtime permissions backward compatible with older devices but using the support library i cant find checkSelfPermission() static call in ContextCompat class, but its documented here
Here is my project gradle settings:
defaultConfig {
applicationId "org.myprogram.cool"
minSdkVersion 16
targetSdkVersion 23
versionCode 39
versionName "3.0"
}
and here is the dependencies:
compile 'com.google.android.gms:play-services:+'
compile 'com.squareup:otto:1.3.5'
compile 'com.android.support:appcompat-v7:22.1.1'
any idea what i am missing ?
checkSelfPermission() didn't get introduced into the native Context until API 23. So you will need to use at least version 23.0.0 of the support library.
You should change this
compile 'com.android.support:appcompat-v7:22.1.1'
to this
compile 'com.android.support:appcompat-v7:23.0.1'
If you have migrated from eclipse adding the below line wont work
compile 'com.android.support:appcompat-v7:23.0.1'
While migrating, it adds appcompatv4 as an external dependent library.
Make sure you have deleted the appcompatv4 library from the libs folder and then it should start working
Make sure class exampleActivity class is extending from AppCompatActivity.
Make sure that your minSdkVersion is 23 in the build.gradle file.
Sync your gradle after making this change.
That should work.
Today, Google released SDK 6 API 23+.
I tried to create a project with the API 23, but I'm having the following problem:
Failed to resolve: com.android.support:appcompat-v7:23.0
Here's my gradle file:
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "my.package"
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'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:23.0'
compile 'com.google.android.gms:play-services:7.8.0'
}
In the SDK manager, the version 23 isn't listed to update:
How can I solve this?
Original answer:
I too tried to change the support library to "23". When I changed the targetSdkVersion to 23, Android Studio reported the following error:
This support library should not use a lower version (22) than the targetSdkVersion (23)
I simply changed:
compile 'com.android.support:appcompat-v7:23.0.0'
to
compile 'com.android.support:appcompat-v7:+'
Although this fixed my issue, you should not use dynamic versions. After a few hours the new support repository was available and it is currently 23.0.1.
Pro tip:
You can use double quotes and create a ${supportLibVersion} variable for simplicity. Example:
ext {
supportLibVersion = '23.1.1'
}
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:palette-v7:${supportLibVersion}"
compile "com.android.support:customtabs:${supportLibVersion}"
compile "com.android.support:gridlayout-v7:${supportLibVersion}"
source: https://twitter.com/manidesto/status/669195097947377664
As seen in the revision column of the Android SDK Manager, the latest published version of the Support Library is 22.2.1. You'll have to wait until 23.0.0 is published.
Edit: API 23 is already published. So u can use 23.0.0
Ran into a similar issue using React Native
> Could not find com.android.support:appcompat-v7:23.0.1.
the Support Libraries are Local Maven repository for Support Libraries
First you need to download the latest support repository (17 by the time I write this) from internal SDK manager of Android Studio or from the stand alone SDK manager. Then you can add compile 'com.android.support:appcompat-v7:23.0.0' or any other support library you want to your build.gradle file. (Don't forget the last .0)
Latest published version of the Support Library is 24.1.1, So you can use it like this,
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
Same as for other support components.
You can see the revisions here,
https://developer.android.com/topic/libraries/support-library/revisions.html