Android Studio: No build variant found error - android

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

Related

Manifest merger failed - android studio error

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

Cannot fit requested classes in a single dex file, even for earlier commits which previously compiled fine

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

error: duplicate value for resource 'attr/actionBarSize' with config ''

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

Why is tmp\kotlin-classes folder empty and path not found during compile stage of kotlin module build in Android Studio?

The module (not the main app) won't build because it fails this step:
:compileDebugKotlin
ERROR MESSAGES:
e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
Cause: [Path-deleted-for-SO-post]\message-classes\build\tmp\kotlin-classes\debug\com[Path-deleted-for-SO-post]\ble\aux\AlarmResponseTypes.class (The system cannot find the path specified)
File being compiled at position: file://[Path-deleted-for-SO-post]/message-classes/src/main/java/com/[Path-deleted-for-SO-post]/ble/_aux/AlarmResponseTypes.kt
Does it have anything to do with the "_aux" in src path vs "aux" in build path?
When I look in tmp\kotlin-classes folder, it's empty. The rest of the parent path back to C drive that I deleted for this post is correct. Even when I try to make the folder path, it gets deleted as soon as build runs of course.
Things I've tried many times:
Clean - rebuild - restart - etc.
Invalidate - restart - etc.
Updated kotlin plugin, Android Studio, Gradle versions, etc.
Only building this module and not entire app.
Always comes back to same error.
AND, it did build properly (although I did not run or build into apk file after that) before updating kotlin plugin -- but not sure that had anything to do with it.
Versions, etc.:
AS - 3.1.3
kotlin_version = '1.2.50'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Full build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 23
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'
}
}
// project configuration
sourceSets {
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
}
SOLVED: Windows does not allow folder name of "aux" (this is a legacy reserved word)...
Therefore, code modules that worked on Macs failed to build when incorporated into a different project on the Windows machine I was using.
As soon as a folder is placed on the file system in Windows via unzip, etc., with the name "aux" then Windows automatically changes the folder name to "_aux" w/o telling the user.

Unable to resolve dependency Android Studio 3.0

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.

Categories

Resources