Android build error DexIndexOverflowException - android-studio

I am not able to build my Android app. I keep seeing this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
However, it doesn't tell me which gradle dependencies are causing my build to fail. How do I go about troubleshooting this?
Igor

It seems the only way to solve my dilemma was to enable multidex in my project:
In AndroidManifest.xml:
<application
android:name="android.support.multidex.MultiDexApplication"
In app's build.gradle:
dependencies {
compile 'com.android.support:multidex:1.0.0'
and
defaultConfig {
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
multiDexEnabled true

Related

ERROR: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.prop

I want to use firebase remote config library(com.google.firebase:firebase-config:19.1.4). When I add its dependency into app gradle, I'm getting following error.
ERROR: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.core:core:1.0.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.1.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
Affected Modules: app
My app gradle is as follows:
android {
compileSdkVersion 27
defaultConfig {
applicationId "in.co.gramafone.client"
minSdkVersion 16
targetSdkVersion 27
versionCode 19
versionName "1.1.1"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
...
}
I'm extensively using android support libraries(com.android.support:appcompat-v7:27.1.1). So, if I'm enabling androidX by putting below lines to solve this, there are a lot of other library conflicts are reporting(I can post if those errors are necessary)
android.useAndroidX=true
android.enableJetifier=true
Please let me know if any other information is necessary to understand the actual issue.
NB:I'm a newbie in the world of android
android.useAndroidX=true
android.enableJetifier=true
You need to add these to your gradle.properties file in your Gradle Scripts Folder.
I am not 100% sure, but this should work.
first Open your Project gradle scripts>> then open gradle.properties And Finally paste this two line code
android.useAndroidX=true
android.enableJetifier=true

React native build failed for android RN 0.57.1

I have read the installation guide and setup everything. Payment is working fine with iOS but android is still failed. I have used everything to fix the issue but still facing the same issue.
android/build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "17.0.0"
}
}
package.json
"react": "16.5.0",
"react-native": "0.57.1",
"tipsi-stripe": "^8.0.0-beta.4",
android/app/build.gradle
implementation 'com.android.support:design:27.1.0'
compile project(':tipsi-stripe')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
Androidmanifest.xml
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
But the android build failed everytime and i tried everything to resolve this nothing worked.
Here is my issue:
> Task :tipsi-stripe:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
error: resource style/Theme.MaterialComponents.Light.DarkActionBar (aka com.app.customer:style/Theme.MaterialComponents.Light.DarkActionBar) not found.
error: resource style/Theme.MaterialComponents (aka com.app.customer:style/Theme.MaterialComponents) not found.
error: resource style/Widget.MaterialComponents.Button.TextButton (aka com.app:style/Widget.MaterialComponents.Button.TextButton) not found.
error: resource style/Widget.MaterialComponents.Button (aka com.mybeautysquad.customer:style/Widget.MaterialComponents.Button) not found.
error: resource style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense (aka com.app:style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense) not found.
/Users/admin/.gradle/caches/transforms-2/files-2.1/6b75366950aa0bad3a0940bb5e9e84dd/res/values/values.xml:87:5-65: AAPT: error: style attribute 'attr/boxBackgroundColor (aka com.app.customer:attr/boxBackgroundColor)' not found.
error: failed linking references.
Please let me know if anyone can help me into this. It's very important to resolve this issue because iOS app is working fine the only android still live with old version.
try changing this
implementation 'com.android.support:design:27.1.0'
to
implementation 'com.android.support:design:28.0.0'
also
targetSdkVersion = 27
change it to
targetSdkVersion = 28
do a clean build and try again.
Let me know if that works.

How do I resolve this ProductFlavours error

This is the first time I've used Android Studio and I can't build this app.
Can anyone tell me how to fix this code?
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "org.settingsdeployer"
minSdkVersion 15
targetSdkVersion 21
versionCode 4
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
applicationId "org.settingsdeployer"
versionCode 4
versionName "1.2"
}
french {
applicationId "org.settingsdeployer"
versionCode 5
versionName "1.2_fr"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
I'm getting these errors when it tries to sync:
ERROR: All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
Affected Modules: org.settingsdeployer
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: org.settingsdeployer
I made the requested changes and it sync'd but now I can't make an apk:
That's great, it sync'd the build without errors but now when I try to generate an apk i get more errors. I have no idea what I'm doing!
UPDATE:
After adding flavorDimensions it sync'd the build without errors but now when I try to generate an apk i get more errors. I have no idea what I'm doing!. Here is the error log:
Executing tasks: [:org.settingsdeployer:assembleNormalRelease]
Task :org.settingsdeployer:preBuild UP-TO-DATE Task :org.settingsdeployer:preNormalReleaseBuild UP-TO-DATE Task :org.settingsdeployer:compileNormalReleaseAidl NO-SOURCE Task :org.settingsdeployer:compileNormalReleaseRenderscript UP-TO-DATE Task :org.settingsdeployer:checkNormalReleaseManifest UP-TO-DATE Task :org.settingsdeployer:generateNormalReleaseBuildConfig UP-TO-DATE Task :org.settingsdeployer:prepareLintJar UP-TO-DATE Task :org.settingsdeployer:generateNormalReleaseSources UP-TO-DATE Task :org.settingsdeployer:javaPreCompileNormalRelease UP-TO-DATE Task :org.settingsdeployer:mainApkListPersistenceNormalRelease Task :org.settingsdeployer:generateNormalReleaseResValues UP-TO-DATE Task :org.settingsdeployer:generateNormalReleaseResources UP-TO-DATE Task :org.settingsdeployer:mergeNormalReleaseResources FAILED
FAILURE: Build failed with an exception.
What went wrong: Could not resolve all files for configuration ':org.settingsdeployer:_internal_aapt2_binary'.
Could not find com.android.tools.build:aapt2:3.3.1-5013011. Searched in the following locations:
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar Required by: project :org.settingsdeployer
Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I'm getting these errors when it tries to sync: ERROR: All flavors
must now belong to a named flavor dimension. Learn more at
https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
Affected Modules: org.settingsdeployer
The flavor dimension problem is happened because you haven't add the flavorDimensions to your build.gradle. There must be at least one flavorDimensions. Something like this:
android {
...
defaultConfig {...}
buildTypes {
debug{...}
release{...}
}
// you need to specifies one flavor dimension.
flavorDimensions "version"
productFlavors {
normal {
// This property is optional if you are using only one dimension.
dimension "version"
applicationId "org.settingsdeployer"
versionCode 4
versionName "1.2"
}
french {
dimension "version"
applicationId "org.settingsdeployer"
versionCode 5
versionName "1.2_fr"
}
}
}
more details at Configure build variants
WARNING: Configuration 'compile' is obsolete and has been replaced
with 'implementation' and 'api'. It will be removed at the end of
2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: org.settingsdeployer
This warning is telling that we need to use either api or implementation to replace the compilation when adding dependencies. So, change the dependencies block to something like this;
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:21.0.3'
}

