Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio / Gradle strange behaviour

I am experiencing a strange bug with Android Studio with new projects since yesterday (haven't even updated anything):

  • What went wrong: Could not determine the dependencies of task ':app:mockableAndroidJar'.

    java.lang.NullPointerException (no error message)

My build.gradle file doesn't seem to properly recognize Strings:

buildToolsVersion cannot be applied to (java.lang.String)

and puts an error in every line that assigns a String.

Here's my build.gradle (nothing special):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '23.0.2'

    defaultConfig {
        applicationId "com.dkslf.fragmenttest"
        minSdkVersion 15
        targetSdkVersion 22
        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:22.0.0'
    compile 'com.android.support:support-v13:22.0.0'
}

What could be wrong here?

EDIT: A combination of restarting the PC, restarting Android studio and randomly punching my keyboard seemed to solve the issue for now. I'll leave the question open though and see if I can reproduce it.

like image 555
fweigl Avatar asked May 29 '26 16:05

fweigl


1 Answers

Recently ran into this but is not pretty sure if we are on the same boat. However, this is how I fixed that mockableAndroid problem:

-        classpath 'com.android.tools.build:gradle:1.3.0'
+        classpath 'com.android.tools.build:gradle:2.0.0-beta6'
like image 81
Teng-pao Yu Avatar answered Jun 01 '26 07:06

Teng-pao Yu