I have been trying to bring back an old app of mine, that I wrote a while back using eclipse. I imported to android-studio and I it complains about colliding versions:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 28.0.0-alpha1, 27.1.0. Examples include
com.android.support:animated-vector-drawable:28.0.0-alpha1 and
com.android.support:cardview-v7:27.1.0
At first, I solved it as suggested by this question, by including the colliding packages specifically in the gradle file with the newer version. So my gradle file ended up like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.tomklino.imhere"
minSdkVersion 16
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:customtabs:27.1.0'
implementation 'com.android.support:support-media-compat:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation "com.google.android.gms:play-services-gcm:11.8.0"
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
}
apply plugin: 'com.google.gms.google-services'
}
This removed the red line from under the appcompat line, but then, after debugging something else, I got the message above again, but this time with the version 28.0.0-alpha1. Now I can't include the new version, because if I try it says it is incompatible with the sdk version of 27.
I'm trying to understand why it asks for that version in the first place if I havn't included that sdk version anywhere. Nothing in the dependency tree asks for the 28.0.0-alpha1 version specifically.
but then, after debugging something else, I got the message above again, but this time with the version 28.0.0-alpha1
Replace:
implementation 'com.android.support:appcompat-v7:+'
with:
implementation 'com.android.support:appcompat-v7:27.1.0'
and resolve to stop using + for the entire version of an artifact.
I'm trying to understand why it asks for that version in the first place if I havn't included that sdk version anywhere.
You used + for the version of appcompat-v7. This says that you want the latest that Gradle can find. And, last week, Google released 28.0.0-alpha1, in tandem with the release of the Android P Developer Preview 1.
I had the same issue, but no of dependencies had '+' in version number.
Problem was in xwalk (Crosswalk WebView) library.
I've solved it by adding 'transitive':
compile ('org.xwalk:xwalk_core_library:23.53.589.4') {
transitive = true;
}
Related
I am getting the above error
My gradle looks like this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.hypersignwalletcorekotlin"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
project.ext {
walletcore_version = "2.0.5"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.trustwallet:wallet-core:$walletcore_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Not able to understand why is this happening.
Thanks
The Fix:
add ndkVersion to your module's build.gradle
android.ndkVersion "your-installed-ndk-version"
as in some examples. You could find your NDK version from the file $NDK/source.properties.
Background Info:
You probably using AGP/Android Studio version 3.6+: "From Android Gradle Plugin ( AGP ) 3.6+, there is a known good NDK concept added, which is the known good/tested NDK version when that AGP version was released". AGP will use that internal NDK version if:
you are not using the ndkVersion feature added in AGP 3.5
That internal NDKs are expected to be installed as side-by-side NDK place:
$SDK\ndk
if not installed:
AGP 3.6, AGP 4.0 will error out
AGP 4.1 would auto install it.
The internally embedded NDK version, most likely, will be out-of-date pretty quickly as newer NDKs are constantly being released: if you want to use a newer NDK version, you do need to configure gradle with ndkVersion.
Additional Doc:
Refer to the official documentation for details.
To install a specific version of the NDK, do the following:
With a project open, click Tools > SDK Manager.
Click the SDK Tools tab.
Select the Show Package Details checkbox.
Select the NDK (Side by side) checkbox and the checkboxes below it that correspond to the NDK versions you want to install. Android Studio installs all versions of the NDK in the android-sdk/ndk/ directory.
I do not use NDK, but still got this error. Clean project worked for me.
Build -> "Clean Project" and then rebuild.
That error happened to me when I run cordova build with Android Studio open. :D
I closed it and that's it.
You need to click the tool on above the bar option. Then you need to download the current ndk if not installed.
I just create a new emulator using the newest Android Studio version. It solved my problem. Hopefully, it may be an alternative...
Install NDK from SDK Manager -> SDK tools
and then just add this line in the android/app/build.gradle
android{
ndkVersion flutter.ndkVersion
}
You can install only the NDK that you need.
Go SDK Manager -> SDK tools -> Click in Show Package Details
Click and install.
This question already has answers here:
Android Studio keeps refusing to resolve com.android.support:appcompat-v7:29.0.1
(6 answers)
Closed 3 years ago.
I'm at the newest level on Android. just boot up a new project and got error on the Gradle Build with Pie ( Android v9.0):
Unable to resolve dependency for
':app#debugAndroidTest/compileClasspath': Could not find any version
that matches com.android.support:appcompat-v7:29.+.
this is my build.gradle (Module:app):
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 28
targetSdkVersion 29
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:29.+'
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'
}
How do I do next?
You are using support library which was last released for API 28 but you are trying to find API 29 version of this library. API 29 version of this library was moved to another library called AndroidX.
Goto Menu bar in Android Studio, Select Refactor then Migrate to AndroidX, that should solve the issue.
This will replace any old support library packages that you are using with newer AndroidX versions.
If you get any error in your dependencies after Migrating, find your dependency packages from the following lik and replace them with the newer ones listed in table:
https://developer.android.com/jetpack/androidx/migrate
Try migrating to Androidx
Android Studio > Refactor Menu > Migrate to AndroidX...
From docs:
With the release of Android 9.0 (API level 28) there is a new version
of the support library called AndroidX which is part of Jetpack. The
AndroidX library contains the existing support library and also
includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts
(those versioned 27 and earlier, and packaged as android.support.*)
will remain available on Google Maven. However, all new library
development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well.
So I've just hit the maximum method count limit for my android project, which fails to build with the following error message:
Error: null, Cannot fit requested classes in a single dex file (# methods: 117407 > 65536)
I understand what the message means, and how to resolve it (running proguard, enabling multidex etc). My problem is that I don't understand why I'm suddenly getting this message - I was doing was removing some old bits of code which were redundant, hit build, and now I get this message.
Question 1: How can it be possible that my method count (117407 according to the error message) is suddenly massively over the limit (65536), even though I did not add any library dependencies? I actually removed code, and suddenly I have like 50 thousand methods too many?
Now this is where it gets really weird: I wanted to analyse the APK to figure out what's causing the problem, but of course I can't build it. So instead of enabling multidex I decided to revert my code to yesterday (which definitely absolutely did build fine yesterday - I have the app on my phone to prove it!), but I still get this build error message. I don't understand how this is possible. I tried reverting to several days ago, same thing (cloning a new repo and checking out an earlier commit).
So, question 2: How am I getting this build error for the exact same code which just yesterday built fine without error?
The only thing I can think of is that a library that I am using as a dependency has suddenly increased in size - but I'm declaring specific versions of everything in my gradle build, for example:
// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
So, surely my dependencies should not have changed?
Any ideas what I can do to figure this out are greatly appreciated. I've tried cleaning my project, and invalidating caches/restart in android studio. I really don't want to enable multidex or have to run proguard on my debug build.
Here's the full build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "XXXXXXXXX"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true // see https://developer.android.com/studio/write/vector-asset-studio#sloption
}
buildTypes {
release {
minifyEnabled false
// Do code shrinking!
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Core stuff
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
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 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.google.android.gms:play-services-wearable:16.0.1'
// Dagger
implementation 'com.google.dagger:dagger:2.21'
kapt 'com.google.dagger:dagger-compiler:2.21'
// Dagger for Android
implementation 'com.google.dagger:dagger-android:2.21'
implementation 'com.google.dagger:dagger-android-support:2.21' // if you use the support libraries
kapt 'com.google.dagger:dagger-android-processor:2.21'
// Constraint layout
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// Associated WearOS project
wearApp project(':wear')
// Common library project
implementation project(':common')
// These were added to resolve gradle error on the 'com.android.support:appcompat-v7:28.0.0' implementation:
// All com.android.support libraries must use the exact same version specification (mixing versions can lead to
// runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0
// and com.android.support:support-media-compat:26.1.0
// This seems to be related to linking the wear project. If the wear project was not linked, the error went away.
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
// Retrofit RxJava
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
// Retrofit logging:
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
// Room
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
implementation "android.arch.persistence.room:common:$room_version"
implementation "android.arch.persistence.room:rxjava2:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
// For modern time handling (java.time requires API 26 or higher)
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1'
// Graphing
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
// Dropbox
implementation 'com.dropbox.core:dropbox-core-sdk:3.0.11'
// OpenCSV
implementation 'com.opencsv:opencsv:4.5'
}
EDIT
So after enabling multidex, there are some heavy dependencies showing up under the following TLDs when I analyse the APK using Android Studio (I'm not sure if I should be looking at defined or referenced method numbers?):
com.dropbox: 26000 defined methods, 34000 referenced methods
com.android (mainly support libraries): 18700 defined, 24600 referenced
org.apache (commons, log etc): 15000 defined, 15700 referenced
These alone take me up to the limit. I still don't get why this is suddenly happening though :( Surely if I have not added any libraries, these numbers should not have changed?
Simple add this to your gradle (Module: app) >> multiDexEnabled true
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
then Rebuild Project
in Menu click => Build>Rebuild Project.
After looking at your entire build gradle file, your issue definitely stems from your dependencies! Attempt to clean them up and remove as many as you can that you don't use. Chances are you were very close to the limit and any of those dependencies may have been cached using older versions. You can attempt to remove the entire build folder (and clean your gradle cache) but I am fairly certain the issue will not go away.
If all of these dependencies are required unfortunately you will have to go the routes you mentioned, either multi-dex or minifying debug builds. Multi-dex should be ok and shouldn't cause any unforeseen issues while minifying will slow down your builds and potentially cause Android Studio to become unstable (especially instant run/apply changes!)
Good luck, one thing to take from this is to keep your dependencies clean and precise, only add when absolutely needed, and if all else fails, multi-dex is your friend.
None of the answers they gave you were exhaustive. The problem lies in the Multidex. You must add the library in the app gradle:
implementation 'com.android.support:multidex:1.0.3'
After, you should add in the defaultConfig of the app gradle:
multiDexEnabled true
From the Android docs:
"If your minSdkVersion is set to 21 or higher, multidex is enabled by default and you do not need the multidex support library."
As an alternative to manually enabling multidex, you could simply increase your minSdkVersion if possible.
I would recommend building the application with multidex, and then extracting the method ids from the multiple dex files from the new apk, and also extract the method ids from the old, single-dex apk and comparing the two lists.
roughly, something like:
baksmali list dex new.apk
baksmali list method new.apk/classes.dex > new.list
baksmali list method new.apk/classes2.dex >> new.list
sort new.list > new.sorted.list
baksmali list method old.apk > old.list
diff new.sorted.list old.list
Although, if you're using proguard, you may need to figure out some way to apply the reverse proguard name mangling before comparing the lists.
After reading your question I can only suggest try invalidate cache and restart after and force refresh your dependency using this .
./gradlew build --refresh-dependencies
As your problem, I had to delete the build folder and the *.iml files (Android Studio project files) y I had to recreate the project, then the build and then all worked fine again.
I encountered the same issue and the solution was to enable Instant Run under File -> Setting -> Build, Execution, Deployment -> Instant Run and that solved my problem. Hope it's helpful.
I tried this.
hopes it helps, found it on some documentation
( forgot the url :( )
build.gradle app
dependencies {...
grdef multidex_version ='2.0.1'
implementation "androidx.multidex:multidex:$multidex_version"
}...
in bulid.gradle app
implementation 'com.android.support:multidex:2.0.1'
android {
multiDexEnabled true
}
android > app > build.gradle
android {
defaultConfig {
versionCode 1
versionName "1.0"
+ multiDexEnabled true
}
}
Add implementation 'com.android.support:multidex:1.0.3'
in dependencies block
dependencies {
+ implementation 'com.android.support:multidex:1.0.3'
}
Community wiki
Its easy just increase this minSdkVersion, targetSdkVersion :
Old:
defaultConfig { minSdkVersion 19 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName }
New:
defaultConfig { minSdkVersion 21 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName }
also this compileSdkVersion:
Old:
android { compileSdkVersion 28
New:
android { compileSdkVersion 29
It's good to have a Updated Android Studio 3.0. But I am facing a problem with Android Studio 3.0, I just created a new project in Android Studio 3.0. Then I got some error
I solved these by changing dependencies to latest version and issues solved.
But, when I added a dependency of facebook account-kit sdk com.facebook.android:account-kit-sdk:4.+
I am getting following errors-:
Error:Unable to resolve dependency for ':app#debug/compileClasspath':
Could not resolve com.facebook.android:account-kit-sdk:4.+. Open
FileShow Details
build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "ultimate.devil.logintest"
minSdkVersion 15
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"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.android:account-kit-sdk:4.+'
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'
}
NOTE -:
I am following Facebook Developers Docs
I have tried by changing compile to implementation
I have also tried changing com.facebook.android:account-kit-sdk:4.+ to com.facebook.android:account-kit-sdk:4.11.0 and com.facebook.android:account-kit-sdk:4.27 by googling latest version of Facebook Account-Kit SDK
I have also tries StackOverFlow Answers with possible with same problem. But no one help me
Screenshot
After some research I have solved this issue.
Step 1-:
I disable the Gradle offline work in settings.
File > Settings > Build, Execution, Deployment > Gradle > Uncheck Offline Work
Step 2-:
Then, I just changed compile 'com.facebook.android:account-kit-sdk:4.+' to api 'com.facebook.android:account-kit-sdk:4.+'
I don't know exactly why it's work. I see api in docs Reference
Now it works :)
EDIT -
Now, I am able to use both api or implementation and everything works fine.
Thanks,
Add matchingFallbacks = ['release', 'debug'] in the buildType that is failing to compile.
E.g. I was having an error for releaseStaging:
buildTypes {
debug {
buildConfigField "String", "CODEPUSH_KEY", '""'
}
releaseStaging {
buildConfigField "String", "CODEPUSH_KEY", 'myKey'
signingConfig signingConfigs.release
matchingFallbacks = ['release', 'debug']
}
release {
buildConfigField "String", "CODEPUSH_KEY", 'myKey'
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
I am facing similar error day before yesterday. Just solved it here
Moreover, as mentioned in the latest gradle release notes , you should avoid using dynamic dependencies with version number as:
com.facebook.android:account-kit-sdk:4.+
Try to replace it with appropriate version number as 4.0.0 or latest. Hope it solves the problem.
Short story:
Downgrade to Gradle 4.2.1
Long story:
I was using Gradle version 4.3 based on the answer here as that question was my error. After doing that change than I started having your problem.
Downgrading to version 4.2.1 your problem went away. Now I have to go back to the previous problem.
I also had this problem while compiling my project with Android Studio 3.0 and gradle plugin 3.0.0
If I will have other problems I will post here the updates
all the Facebook Account Kit SDK build artifacts can be found on Maven Central:
// https://mvnrepository.com/artifact/com.facebook.android/account-kit-sdk
api 'com.facebook.android:account-kit-sdk:4.35.0'
and the according repository to add is:
repositories {
mavenCentral()
}
Gradle not being in offline mode, is being assumed.
I solve this problem by clearing this directory:
c:\Users\User name\\.gradle\caches\
I had the same issue and I solved it by changing apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
Regarding my issue, it was a little bit different from yours. I have the second module with android library and from android developers page under the section "Convert an app module to a library module". My guess is that it is related to managing Manifest files inside of the architecture, so Android will know where is the main Manifest file.
And regarding api and implementation, the answer can be found here
The api configuration should be used to declare dependencies which are exported by the library API, whereas the implementation configuration should be used to declare dependencies which are internal to the component.
Had the same issue. After trying everything, finally realized that it was the network that didn't allow syncing dependencies. Tried out with hotspot and it worked.
I had the same issue and I did fix it like this :
implementation project(path: 'com.facebook.android:account-kit-sdk:4.+', configuration: 'default')
Downgrade these two files solve the problem
project`s build.graddle to 3.1.4
graddle-wrapper properties to 4.4
Saw an old project. It showed "build" successful. So i checked build.gradle file. Comparing those 2 projects i saw a change in dependencies version number. Then i just copied version numbers from the old proj and it worked. There was one more BuildUsing or so in android{} i removed it from my new proj (it was not in my old proj). i think it is because of an incomplete or corrupt gradle update.
Verdant newbie here. I'm making a fairly simple project that needs to be compatible with Android versions older than Lollipop, but still want to have the app look nicer by using AppCompat.
Unfortunately, I do not know how to work (or even find) the gradle - I tried to run a gradle task: compile "com.android.support:appcompat-v7:21.0.+"
But it returned an error saying that "Task 'compile' is ambiguous...." in my project.
Could anyone tell me how to add this? I've searched all over Google, but everything goes way over my head.
Thanks!
Have you been able to locate Gradle file?
Edit your gradle like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xyz.xyz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.00.00"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
}
Update your question and post full Gradle code.
Add the appcomapt library(com.android.support:appcompat-v7:21.0.+") in dependancy section of the build.gradle file
Or second way to add library is by searching on maven repo.this can be done by traversing file->project structure->app>dependancy->click (+) ->add Library dependancy
Task 'compile' is ambiguous.
This issue is not the Compile Issue. but this was an issue on the task itself.
if you are not using a command like "gradle compileDebug" then one of the android configurations are executing the task and it is not working well with your build.gradle.
Here is a link that seems to relate specifically to your issue. Click Here