I changed the name of the package to "com.xxx.xxx" with Refactor > Rename and changed the name of the package and application identifiers tomanifest and gradle. Successful synchronization, everything is OK. According to the instructions delevopers.google Getting Started and delevopers.google Intermediate Ads ads built into my application, previously included in the project structure AdMob. When using gradle, but it cost me to try to run the application on a physical level.
Manifest merge error: Attribute application # appComponentFactory value = (android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml: 22: 18-91
also present in [androidx.core: core: 1.0.0] AndroidManifest.xml: 22: 18-86 value = (androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools: replace = "android: appComponentFactory"' to the <application> element in AndroidManifest.xml: 8: 5-27: 19 to override.
If you advertise android.useAndroidX = true and android.enableJetifier = true in the gradle properties, then everything becomes even worse, because my MainActivity.java extendit isAppCompatActivity, which is not used with the above gradle properties (android.useAndroidX = true)
Well since you did not post your build.gradle file
I suspect that you have the old android support libraries and you are trying to migrate to AndroidX, According to your error it appears that you should be using this one instead
implementation "androidx.appcompat:appcompat:1.0.2"
of
implementation "com.android.support:support-compat:28.0.0"
And a couple of other files related files in that same manner, now before trying to manually fix the paths of androidx , I would recommend that you update to the latest version of Android Studio (3.4.2) and do click Migrate to AndroidX inside the refactor menu
Now sometimes, the error might be in the libraries you want to depend to
If that's the case , heres a workaround ...
configurations {
all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
api project(':your-awesome-library-goes-here')
}
also if there is a slight chance that you are using butterknife
android{
.
.
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
.
.
}
Do a sync , if you still see errors ... then try to check for dependencies to see which library is the culprit
./gradlew app:androidDependencies
Where app is your module's name
Cheers
It is because in gradle you have to also change it to androidX and check your dependency with this
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example1.*appname*"
minSdkVersion 22
targetSdkVersion 28
versionCode 3
versionName "3.0"
**testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"**//check this is their or not
}
sometimes we forget to define testInstruement runner
Related
i am new to android development, i started developing from scratch on a project i bought online, following the documentation, i encountered a error saying No variants found for 'app'. Check build files to ensure at least one variant exists.
Here is the build.gradle code
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.app-10.app"
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'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Third Party Libraries
//Glide library for image fetching from the web
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
//Material library for styling blocks
implementation 'com.google.android.material:material:1.0.0'
// Google Gson
implementation 'com.google.code.gson:gson:2.8.5'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
// Android-SpinKit
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
// gotev/android-upload-service
implementation "net.gotev:uploadservice:3.5.2"
//A fast circular ImageView perfect for profile images
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'org.apache.commons:commons-io:1.3.2'
}
I have just solved the same issue like this:
Tools -> SDK Manager
Verify that the SDK platform package for Android 10.0 (the one with API level 29, like you defined in your gradle file) is checked.
If not, check it and apply changes. Accept the licence terms, install the package and then File -> Sync Project with Gradle Files (or open the project again)
In my case, it is because I add flavourDimensions and not adding it to any productFlavors
example from my case I have in my build.gradle in app level:
flavorDimensions "stage", "mode"
and my productFlavors:
productFlavors {
dev {
dimension "stage"
//noinspection DevModeObsolete
minSdkVersion 21
versionNameSuffix "-dev"
applicationIdSuffix '.dev'
resConfigs "en", "xxhdpi"
}
prod {
dimension "stage"
minSdkVersion 21
versionNameSuffix "-prod"
applicationIdSuffix '.prod'
}
}
As you can see here, I don't use flavorDimensions "mode" in any of my productFlavors's dimension. So, when I try to sync my gradle. It gives me that error.
So my solution here is to remove "mode" from flavorDimensions
go to the SDK manager (Ctrl+Shift+A then write SDK manager), install the android version of current project, in this case I installed all the available options starting from 5.0
I replaced from:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
to my Android Studio v3.0.1 in my case:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
but at the end i resolve it by
you need to detect and set your proper sdk
my sdk is 30.0.2 after i install 29.0.2 this error gone
Might help someone, in my case, I just needed to update Gradle.
A warning popped up on Android Studio, so I updated it, and then worked properly 🤷🏻♀️
For me the issue was that I hadn't opened the project at its root folder, I'd opened the "app" folder. Both folders had the gradle icon so it was an easy mistake to make after not having done any Android development for a while.
You may get the "No variants found" error in a project with multiple modules, when build types do not match between modules.
In my case, this happened when trying to add a macrobenchmark to an existing Android project.
Following the instructions in this document, I added a new module macrobenchmark to the project.
At some point, I misinterpreted the instructions: I added a new build type benchmark to the build.gradle of module app, but did not add the same build type to the build.gradle of module macrobenchmark.
From then on, any attempt to sync the project with the gradle files would fail with the following error message:
No variants found for 'macrobenchmark'. Check build files to ensure at least one variant exists.
The solution was simple (but not trivial): bring the build types back in sync. In my case, add the missing build type benchmark to the build.gradle of module macrobenchmark.
Try with
npm i cordova-android#10.1.1
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
My app is working fine, but after adding Mobile Ads SDK, it stops syncing.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "abc
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/images', 'src/main/assets/databases']
res.srcDirs =['src/main/res', 'src/main/res/menu', 'src/main/res/anim', 'src/main/res/values-ja']
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable: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 'com.sothree.slidinguppanel:library:3.4.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
This is the error.
Manifest merger failed : Attribute
meta-data#android.support.VERSION#value value=(26.0.2) from
[com.android.support:recyclerview-v7:26.0.2]
AndroidManifest.xml:25:13-35
is also present at [com.android.support:customtabs:26.1.0] AndroidManifest.xml:25:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override.
I don't know what the error means, have anyone encountered the same problem?
Problem:
Problem is support library version is getting conflicted.
Solution:
First step you need to try is using a common version of support library, you can declare a common variable:
supportLibraryVersion=28.0.0
And refer the same for all the dependencies of the same package:
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.android.support:support-v4:$supportLibraryVersion"
Second step:
You need to debug the dependencies list, use the ./gradlew dependencies command which will list dependencies tree. Analyse the dependencies tree, you will get to see which library is internally referring which version of the support library:
For example, this older version of the library:
com.android.support:recyclerview-v7:26.0.2
The mobile Ads SDK might have a support library version which is different that is being used in your application. The error clearly says that there is a different version in your AndroidManifest.xml file. The error also suggests -
add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override
It also shows the lines where you need to add this. I think that should solve the problem.
Open Your AndroidManifest.xml .you will see Merged Manifest below it . Now from your error log.
[com.android.support:recyclerview-v7:26.0.2]
AndroidManifest.xml:25:13-35 is also present at
[com.android.support:customtabs:26.1.0] AndroidManifest.xml:25:13-35
value=(26.1.0).
Your manifest is having conflict with two version for same library.So click on Merged Manifest and your will get
add 'tools:replace="android:value"' to element at
AndroidManifest.xml:23:9-25:38 to override
Click on it . and issue will be solved.
I'm porting my current android apk to meet recent playstore directive - " targetSdkVersion 26"
This my gradle file. I started off with compileSdkVersion 26 and ended up at 28. So for 28 I had to use AndroidX dependencies. Im stuck at the error as posted in subject line. Any help would be very much appreciated.
The error message is
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/actionBarSize\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/sk/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0.aar/34c8fa33903fb2b3203e5c70952da588/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/sk/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0.aar/34c8fa33903fb2b3203e5c70952da588/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
:app:mergeDebugResources
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "pack.age.net"
minSdkVersion 16
//Since no updates to app can be published in Playstore beginning Nov 1, 2018 - bumping targetSdk to 26 from 19
targetSdkVersion 26
//Double check this before you move this to production
versionCode 22
versionName "3.3"
// Enabling multidex support.
multiDexEnabled true
//Language resources
resConfigs "en", "hi"
}
buildTypes {
release {
//Shrink your code
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
checkReleaseBuilds false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/journeyapps/maven"
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
//implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
// implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
//Hockey App for Crash Analytics
implementation 'net.hockeyapp.android:HockeySDK:5.1.1'
//Sundry library files
implementation files('libs/commons-codec-1.9.jar')
implementation files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
implementation files('libs/libphonenumber-6.2.jar')
//Mutlidex Support
implementation 'com.android.support:multidex:1.0.0'
//Square Picasso Image View
implementation 'com.squareup.picasso:picasso:2.5.2'
//Calligraphy for custom fonts
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
testImplementation 'junit:junit:4.12'
//Apache Commons
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'com.github.chrisbanes:PhotoView:2.2.0'
// Supports Android 4.0.3 and later (API level 15)
implementation 'com.journeyapps:zxing-android-embedded:2.0.1#aar'
// Supports Android 2.1 and later (API level 7), but not optimal for later Android versions.
// If you only plan on supporting Android 4.0.3 and up, you don't need to include this.
implementation 'com.journeyapps:zxing-android-legacy:2.0.1#aar'
// Convenience library to launch the scanning and encoding Activities.
// It automatically picks the best scanning library from the above two, depending on the
// Android version and what is available.
implementation 'com.journeyapps:zxing-android-integration:2.0.1#aar'
// Version 3.0.x of zxing core contains some code that is not compatible on Android 2.2 and earlier.
// This mostly affects encoding, but you should test if you plan to support these versions.
// Older versions e.g. 2.2 may also work if you need support for older Android versions.
implementation 'com.google.zxing:core:3.0.1'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
hello there~ I too got a disaster moving to Androidx... according to google document you should locate the gradle property and add these two lines which works fine for me!
android.enableJetifier=true
android.useAndroidX=true
Good Luck dude~
The proper answer might be, to update the Firebase dependencies to have versions, which already use androidx dependencies and if this should not be enough, to also enable the Jetfier, in case other libraries pull in com.android.support dependencies, which need to be re-written. To do so, add this into the gradle.properties file:
android.enableJetifier=true
android.useAndroidX=true
PS_ANDROIDBUILDTOOLSVERSION=29.0.1
android.aapt2FromMavenOverride=${Android_home}/build-tools/29.0.1/aapt2
disable aapt2 from maven
We need to change XML layout, any support value need to change to androiddx value
android.support.v4.widget.SwipeRefreshLayout need to change to androidx.swiperefreshlayout.widget.SwipeRefreshLayout
When I use com.android.support:appcompat-v7:28.+ in my project's build.gradle(module) it works without any error. But when I just use com.android.support:appcompat-v7:28, just without .+, it gives me an error:
Failed to resolve: com.android.support:appcompat-v7:28.0
Just without the .+ end of it. I added maven before but the result was the same. Any idea to solve it?
28.0.0 is the final version of support libraries. Android has migrated to AndroidX. To use the latest android libraries, Migrating to AndroidX
Edit: Versions 28.0.0-rc02 and 28.0.0 are now available.
I don't see any 28.0 version on Google Maven. Only 28.0.0-alpha1 and 28.0.0-alpha3. Just change it to either of those or how it was previously, i.e., with .+ which just means any version under 28 major release.
For an alpha appcompat release 28.+ makes more sense.
Add the following code on build.gragle (project) for adding Google maven repository
allprojects {
repositories {
...
maven {
url 'https://maven.google.com/'
name 'Google'
}
...
}
}
some guys who still might have the problem like me (FOR IRANIAN and all the coutries who have sanctions) , this is error can be fixed with proxy
i used this free proxy for android studio 3.2
https://github.com/freedomofdevelopers/fod
just to to Settings (Ctrl + Alt + S) and search HTTP proxy then check Manual proxy configuration then add fodev.org
for host name and 8118 for Port number
As #Sourabh already pointed out, you can check in the Google Maven link what are the packages that Google has listed out.
If you, like me, are prompted with a similar message to this Failed to resolve: com.android.support:appcompat-v7:28.0, it could be that you got there after upgrading the targetSdkVersion or compileSdkVersion.
What is basically happening is that the package is not being found, as the message correctly says. If you upgraded the SDK, check the Google Maven, to check what are the available versions of the package for the new SDK version that you want to upgrade to.
I had these dependencies (on version 27):
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
And I had to change the SDK version and the rest of the package number:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
Now the packages are found and downloaded. Since the only available package for the 28 version of the SDK is 28.0.0 at the moment of writing this.
Run
gradlew -q app:dependencies
It will remove what is wrong.
my problem was just network connection. using VPN solved the issue.
implementation 'com.android.support:appcompat-v7:28.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
All to add
Ensure that your buildToolsVersion version tallies with your app compact version.
In order to find both installed compileSdkVersion and buildToolsVersion go to Tools > SDK Manager. This will pull up a window that will allow you to manage your compileSdkVersion and your buildToolsVersion.
To see the exact version breakdowns ensure you have the Show Package Details checkbox checked.
android {
compileSdkVersion 28
buildToolsVersion "28.0.3" (HERE)
defaultConfig {
applicationId "com.example.truecitizenquiz"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0' (HERE)
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'
}
in build.gradle , the version of bellow line should be same
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0'