Search result for Question Taged android-gradle-plugin
There are some results of your Tag: android-gradle-plugin
    how to solve Could not find or load main class org.gradle.wrapper.GradleWrapperMain

    1. FAILURE
    2. execution of the command ./gradlew leads to the following output:
      usr$ ./gradlew tasks
      Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
      

    3. What is gradle wrapper
    4. gradlew is the gradle wrapper executable - batch script on windows and shell script elsewhere. The wrapper script when invoked, downloads the defined gradle version and executes it. By distributing the wrapper with your project, anyone can work with it without needing to install Gradle beforehand. Even better, users of the build are guaranteed to use the version of Gradle that the build was designed to work with.

    5. Restoring gradle wrapper
    6. It used to be that you needed to add a wrapper task to your build.gradle to restore gradle wrapper and all its dependencies. For instance:

      task wrapper(type: Wrapper) {
          gradleVersion = '4.1'
      }
      

      Newer versions of gradle do not require this. It is now a built-in task. Just run:

      gradle wrapper
      

      You can also supply additional flags to specify versions etc

      gradle wrapper --gradle-version 6.2 --distribution-type all
      

      When you run this task, a gradle wrapper script, and the required jar files are added to your source folders. Properties are stored in gradle/wrapper/gradle-wrapper.properties

      (You may need to install gradle locally to run this. brew install gradle on mac for instance. See more detailed instructions here)

    7. Why was it missing in the first place?
    8. OP seems to have deleted something that gradle wrapper depends on.

      But a common reason is that a .gitignore entry prevents wrapper jars from being checked into git. Note that the .gitignore in effect may be in the source folder, or a global one in your user home folder or git global configuration. It is common to have a *.jar entry in .gitignore.

      You can add an exception for gradlew's jar files in .gitignore

      *.jar
      !gradle/wrapper/gradle-wrapper.jar
      

      or force add the wrapper jar into git

      git add -f gradle/wrapper/gradle-wrapper.jar
      

      --
      Ref: Gradle Wrapper

    9. Other Solution
    10. What worked for me is to first run:

       gradle wrapper
      

      After successful build I was able to run

      ./gradlew assembleRelease
      

      Note: To be able run gradle wrapper first run brew install gradle. If installation successful run gradle wrapper from project root.

      Source and thanks: http://gradle.org/docs/current/userguide/gradle_wrapper.html and https://stackoverflow.com/users/745574/rage

      In my case it was a global .gitignore, as explained in @HankCa's answer.

      Instead of forcefully adding the jar, which you'll need to remember to do in each Gradle project, I added an override to re-include the wrapper jar in my global .gitignore:

      *.jar
      !gradle/wrapper/gradle-wrapper.jar
      

      This is useful to me as I have many projects that use Gradle; Git will now remind me to include the wrapper jar.

      This override will work so long as no directories above gradle-wrapper.jar (such as gradle and wrapper) are ignored -- git will not descend in to ignored directories for performance reasons.

    Laxmi Queenie 2022-08-11
    How to solve Error building Android library

    1. FAILURE
    2. We are now seeing this error when building one of our library modules:
      $ ./gradlew library_module:assemble
      
      Execution failed for task ':library_module:bundleDebugAar'.
      > Direct local .aar file dependencies are not supported when building an AAR. 
      The resulting AAR would be broken because the classes and Android resources from any local .aar 
      file dependencies would not be packaged in the resulting AAR. Previous versions of the Android 
      Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The 
      following direct local .aar file dependencies of the :library_module project caused this error: 
      ______.aar
      

    3. Most common Solution
    4. I recently encountered the same issue, the fix was to remove the library from libs/ and import it using File -> New -> New Module -> Import .JAR/.AAR Package, then referencing it in the library module build.gradle file:

      dependencies {
        implementation project(":imported_aar_module")
      }
      

      If you are on a newer Android Studio version (4.0.0+), this option is not available. Instead you have to do it manually.

      1. Create a new directory and put the following content into the build.gradle file withing the new directory:
      configurations.maybeCreate("default")
      artifacts.add("default", file('[nameOfTheAar].aar'))
      
      1. Place the aar into this new directoy. Next to the build.gradle file.
      2. Add the new created Gradle project to the settings.gradle file:
      include(":pathToTheCreatedDirectory")
      
      1. Include the project in your library where you want to use the aar:
      implementation project(":pathToTheCreatedDirectory", configuration = "default")
      

    5. Solution 2
    6. When building an Android library that depends on other Android libraries (i.e., aar files), you will get the following error message if you include the aar files as dependencies in the project:

      Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error).

      As the above message states, when you build an Android library project, any aar it depends on is not packaged. If you built this way prior to AGP (Android Gradle Plugin) 4, you probably noticed that you had to include the aar dependencies on the project consuming your library.

      You can compile your Android library project by specifying that the aar dependencies are compileOnly. See this for more info on when to use compileOnly.

      So just add the following to your app build.gradle file:

      compileOnly files('libs/some-library.aar')
      

      Note that if you do this you will have to include the aar dependencies on the application project that consumes your library.

      Alternatively, you can create a module that imports your aar dependency as @Sandi mentioned in the answer above.

      Another way is to publish your aar dependencies to a maven repository and then add them to your library project like this:

      implementation 'mylibrarygroup:mylibraryartifact:version-x.y.z@aar'
      

    7. Solution 3
    8. I want to call out @StefMa's comment on this question which was incredible simple and solved this issue for me, but it's buried among many other comments on this thread and is easily missed.

      The 'correct' answer on this thread no longer works because it's not possible to import AARs in Android Studio anymore as referred to in that answer. But, the solution referred to in StefMa's comment linking to this GitHub post does, and it works perfectly.

      Long story short - put your AAR into a separate module.

      There's no need to muck around with creating lib directories, just follow these directions -

      1. Create a new directory in your project's root directory. The image below shows two of them - spotify-app-remote and spotify-auth, but one is sufficient. Within that, put your AAR in, and create a new build.gradle file.

        Folder structure

      2. Within the build.gradle file, add the following, replacing the aar filename with the name of your AAR file -

        configurations.maybeCreate("default")
        artifacts.add("default", file('spotify-app-remote-release-0.7.1.aar'))
        
      3. Add this to your settings.gradle file, substituting the name of the directory you created

        include ':spotify-app-remote'
        
      4. Include your new module in the module you wish to use the AAR. eg, if you want to use it within your app module, open app's build.gradle and add

        api project(':spotify-app-remote')
        

        within your dependencies { } block, obviously again substituting spotify-app-remote with whatever the name of your module is.

    9. Solution 4
    10. In my experience, when Gradle Plugin version is 4.2.2+ and Gradle version is 7.1+, as in @Luis's answer 'compileOnly' works.

      compileOnly files('libs/your_library_name.aar')
      

      It didn't work when the Gradle versions were lower.

    Filibert Nosizwe 2022-08-11
    how can I add the aidl file to Android studio (from the in-app billing example)

    I am currently migrating an Eclipse app to Android Studio. This app was using the in app billing.

    My main problem is to compile the project and the aidl file (I guess you all use this file)

    I get this error message:

    Gradle: error: cannot find symbol class IInAppBillingService
    Gradle: error: package IInAppBillingService does not exist
    

    So, following some tutorials, I move this file from com.mypackage.billing to src/main/aidl (see this reference)

    But as soon, as I do that, I get this message:

    Gradle: Execution failed for task ':xxxxxxxxxxx:compileDebugAidl'.

    Failed to run command: (...) C:\Users\xxxx\AndroidStudioProjects\xxxxxxProject\xxxxxxx\src\main\aidl\IInAppBillingService.aidl:45 interface IInAppBillingService should be declared in a file called com\xxxxxxxx\billing\IInAppBillingService.aidl.

    The message is clearly a contradiction with the post from the Google bug page I linked above.

    Anyone suceeded to make this aidl file to work and can help me?

    enter image description here

    Just to inform, some links I followed:

    • http://tools.android.com/tech-docs/new-build-system/user-guide
    • http://developer.android.com/guide/components/aidl.html
    Margrit Simon 2022-08-15
    Android Studio Could not find method runProguard() for arguments?
    /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java "- com.intellij.rt.execution.application.AppMain org.gradle.launcher.GradleMain --build-file /Users/Tom/Documents/Git_open_sources/android-material-drawer-template/app/build.gradle
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/Tom/Documents/Git_open_sources/android-material-drawer-template/app/build.gradle' line: 16
    
    * What went wrong:
    A problem occurred evaluating project ':app'.
    > Could not find method runProguard() for arguments [false] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, applicationIdSuffix=null, versionNameSuffix=null, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    BUILD FAILED
    
    Total time: 6.741 secs
    
    Process finished with exit code 1
    

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"
    
    defaultConfig {
        applicationId "com.poliveira.apps.materialtests"
        minSdkVersion 11
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.0.0'
    //noinspection GradleDependency
    compile "com.android.support:appcompat-v7:21.0.0"
    compile 'com.android.support:recyclerview-v7:21.0.0'
    }    
    
    Baptist Slaven 2022-08-18
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0

    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

    Could not resolve com.android.support:appcompat-v7:26.1.0.

    Required by: project :app

    No cached version of com.android.support:appcompat-v7:26.1.0 available for offline mode.

    Error log:

    Could not resolve all files for configuration ':app:debugCompileClasspath'.
    Could not resolve com.android.support:appcompat-v7:26.1.0.
    Required by:
    project :app
    No cached version of com.android.support:appcompat-v7:26.1.0 available for offline mode.
    No cached version of com.android.support:appcompat-v7:26.1.0 available for offline mode.
    Could not resolve com.android.support.constraint:constraint-layout:1.1.0-beta3.
    Required by:
    project :app
    No cached version of com.android.support.constraint:constraint-layout:1.1.0-beta3 available for offline mode.
    No cached version of com.android.support.constraint:constraint-layout:1.1.0-beta3 available for offline mode.
    Could not resolve com.android.support:design:26.1.0.
    Required by:
    project :app
    No cached version of com.android.support:design:26.1.0 available for offline mode.
    No cached version of com.android.support:design:26.1.0 available for offline mode.
    Could not resolve com.android.support:cardview-v7:26.1.0.
    Required by:
    project :app
    No cached version of com.android.support:cardview-v7:26.1.0 available for offline mode.
    No cached version of com.android.support:cardview-v7:26.1.0 available for offline mode.
    Could not resolve com.google.android.gms:play-services-ads:11.4.2.
    Required by:
    project :app
    No cached version of com.google.android.gms:play-services-ads:11.4.2 available for offline mode.
    No cached version of com.google.android.gms:play-services-ads:11.4.2 available for offline mode.
    Could not resolve com.android.support:support-v4:26.1.0.
    Required by:
    project :app
    No cached version of com.android.support:support-v4:26.1.0 available for offline mode.
    No cached version of com.android.support:support-v4:26.1.0 available for offline mode.

    Error log image:

    Click here for image

    Steve 2022-08-17
    android - Unable to open debugger port : java.net.SocketException “Socket closed”

    I'm using Android Studio, with multiple flavors using Gradle, each with a Debug and Release type, organized as described here, on the bottom half.When I try to start the debugger, I get this error:

    Error running androidRecover [installAppDebug]: Unable to open debugger port :     java.net.SocketException "Socket closed
    

    I'm also unable to attach the debugger to my device once it's running (it only displays the name of my phone, not the app).

    All 3 flavors install on my phone just fine. I just can't get it to let me debug them. I also tested attaching the debugger on a Nexus tablet, and I got the same result.

    It's not Gradle specifically as a whole because I can run other Gradle-based apps and attach the debugger just fine so I wonder if it's something with how I've setup my Gradle project and settings.

    Here's my build.gradle:

    apply plugin: 'android'
    apply from: 'signing.gradle'
    
    android {
        compileSdkVersion 19
        buildToolsVersion '19.0.3'
    
        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 19
        }
    
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile
                         ('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    
        productFlavors {
            flav1 {
                packageName "com.ex.flav1"
                versionCode 32
                versionName "1.0.5"
                signingConfig signingConfigs.flav1
            }
    
            flav2 {
                packageName "com.ex.flav2"
                versionCode 33
                versionName "1.0.6"
                signingConfig signingConfigs.flav2
            }
    
            flav3 {
                packageName "com.ex.flav3"
                versionCode 27
                versionName "1.0.0"
                signingConfig signingConfigs.flav3
            }
        }
    }
    
    dependencies {
        compile 'com.android.support:appcompat-v7:19.+'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/httpmime-4.2.5.jar')
    }
    

    I really have no idea what else to try. Android Studio is completely up-to-date. I've restarted Android Studio, my phone, and my computer.

    Also, last week I was having this problem, but it was a specific socket that was blocked, from trying to run the emulator and my phone at the same time. I also noticed I had multiple Gradle processes running, because it wasn't killing them on its own, which I often had to kill Android Studio to kill them. Once that was fixed, it was working off and on.

    Let me know if you need any other info.

    Thanks, Devin

    Edit I finally know why @hasanaydogar's answer works and why it probably would have solved my problem if we had known it then. See my 2nd comment on it to know why, but in short, you have to select in that dropdown the name that matches your app's root directory.

    Rüdiger Yewande 2022-08-31
    BuildConfig not getting created correctly (Gradle Android)

    I am trying to convert our Android application to a gradle build. I have the project and it's libraries building successfully. I am now trying to create separate apks for our various environments (dev/test/prod have different urls for the restful services they consume).

    In searching around, the best way that I feel to do this is with making different BuildConfig for each environment. This is what I tried:

    import java.util.regex.Pattern
    
    buildscript {
        repositories {
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:+'
        }
    }
    
    apply plugin: 'android'
    
    task('increaseVersionCode') << {
        def manifestFile = file("AndroidManifest.xml")
        def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
        def manifestText = manifestFile.getText()
        def matcher = pattern.matcher(manifestText)
        matcher.find()
        def versionCode = Integer.parseInt(matcher.group(1))
        def manifestContent = matcher.replaceAll("versionCode=\"" + ++versionCode + "\"")
        manifestFile.write(manifestContent)
    }
    
    tasks.whenTaskAdded { task ->
        if (task.name == 'generateReleaseBuildConfig') {
            task.dependsOn 'increaseVersionCode'
        }
    }
    
    dependencies {
        compile 'com.android.support:support-v4:19.0.0' 
        compile files('libs/commons-io-2.4.jar',
                      'libs/google-play-services.jar',
                      'libs/gson-2.2.4.jar',
                      'libs/universal-image-loader-1.8.6.jar',
                      'libs/wakeful-1.0.1.jar')
        compile project(':pulltorefresh_lib')
        compile project(':edgeeffect_lib')
        compile project(':viewpagerindicator_lib')        
    }
    
    android {
        buildToolsVersion "18.1.1"
        compileSdkVersion "Google Inc.:Google APIs:18"
    
        defaultConfig { 
           minSdkVersion 14
           targetSdkVersion 18
        }
    
        buildTypes {
            debug {
                packageNameSuffix ".debug"
            }
            dev.initWith(buildTypes.debug)
            dev {
                buildConfigField "String", "URL_SEARCH", "\"https://dev-search.example.com\";"
                buildConfigField "String", "URL_CONNECT", "\"https://dev-connect.example.com\";"
                buildConfigField "String", "URL_SVC_NEWSLIST", "\"https://dev-mobilenews.example.com/newslist\";"
                buildConfigField "String", "URL_SVC_NEWSDETAIL", "\"https://dev-mobilenews.example.com/newsdetail\";"
                buildConfigField "String", "URL_SVC_REGISTERENDPOINTS", "\"https://dev-mobilenews.example.com/registerendpoints\";"
            }
            prod.initWith(buildTypes.release)
            prod {
                buildConfigField "String", "URL_SEARCH", "\"https://search.example.com\";"
                buildConfigField "String", "URL_CONNECT", "\"https://connect.example.com\";"
                buildConfigField "String", "URL_SVC_NEWSLIST", "\"https://mobilenews.example.com/newslist\";"
                buildConfigField "String", "URL_SVC_NEWSDETAIL", "\"https://mobilenews.example.com/newsdetail\";"
                buildConfigField "String", "URL_SVC_REGISTERENDPOINTS", "\"https://mobilenews.pdc-np-cf.lmig.com/registerendpoints\";"          
            }
        }
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
        }
    }
    

    The problem is that my BuildConfig.java doesn't seem to get the static variables injected, therefore I get errors similar to:

    /Users/path/to/project/MainActivity.java:348: error: cannot find symbol
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.URL_SEARCH)));
                                                                                  ^
      symbol:   variable URL_SEARCH
      location: class BuildConfig
    /Users/path/to/project/MainActivity.java:359: error: cannot find symbol
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.URL_CONNECT)));
                                                                                  ^
      symbol:   variable URL_CONNECT
      location: class BuildConfig
    /Users/path/to/project/MainActivity.java:600: error: cannot find symbol
                HttpPost httpPost = new HttpPost(BuildConfig.URL_SVC_REGISTERENDPOINTS);
                                                            ^
      symbol:   variable URL_SVC_REGISTERENDPOINTS
      location: class BuildConfig
    /Users/path/to/project/service/AlarmNotificationService.java:145: error: cannot find symbol
            String requestUrl = BuildConfig.URL_SVC_NEWSLIST + "?"
                                           ^
      symbol:   variable URL_SVC_NEWSLIST
      location: class BuildConfig
    /Users/path/to/project/service/NewsService.java:240: error: cannot find symbol
            String requestUrl = BuildConfig.URL_SVC_NEWSLIST + "?"
                                           ^
      symbol:   variable URL_SVC_NEWSLIST
      location: class BuildConfig
    /Users/path/to/project/service/NewsService.java:530: error: cannot find symbol
                HttpPost httpPost = new HttpPost(BuildConfig.URL_SVC_NEWSDETAIL);
                                                            ^
      symbol:   variable URL_SVC_NEWSDETAIL
      location: class BuildConfig
    6 errors
    

    My build/source/buildConfig/debug/com/.../BuildConfig.java file contains:

    /**
     * Automatically generated file. DO NOT MODIFY
     */
    package com....;
    
    public final class BuildConfig {
      public static final boolean DEBUG = Boolean.parseBoolean("true");
      public static final String PACKAGE_NAME = "com.....debug";
      public static final String BUILD_TYPE = "debug";
      public static final String FLAVOR = "";
      public static final int VERSION_CODE = 5;
    }
    

    What am I doing wrong?

    Alícia Ugochukwu 2022-08-18
    java - Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]

    I am trying to open existing android project in android studio and it gradle cannot build the app without the error

    Error android studio keeps on throwing

    Error:(74, 1) A problem occurred evaluating project ':app'.
    > Could not find method implementation() for arguments 
    [com.android.support:appcompat-v7:26.0.0] on object of type 
    org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    

    My Code in build.gradle Which can help to understand my issue My dependencies

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    
    // google & support
    implementation "com.android.support:appcompat-v7:$supportVersion"
    implementation "com.android.support:cardview-v7:$supportVersion"
    implementation "com.android.support:recyclerview-v7:$supportVersion"
    implementation "com.android.support:design:$supportVersion"
    implementation "com.android.support:palette-v7:$supportVersion"
    implementation "com.android.support:customtabs:$supportVersion"
    implementation "com.android.support:support-v4:$supportVersion"
    implementation 'com.google.android.exoplayer:exoplayer:r2.0.4'
    
    // utils
    implementation 'com.github.bumptech.glide:glide:4.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
    implementation 'com.koushikdutta.ion:ion:2.1.7'
    implementation 'com.github.Commit451:bypasses:1.0.4'
    implementation 'com.jakewharton:butterknife:8.8.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
    implementation 'com.drewnoakes:metadata-extractor:2.9.1'
    implementation "com.orhanobut:hawk:2.0.1"
    
    }
    

    Please help to solve the issue

    Eudocia Girolamo 2022-08-16
    google cloud messaging - IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM

    Since I updated to Android SDK Tools 25.1.6 and Android Support Repository 32.0.0 (this morning), I got the following error, I didn't change anything in my code and it is still working on my colleague computer (Android SDK Tools 25.1.1 + Android Support Repository 30.0.0).

    java.lang.IncompatibleClassChangeError: The method 
         'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' 
         was expected to be of type virtual but instead was found to be of type direct 
         (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
    
         at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
         at com.google.android.gms.iid.zzd.<init>(Unknown Source)
         at com.google.android.gms.iid.zzd.<init>(Unknown Source)
         at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
         at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
         at com.xxxxxxx.utils.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:55)
         at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:145)
         at android.os.HandlerThread.run(HandlerThread.java:61)
    

    Here is a the piece of code that crash:

    InstanceID instanceID = InstanceID.getInstance(this); // <-- crash here
    String instanceIDToken = instanceID.getToken(getString(R.string.google_app_id),
    GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
    

    It is when I try to get a token from Google Cloud Messaging.

    I'm importing GCM in Gradle with splited play-services :

     compile 'com.google.android.gms:play-services-analytics:9.0.0' 
     compile 'com.google.android.gms:play-services-maps:9.0.0'
     compile 'com.google.android.gms:play-services-location:9.0.0' 
     compile 'com.google.android.gms:play-services-gcm:9.0.0' 
     compile 'com.google.android.gms:play-services-base:9.0.0'
    

    EDIT disabling GCM fixed the problem, so my guess is I should migrate to Firebase Cloud Message

    EDIT2 My device receive Google Play Services 9.0 (yesterday was 8.4.x). Now it doesn't crash anymore, but complain about module descriptor

     Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor"
     Firebase API initialization failure.
    

    Does anyone has a similar error, and how to fix it ?

    FIXED special thanks to @stegranet. ./gradlew -q app:dependencies --configuration compile helps you to identify what dependencies include SDK 24.x

    Main issue is some library import the latest support library using + sign instead of a version. This cause the issue, by including the latest available version.

    So avoid + sign in dependencies ;)

    Laxmi Queenie 2022-08-17
    android - Error:Execution failed for task ':app:transformClassesWithDexForDebug'

    The error

    Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1

    My app gradle file:

    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
        defaultConfig {
            applicationId 'Hidden application ID'
            minSdkVersion 15
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
        buildTypes {
            debug {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        lintOptions {
            disable 'InvalidPackage'
        }
        packagingOptions {
            exclude 'META-INF/services/javax.annotation.processing.Processor'
        }
        productFlavors {
        }
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'com.android.support:cardview-v7:23.1.1'
        compile 'com.jakewharton:butterknife:7.0.1'
        compile 'com.mcxiaoke.volley:library-aar:1.0.0'
        compile 'com.google.android.gms:play-services:8.1.0'
        compile 'com.facebook.android:facebook-android-sdk:4.7.0'
        compile 'com.googlecode.libphonenumber:libphonenumber:7.2.1'
        compile 'com.getbase:floatingactionbutton:1.10.1'
        compile 'com.android.support:preference-v7:23.1.1'
    }
    

    While debugging, if I set minifyEnabled to true, then it compiles. However, then I cannot debug my application.

    I checked this other question: Execution failed for task ':app:transformClassesWithDexForDebug' while implementing Google sign in for Android, but there is only one answer and implementing it does not resolve the issue unfortunately.

    AFAIK, the error is caused due to addition of too many Gradle dependencies, but I may be wrong (I really hope to be wrong because all these packages are really important!).

    Please help me to resolve this error. Much thanks!

    Gábor Pasha 2022-08-18
    android - Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve

    Newly installed Android studio 3.1.3 is giving strange dependencies error when making a new project and compiling for very first time.

    A similar question that didn't help resolve the problem.

    Event Logs:

    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
    Open File
    Show Details
    
    
    Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
    Open File
    Show Details
    

    ScreenShot:

    TestProject

    this problem happened to me several times and forcing https or http didn't resolve it either

    Beatrycze Luc 2022-08-17
    kotlin - Type Android Junit4 not present exception

    I have an Android project that I am trying to run Instrumentation tests for using AndroidStudio, but when I try to run the whole class file for the tests, I get the exceptions as stated below :

    java.lang.TypeNotPresentException: Type android.support.test.runner.AndroidJUnit4 not present
    Caused by: java.lang.ClassNotFoundException: android.support.test.runner.AndroidJUnit4
    

    Interestingly, I can run individual methods in this Instrument Test class, just not the whole class. My build.gradle file for the app is below:

    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    
    android {
        lintOptions {
            abortOnError false
        }
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.sarpuner.journal"
            minSdkVersion 19
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        buildToolsVersion '27.0.3'
    }
    
    repositories {
        maven { url "https://dl.bintray.com/ijabz/maven" }
    }
    
    dependencies {
        androidTestImplementation 'com.android.support:support-annotations:27.1.1'
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        implementation 'dev.dworks.libs:volleyplus:0.1.4'
        implementation 'com.google.code.gson:gson:2.8.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:rules:1.0.2'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'org.jsoup:jsoup:1.11.3'
        testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.1'
        implementation 'net.jthink:jaudiotagger:2.2.3'
        api 'com.google.guava:guava:26.0-android'
    }
    

    And the InstrumentTest class is as follows:

    package com.sarpuner.journal
    
    import android.support.test.InstrumentationRegistry
    import android.support.test.runner.AndroidJUnit4
    import android.util.Log    
    import org.junit.Test
    import org.junit.runner.RunWith    
    import org.junit.Assert.*
    import java.io.File
    
    private const val INSTRUMENT_TAG = "InstrumentTest"
    
    // TODO: There is a problem here with the class run!
    
    @RunWith(AndroidJUnit4::class)
    class ExampleInstrumentedTest {
    
        private val appContext = InstrumentationRegistry.getTargetContext()
    
        @Test
        fun useAppContext() {
            // Context of the app under test.
            assertEquals("com.sarpuner.journal", appContext.packageName)
        }
    
        @Test
        fun downloadAndSaveAudio() {
            val url = "http://telechargement.rfi.fr/rfi/francais/audio/jff/201808/journal_francais_facile_20h00_-_20h10_tu_20180809.mp3"
            val name = "09-08-2018.mp3"
            val f = File(appContext.filesDir, name)
            Log.d(INSTRUMENT_TAG, f.absolutePath)
            downloadAudio(url, f)
        }
    
        @Test
        fun downloadAndSaveTranscript() {
            val url = "https://savoirs.rfi.fr/fr/apprendre-enseigner/langue-francaise/journal-en-francais-facile-09082018-20h00-gmt"
            val name = "09-08-2018.txt"
            val f = File(appContext.filesDir, name)
    
            downloadText(url, f)
        }
    
        @Test
        fun addLyricsToAudio() {
    
        }
    }
    

    Any help/guidance is much appreciated, thank you.

    Louella Eleonora 2022-08-21
    android - Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7

    I installed the Kotlin plugin into my app (v. v1.1.1-release-Studio2.2-1) and then selected "Configure Kotlin in Project" I selected compiler and runtime version of 1.0.7. Kotlin updated my Gradle files. Now when I try to build in I get:

    Error: A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApkCopy'. Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7. Required by:

    MyApplication:app:unspecified

    I'm not sure what I'm missing here.

    Geordie Andrus 2022-08-15
    gradle - Android Studio how to package single AAR from multiple library projects?

    I am building android library project, which has a dependency on another internal library project.

    I am wondering if there is a way to package a single AAR library, which already contains internal library inside it. I would like to share only 1 AAR library package to my application developers.

    This is how my build.gradle files look currently, but currently they produce separate AAR files and both needs to be included in Application's build.gradle. As application is being built by another company, we need to share the final AAR file with them and not the complete library projects.

    ----- internalLib -------->>>>>>>>>>

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.+'
        }
    }
    apply plugin: 'android-library'
    
    repositories {
        mavenCentral()
    }
    
    android {
        compileSdkVersion 18
        buildToolsVersion '18.1.1'
    }
    
    dependencies {
        compile 'com.android.support:support-v4:18.0.0'
    }
    

    ----- externalLib --------

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.+'
        }
    }
    apply plugin: 'android-library'
    
    repositories {
        mavenCentral()
    }
    
    android {
        compileSdkVersion 18
        buildToolsVersion '18.1.1'
    }
    
    dependencies {
        compile 'com.android.support:support-v4:18.0.0'
        compile project(':internalLib')
    }
    
    Helle Sigrid 2022-08-18
    android - Gradle: More than one variant of project :myLib matches the consumer attributes

    A library that I wrote myLib uses RemoteMessage from Firebase, the app itself also uses Firebase.

    Using gradle 4.7. Also facing this in 4.4.1.

    How to fix it?

    project.gradle

    buildscript {
        
        repositories {
            google()
            jcenter()
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.2'
            classpath 'com.google.gms:google-services:3.3.0'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
            mavenCentral()
            mavenLocal()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    app.gradle

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.test.app"
            minSdkVersion 19
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
    
        dexOptions {
            preDexLibraries = false
            jumboMode = false
            javaMaxHeapSize "2048M"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        productFlavors {
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    
        implementation 'com.android.support:appcompat-v7:27.1.1'
    
        implementation 'com.google.android.gms:play-services-gcm:12.0.1'
        implementation 'com.google.android.gms:play-services:12.0.1'
        implementation 'com.google.firebase:firebase-core:12.0.1'
        implementation 'com.google.firebase:firebase-messaging:12.0.1'
        implementation 'com.google.firebase:firebase-crash:12.0.1'
    
        implementation project(":myLib")
    }
    
    apply plugin: 'com.google.gms.google-services'
    

    myLib.gradle

    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 27
    
    
    
        defaultConfig {
            minSdkVersion 19
            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'
            }
        }
    
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    
        implementation 'com.android.support:appcompat-v7:27.1.1'
    
        implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
        implementation 'com.j256.ormlite:ormlite-core:5.0'
        implementation 'com.j256.ormlite:ormlite-android:5.0'
    
        implementation 'com.google.firebase:firebase-messaging:12.0.1'
    }
    

    Error output from testApp\myLib> gradle clean assembleDebug and testApp\app> gradle clean assembleDebug

    More than one variant of project :myLib matches the consumer attributes:

    • Configuration ':myLib:debugApiElements' variant android-aidl:
      • Found artifactType 'android-aidl' but wasn't required.
      • Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      • Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      • Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      • Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
    • Configuration ':myLib:debugApiElements' variant android-classes:
      • Found artifactType 'android-classes' but wasn't required.
      • Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      • Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      • Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      • Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
    • Configuration ':myLib:debugApiElements' variant android-manifest:
      • Found artifactType 'android-manifest' but wasn't required.
      • Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      • Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      • Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      • Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
    • Configuration ':myLib:debugApiElements' variant android-renderscript:
      • Found artifactType 'android-renderscript' but wasn't required.
      • Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      • Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      • Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      • Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
    • Configuration ':myLib:debugApiElements' variant jar:
      • Found artifactType 'jar' but wasn't required.
      • Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      • Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      • Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      • Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
    Adrianne Siavash 2022-08-17
    android - Can an AAR include transitive dependencies?

    Right now I have a library project, say project Foo that depends on a library like OkHttp.

    Now, Foo has a Maven buildstep that generates an AAR and pushes it up to a public place.

    Now lets say I have project B, we'll call it Bar. Bar is an Android application, and Bar depends on Foo.

    Well, I have that. However, when I make a call to a public static function in Foo from Bar that calls OkHttp, I get this message:

    java.lang.NoClassDefFoundError: com.squareup.okhttp.OkUrlFactory
                at com.foo.sdk.utils.OkHttpStack.<init>(OkHttpStack.java:15)
    

    Is such a thing possible? Or will Bar need to manually depend on OkHttp as well as any other dependencies Foo has?

    Jožica Lidiya 2022-08-18
    firebase - Class file for com.google.android.gms.internal.zzaja not found

    I am using Fragment for the designing of the Firebase simple login registration.

    I get error in the OnCreateView() method on initializing

    auth = FirebaseAuth.getInstance();
    

    error:- Error:(58, 28) error: cannot access zzaja class file for com.google.android.gms.internal.zzaja not found please help source:- http://www.androidhive.info/2016/06/android-getting-started-firebase-simple-login-registration-auth/

    Benjamín Murali 2022-08-18
    android - Failed to read PNG signature: file does not start with PNG signature

    Gradle build failing with this error:

    Error:C:\Users\Roman\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.2.aar\bab547c3f1b8061ef9426f524a823a15\res\drawable-xhdpi-v4\abc_btn_switch_to_on_mtrl_00001.9.png failed to read PNG signature: file does not start with PNG signature
    
    Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
    Error:Execution failed for task ':app:mergeDebugResources'.
    Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
    aapt2 compile --legacy -o C:\dev\workspace\android2\MatrixCalculator\app\build\intermediates\res\merged\debug C:\Users\Roman\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.2.aar\bab547c3f1b8061ef9426f524a823a15\res\drawable-xhdpi-v4\abc_btn_switch_to_on_mtrl_00001.9.png
    Issues:
     - ERROR: C:\Users\Roman\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.2.aar\bab547c3f1b8061ef9426f524a823a15\res\drawable-xhdpi-v4\abc_btn_switch_to_on_mtrl_00001.9.png failed to read PNG signature: file does not start with PNG signature
    

    Some basic things i've tried to solve this issue:

    1. Invalidate caches/restart
    2. Deleting gradle folder
    Raja Prateek 2022-08-18
    Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package

    I am trying to upgrade my google play services dependencies to 8.4.0 by following the example Google gives here, but I am getting the following error ('com.example.exampleapp' is a replacement for my app package name):

    Error:Execution failed for task ':app:processDebugGoogleServices'.
    > No matching client found for package name 'com.example.exampleapp'
    

    Project build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    

    Module app/build.gradle:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.example.exampleapp"
            minSdkVersion 19
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
        }
        useLibrary 'org.apache.http.legacy'
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:cardview-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'com.google.android.exoplayer:exoplayer:r1.5.2'
        compile 'com.google.android.gms:play-services-auth:8.4.0'
        compile 'com.google.android.gms:play-services-maps:8.4.0'
        compile('com.mapbox.mapboxsdk:mapbox-android-sdk:3.0.0@aar') {
            transitive = true
        }
        compile files('libs/commons-lang3-3.3.2.jar')
    }
    
    apply plugin: 'com.google.gms.google-services'
    

    gradle-wrapper.properties:

    #Fri Jan 01 08:23:56 CST 2016
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
    

    Any ideas as to why gradle can't recognize my own app package name?


    EDIT:

    Ok, I'm getting different errors this time.

    Based on the link Shawn Thye provided, I added this to the bottom of app/build.gradle:

    apply plugin: 'com.google.gms.google-services'
    

    and leaving everything else what I listed previously I got this error:

    Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
    /Users/user/Documents/AndroidStudio/ExampleApp/app/build.gradle
    Error:(1, 1) A problem occurred evaluating project ':app'.
    > Failed to apply plugin [id 'com.android.application']
       > Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Documents/AndroidStudio/ExampleApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip
    Information:BUILD FAILED
    Information:Total time: 0.921 secs
    Information:1 error
    Information:0 warnings
    Information:See complete output in console
    

    and the Gradle console:

    Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
    
    Configuration on demand is an incubating feature.
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/user/Documents/AndroidStudio/ExampleApp/app/build.gradle' line: 1
    
    * What went wrong:
    A problem occurred evaluating project ':app'.
    > Failed to apply plugin [id 'com.android.application']
       > Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Documents/AndroidStudio/ExampleApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    BUILD FAILED
    
    Total time: 1.211 secs
    

    So, then I changed gradle-wrapper.properties as requested to "gradle-2.10-all" and got this error:

    Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
    google-services plugin could not detect any version for com.google.android.gms, default version: 8.3.0 will be used.
    please apply google-services plugin at the bottom of the build file.
    :clean
    :app:clean
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportAppcompatV72311Library
    :app:prepareComAndroidSupportCardviewV72311Library
    :app:prepareComAndroidSupportDesign2311Library
    :app:prepareComAndroidSupportGridlayoutV72311Library
    :app:prepareComAndroidSupportRecyclerviewV72311Library
    :app:prepareComAndroidSupportSupportV42311Library
    :app:prepareComDigitsSdkAndroidDigits192Library
    :app:prepareComFacebookAndroidFacebookAndroidSdk470Library
    :app:prepareComGoogleAndroidExoplayerExoplayerR152Library
    :app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
    :app:prepareComGoogleAndroidGmsPlayServicesBase840Library
    :app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
    :app:prepareComGoogleAndroidGmsPlayServicesMaps840Library
    :app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library
    :app:prepareComMapboxMapboxsdkMapboxAndroidSdk230Library
    :app:prepareComTwitterSdkAndroidTweetComposer102Library
    :app:prepareComTwitterSdkAndroidTweetUi180Library
    :app:prepareComTwitterSdkAndroidTwitter1110Library
    :app:prepareComTwitterSdkAndroidTwitterCore162Library
    :app:prepareIoFabricSdkAndroidFabric1310Library
    :app:prepareDebugDependencies
    :app:compileDebugAidl
    :app:compileDebugRenderscript
    :app:generateDebugBuildConfig
    :app:generateDebugAssets UP-TO-DATE
    :app:mergeDebugAssets
    :app:processDebugManifest
    :app:fabricGenerateResourcesDebug
    :app:generateDebugResValues UP-TO-DATE
    :app:processDebugGoogleServices
    Found com.google.android.gms:play-services-auth:8.4.0, but version 8.3.0 is needed for the google-services plugin.
    Found com.google.android.gms:play-services-maps:8.4.0, but version 8.3.0 is needed for the google-services plugin.
    :app:processDebugGoogleServices FAILED
    Error:Execution failed for task ':app:processDebugGoogleServices'.
    > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.
    Information:BUILD FAILED
    Information:Total time: 5.724 secs
    Information:1 error
    Information:0 warnings
    Information:See complete output in console
    

    And the Gradle console:

    Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
    
    Configuration on demand is an incubating feature.
    google-services plugin could not detect any version for com.google.android.gms, default version: 8.3.0 will be used.
    please apply google-services plugin at the bottom of the build file.
    Incremental java compilation is an incubating feature.
    :clean
    :app:clean
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportAppcompatV72311Library
    :app:prepareComAndroidSupportCardviewV72311Library
    :app:prepareComAndroidSupportDesign2311Library
    :app:prepareComAndroidSupportGridlayoutV72311Library
    :app:prepareComAndroidSupportRecyclerviewV72311Library
    :app:prepareComAndroidSupportSupportV42311Library
    :app:prepareComDigitsSdkAndroidDigits192Library
    :app:prepareComFacebookAndroidFacebookAndroidSdk470Library
    :app:prepareComGoogleAndroidExoplayerExoplayerR152Library
    :app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
    :app:prepareComGoogleAndroidGmsPlayServicesBase840Library
    :app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
    :app:prepareComGoogleAndroidGmsPlayServicesMaps840Library
    :app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library
    :app:prepareComMapboxMapboxsdkMapboxAndroidSdk230Library
    :app:prepareComTwitterSdkAndroidTweetComposer102Library
    :app:prepareComTwitterSdkAndroidTweetUi180Library
    :app:prepareComTwitterSdkAndroidTwitter1110Library
    :app:prepareComTwitterSdkAndroidTwitterCore162Library
    :app:prepareIoFabricSdkAndroidFabric1310Library
    :app:prepareDebugDependencies
    :app:compileDebugAidl
    :app:compileDebugRenderscript
    :app:generateDebugBuildConfig
    :app:generateDebugAssets UP-TO-DATE
    :app:mergeDebugAssets
    :app:processDebugManifest
    :app:fabricGenerateResourcesDebug
    :app:generateDebugResValues UP-TO-DATE
    :app:processDebugGoogleServices
    Found com.google.android.gms:play-services-auth:8.4.0, but version 8.3.0 is needed for the google-services plugin.
    Found com.google.android.gms:play-services-maps:8.4.0, but version 8.3.0 is needed for the google-services plugin.
    :app:processDebugGoogleServices FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:processDebugGoogleServices'.
    > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    BUILD FAILED
    
    Total time: 5.724 secs
    

    It's asking for the google-services plugin at the bottom of the build file, which it is already, and it's asking me to run 8.3.0 again... which I will do since that's the only thing working right now...

    Elise Pankaj 2022-08-16
    android - What is the difference between compileSdkVersion and targetSdkVersion?

    I have looked at the documentation for building with Gradle, but I'm still not sure what the difference between compileSdkVersion and targetSdkVersion is.

    All it says is:

    The compileSdkVersion property specifies the compilation target.

    Well, what is the "compilation target"?

    I see two possible ways to interpret this:

    1. compileSdkVersion is the version of the compiler used in building the app, while targetSdkVersion is the "API level that the application targets". (If this were the case, I'd assume compileSdkVersion must be greater than or equal to the targetSdkVersion?
    2. They mean the same thing. "compilation target" == "the API level that the application targets"
    3. Something else?

    I see that this question has been asked before, but the one answer just quotes the doc, which is what is unclear to me.

    Krisztina Promise 2022-08-14
    java - Android X: tools:replace specified at line: for attribute, but no new value specified

    I have tried many solutions on this website but still, the problem is not solved. The issue is due to Android X library. When I added Android X, this issue was resolved but it opened up new issue. How to fix this issue?

    Earlier this error was coming:

    Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:19:5-142:19 to override.
    

    After I added tools:replace="android:appComponentFactory", this error is came:

     java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
    at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:540)    
    at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:173)
    

    Merging Error (in Android Manifest):

    Error: tools:replace specified at line:2 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 1

    Manifest:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest
        package="com.example"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        tools:replace="allowBackup, android:appComponentFactory"
        android:allowBackup="false">
    
        ...
    
        <application
            android:name="com.example"
            android:icon="@mipmap/icon"
            android:debuggable="true"
            android:hardwareAccelerated="false"
            android:largeHeap="true"
            android:supportsRtl="true"
            android:theme="@style/AppTheme"
            android:allowBackup="false"
            tools:ignore="GoogleAppIndexingWarning,HardcodedDebugMode">
           ...
    
    Victor Wenceslaus 2022-08-17
    android - Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it"

    I updated my project to the latest Play services classpath 'com.google.gms:google-services:1.5.0-beta2'. I am also using the latest version of playservices in my app.gradle file as:

    compile 'com.google.android.gms:play-services-location:8.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    

    However when I compile, Gradle throws exception as follows

    Error:Execution failed for task ':app:processDebugGoogleServices'. > File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it.
    
    Baptist Slaven 2022-08-15
    android - WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'

    Suddenly when Syncing Gradle, I get this error:

    WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'. It will be removed at the end of 2019. For more information, see https://d.android.com/r/tools/task-configuration-avoidance Affected Modules: app

    I've got this build.gradle for the app module:

    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'com.google.gms.google-services'
    
    apply plugin: 'io.fabric'
    
    android {
        compileSdkVersion 28
        buildToolsVersion "28.0.2"
        defaultConfig {
            applicationId "..."
            minSdkVersion 21
            targetSdkVersion 28
            versionCode 1
            versionName "..."
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            versionNameSuffix = version_suffix
    
            [...]
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    
                [...]
            }
            debug {
                [...]
            }
        }
    }
    
    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"
        implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation "com.android.support:preference-v7:28.0.0"
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
        implementation 'com.google.android.material:material:1.0.0-rc02'
    
        [...]
    }
    

    I can compile the app correctly, but it's a bit bothering, and as I see it, something will stop working at the end of 2019. Any ideas of what is it and how to solve it?

    Yusup Waldemar 2022-08-15
    android - Exception : AAPT2 error: check logs for details
    Task :processDebugResources Failed to execute aapt com.android.ide.common.process.ProcessException: Failed to execute aapt
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
        at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
        at sun.reflect.GeneratedMethodAccessor200.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745) Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
        ... 47 more Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
        at com.android.builder.internal.aapt.v2.QueueableAapt2$$Lambda$489/579799618.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        ... 1 more Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411)
        at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
        at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
    

    Where will the AAPT2 logs be saved? While migrating to gradle-plugin-3.0.0, I am getting this exception.

    Sydnee Vesa 2022-08-18
    Could not find method android() for arguments

    I've been trying to import a project to Android Studio and this is where I am stuck, there is a similar question on Stack Overflow but it did not provide a solution to my particular error.

    This is my error log:

    C:\<some location>\build.gradle
    
    Error:(24, 1) A problem occurred evaluating root project '<project name>'.
    > Could not find method android() for arguments [build_4fli1jm76ubcnxesnhqnhie47$_run_closure3@6e71db85] on root project '<project name>'.
    Information:BUILD FAILED
    

    The Gradle sync messages are:

    Error:(24, 0) Gradle DSL method not found: 'android()' Possible causes:

  1. The project 'PoojaPeople' may be using a version of Gradle that does not contain the method. Gradle settings
  2. The build file may be missing a Gradle plugin. Apply Gradle plugin
  3. I'm not too sure where exactly this method android() is located. If it is the one located in Application's build.gradle file, I still don't exactly know where to go from here. Any help is appreciated.

    My build.gradle is

    buildscript {
        repositories {
            maven { url "http://dl.bintray.com/populov/maven" }
            mavenCentral()
        }
         dependencies {
            classpath 'com.android.tools.build:gradle:2.1.0'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            maven { url "http://dl.bintray.com/populov/maven" }
            mavenCentral()
    
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    android {
        compileSdkVersion 17
        buildToolsVersion '23.0.0'
    }
    dependencies {
        compile files('app/libs/junit-4.12-JavaDoc.jar')
    }
    apply plugin: 'maven'
    
    Margrit Simon 2022-08-17
    android - What are the differences between gradle assemble and gradle build tasks?

    If I am not wrong gradle assemble does run gradle assembleDebug and gradle assembleRelease, but I believe gradle build also does the same, so what are the different between them both?

    Amalia Sopheap 2022-08-16
    android - no cached version available for offline mode

    At office, I am behind a proxy. The internet access is restricted.

    So I performed a gradle sync at home and copied the folder ".gradle" present at C:\Users\username.gradle from my home PC to the same location on my office PC.

    Now on my office PC, I set gradle in Android Studio to "Work Offline" but still whenever I try to perform a gradle sync, I get an error stating

    Error: Could not download google-services.jar (com.google.gms:google-services:3.0.0): No cached version available for offline mode
    

    However on digging through the ".gradle" folder I was able to locate the google-service.jar file at

    C:\Users\username\.gradle\caches\modules-2\files-2.1\com.google.gms\google-services\3.0.0\32b833222c886ecfb37d79b1a05ce1eddb702db1
    

    I am not sure how to proceed. Please help.

    Noah Cas 2022-08-18
    Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)

    I am having this issue in Android studio.

    Error:Failed to resolve: com.android.support:appcompat-v7:27.+
    <a href="install.m2.repo">Install Repository and sync project</a><br><a href="open.dependency.in.project.structure">Show in Project Structure 
    dialog</a>
    

    My Android Studio is full of error android studio cannot identify libraries. The whole screen looks like this.

    image

    This is my Gradle code:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.1"
    
        defaultConfig {
            applicationId "com.example.hp.temp"
            minSdkVersion 21
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
        }
        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:27.+'
    }
    
    Pétur Gulnara 2022-08-19
    android - Gradle version 2.2 is required. Current version is 2.10

    I am trying to use gradle build. It gives me error saying that

    Failed to apply plugin [id 'com.android.library'] Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in /home/sanjeewa/workspace/Android/UVCCamera/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip

    But my gradle-wrapper.properties includes gradle-2.4-all.zip. I have changed it to gradle-2.2-all.zip Still same problem.

    When I run gradle -version in terminal Gradle 2.10 shows as version.

    How to solve that error??

    my build gradle file is

     buildscript { 
       repositories { 
           jcenter() 
       } 
       dependencies { 
           classpath 'com.android.tools.build:gradle:1.3.0' 
       } 
     } 
    
     allprojects { 
       repositories { 
           jcenter() 
       } 
     } 
    
    Karthikeyan Dimos 2022-08-17
    android - Gradle build failing after update to 3.0

    I've recently updated the gradle version of my project from 2.14.1 to 3.0. Since then the gradle build is failing every time with this error:

    Error:Cause: org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection Possible causes for this unexpected error include:

    • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
    • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
    • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
    In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

    I've searched google and found some solutions like this one but nothing is working. Does anyone know how to fix it?

    Gert Branimira 2022-08-18
    Why are there two build.gradle files in an Android Studio project?

    After having imported an Eclipse project into Android Studio, I see two build.gradle files:

    1 - <PROJECT_ROOT>\build.gradle
    2 - <PROJECT_ROOT>\app\build.gradle
    

    The first version is shorter, the second version contains definitions for compileSdkVersion, etc.

    What is the purpose behind having two separate files? Are there separate build tasks?

    Alícia Ugochukwu 2022-08-16
    android - Could not find method leftShift() for arguments after updating studio 3.4

    After updating studio 3.4 and Gradle version to 5.1.1 I got the error on my task as Could not find method leftShift()

    My task:

    task incrementBetaVersion << {
        println("Incrementing Beta Version Number...")
        incrementVersionNumber('BetaVersionNumber')
        println("Incrementing Beta Version Number...")
        incrementVersionName('BetaVersionName')
    }
    

    I got the error for the left shift operator << in the line.

    How to resolve this error?

    Iorwerth Endrit 2022-08-16