Generate Signed APK using Android Studio 3.1.3

I am pretty sure that I have checked all the possible duplicate questions and none solve my problem. I have instant run turned off, I have minfy and shrink set to false. I have cleaned. The keyfile exists and worked perfectly on a previous release of this app. I have tried running the compile with --info but it does not give me any hints as the the problem. The error is:
Execution failed for task ':app:packageRelease'.
Failed to read key myreleasekey from store "C:\Users\Mel\AndroidStudioProjects\tourbuilderkeystore.jks": Cannot recover key
My build gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.myguidedtours.www.tourguide"
minSdkVersion 16
targetSdkVersion 27
versionCode 10
versionName '1.10'
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
// implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-fragment:27.1.1'
implementation 'com.android.support:support-compat:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-tasks:15.0.1'
implementation 'com.google.android.gms:play-services-basement:15.0.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation "com.android.support:exifinterface:27.1.1"
implementation files('libs/PdfViewer.jar')
}
I have been sweating over this for two days - I hope you can help.
Just in case there's someone out there as stupid as me. The prompt for Generate a Signed APK in Android Studio, does not tell you if the passwords you supply are good or bad. I must have miss-keyed one of them, then, because I ticked the remember passwords option, it failed every time I tried to run it. There is no hint that the password may be wrong - usually when you enter a bad password you get immediate feedback.

Android Studio :Null pointer exception when assembleDebugUnitTest gradle task is run

I am trying to run a simple JUNIT test for a test class in android studio. Build goes fine. When i try to run the JUNIT test i get the following error
*
Execution failed for task ':app:mockableAndroidJar'.
> java.lang.NullPointerException (no error message)
*
When i dumped the stacktrace i get the following. I am clueless as to why this is happening.
:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mockableAndroidJar'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteAc
tionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTa
skExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecu
tionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskEx
ecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecut
er.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptyS
ourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithN
oActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecut
er.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMost
OnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:31
0)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(Abst
ractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(Abst
ractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTask
PlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java
:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.ja
va:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:3
7)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:14
9)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessB
uildActionExecuter.java:90)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.
java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.
java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.
java:28)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSugges
tingBuildActionExecuter.java:50)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSugges
tingBuildActionExecuter.java:27)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineAct
ionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineAct
ionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.jav
a:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.jav
a:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFacto
ry.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFacto
ry.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at org.objectweb.asm.tree.ClassNode.accept(Unknown Source)
at com.android.builder.testing.MockableJarGenerator.rewriteClass(MockableJarGenerator.java:134
)
at com.android.builder.testing.MockableJarGenerator.createMockableJar(MockableJarGenerator.jav
a:91)
at com.android.build.gradle.internal.tasks.MockableAndroidJarTask.createMockableJar(MockableAn
droidJarTask.groovy:50)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAct
ion.doExecute(AnnotationProcessingTaskFactory.java:226)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAct
ion.execute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAct
ion.execute(AnnotationProcessingTaskFactory.java:208)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:589)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:572)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteAct
ionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteAc
tionsTaskExecuter.java:61)
... 49 more
Test Environment used:
Environment: 1.2.2
SDK Version : API 21
Build tools 22.0.1
Android Plugin version : 1.2.3
Gradle version : 2.5
JDK : 1.7.0_79
Can you please help me out with this? Is there any problem with my setup?
Build Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.krishnaswamyna.testmathsapplication"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:leanback-v17:22.2.1'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.0.31-beta'
testCompile 'org.robolectric:robolectric:3.0'
}
Jus delete the .gradle file in the project
I also had the same issue since a couple of weeks. I saw a hint about the issue being about the SDK from here.
What worked for me was to simply remove the SDK through the SDK Manager and then reinstalling it. You might also have to clean the project and/or invalidate cashes and restart Android Studio, between removing and reinstalling the SDK.
I had the same problem when i installed the Android Studio 2.0.
Uncheck Enable all test artifacts in:
File-> Settings-> Build, Execution, Deployement->Build Tools ->
Gradle-> Experimental gradle
Info: link
Clean the build and rebuild the app this might work and fix the issue. This gradle errors might come due to some old edited files just do the above said.

Resources