android-hidden-api icon indicating copy to clipboard operation
android-hidden-api copied to clipboard

clean Error:Execution failed for task ':app:mockableAndroidJar'. > java.lang.NullPointerException (no error message) in Android Studio 2.2

Open jp1017 opened this issue 9 years ago • 24 comments

Error:

20161004103811

gradle:

··· compileSdkVersion 23 buildToolsVersion "23.0.3" ···

This error comes when using your lib of android-23, and it disappear when using the original android-23.jar.

We know task ':app:mockableAndroidJar' is experimental in Android Studio 2.1.3, and I close this.

Android Studio clean 时产生 Error:Execution failed for task ':app:mockableAndroidJar' > java.lang.NullPointerException (no error message)

but google makes this stable in Android Stuido 2.2, and I can't this.

This error comes for some days until today I found this may be result from your lib.

jp1017 avatar Oct 04 '16 03:10 jp1017

I also still don't know what happens with hidden API v23. On some users, this error doesn't appear. Otherwise, some users are facing this problem. For me, I don't face this problem.

Let's try a new framework.jar from different devices, this trick may fix the problem. The current jar was picked from SGS3 LTE with BlissPop ROM, Android 6.0.1, Bliss version v6.2. You can find the jar in from Android 6.0 devices. Upload it to me and I'll make a new modified android.jar.

anggrayudi avatar Oct 09 '16 16:10 anggrayudi

I also met this problem today. Are you have solution now ?

Android Studio 2.2.2

benniaobuguai avatar Nov 07 '16 11:11 benniaobuguai

I met this problem days ago, for now I clean all the files by hand every every time...., and this do makes me annoy. Does anyone find the solution about this ?

KaelLuo avatar Nov 08 '16 06:11 KaelLuo

I have this issue as well as I'm using a modified android.jar (which has all the hidden API revealed). I don't use the unit testing and there's no apparent way to disable it in Android Studio 2.2.2, so I found a workaround for this problem:

  1. Go to File -> Settings -> Build, Execution, Deployment -> Compiler
  2. Add to "Command-line Options": -x :app:prepareReleaseUnitTestDependencies -x :app:mockableAndroidJar -x :app:compileReleaseUnitTestSources
  3. Press "OK" and try to Rebuild Project again.

Now the unit testing compilation tasks will always be skipped and no errors will be thrown.

IgorEisberg avatar Dec 03 '16 02:12 IgorEisberg

@IgorEisberg wow, thanks, :+1: :smile: it works. I just using

-x :app:mockableAndroidJar

jp1017 avatar Dec 03 '16 02:12 jp1017

@jp1017 That works too, I just feel as if disabling all of the "unit testing" tasks is better because it's also faster (you have 3 tasks less instead of just 1 task less). Enjoy!

IgorEisberg avatar Dec 03 '16 02:12 IgorEisberg

Yes, but I can't disable others for I using Tinker which using thems. :disappointed:

jp1017 avatar Dec 03 '16 03:12 jp1017

@jp1017 Oh fair enough. Well, at least the problem's solved for now! Gradle is such a buggy thing... -_-

IgorEisberg avatar Dec 03 '16 03:12 IgorEisberg

@IgorEisberg I add -x :app:prepareReleaseUnitTestDependencies -x :app:mockableAndroidJar -x :app:compileReleaseUnitTestSources to my settings but it still show Error:java.lang.NullPointerException (no error message)
Information:Gradle tasks [:api:generateDebugSources, :api:generateDebugAndroidTestSources, :api:mockableAndroidJar, :api:prepareDebugUnitTestDependencies, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :core:generateDebugSources, :core:mockableAndroidJar, :core:prepareDebugUnitTestDependencies, :core:generateDebugAndroidTestSources, :library:generateDebugSources, :library:generateDebugAndroidTestSources, :library:mockableAndroidJar, :library:prepareDebugUnitTestDependencies, :model:generateDebugSources, :model:mockableAndroidJar, :model:prepareDebugUnitTestDependencies, :model:generateDebugAndroidTestSources]

tchgithub avatar Dec 05 '16 07:12 tchgithub

@tchgithub

:api:mockableAndroidJar,

For this, you should add below to your setting:

-x :api:mockableAndroidJar

For others, do it like this. enjoy it. :smile:

jp1017 avatar Dec 06 '16 00:12 jp1017

Another workaround: In your project's main build.gradle, inside "allprojects":

allprojects {
    repositories {
        jcenter()
    }
    gradle.taskGraph.whenReady {
        tasks.each { task ->
            if (task.name.equals('mockableAndroidJar')) {
                task.enabled = false
            }
        }
    }
}

IgorEisberg avatar Dec 08 '16 02:12 IgorEisberg

Another workaround: In your project's main build.gradle, inside "allprojects":

@IgorEisberg :+1: After add this to my build.gradle, I found this in gradle console:

:app:mockableAndroidJar SKIPPED

It worked too. :+1: , Thank you.

More important, this would work for other modules, it may worked for @tchgithub

jp1017 avatar Dec 08 '16 02:12 jp1017

Yup, it covers the whole project, no matter how you name your modules. It's also more portable since it'll work immediately even if you transfer the project to another computer. To skip all Test tasks you can change the "if" statement to: if (task.name.contains('Test') || task.name.equals('mockableAndroidJar')) {

IgorEisberg avatar Dec 08 '16 03:12 IgorEisberg

I do like this, but it didn't work. Please can you give another way to resolve it? Thx a lot! @jp1017

hyy007 avatar Dec 19 '16 07:12 hyy007

@hyy007 May be you should show some codes.

jp1017 avatar Dec 19 '16 11:12 jp1017

java.lang.NullPointerException(no error message). That's the error yestoday, and then when I rebuild the project, it shows: " Error:org.gradle.api.internal.changedetection.state.FileCollectionSnapshotImpl cannot be cast to org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter$OutputFilesSnapshot 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." But I don't know the where's the right question... I restarted the Android Studio or restart the PC (Windows 7 system), it didn't help, either~ ‘(>﹏<)′ wuwu~ @jp1017

hyy007 avatar Dec 20 '16 07:12 hyy007

@hyy007 what for other projects? gradle version? just try any you can.

jp1017 avatar Dec 20 '16 10:12 jp1017

Thank you for your answers for me. I checked out a new version and reopened it, then it went OK just like before... And I still don't know what's the question....I'm not sure if it is the SVN's problem when I work with my teammates.

hyy007 avatar Dec 22 '16 08:12 hyy007

Try Hidden API v24 and this problem will be solved.

anggrayudi avatar Jan 31 '17 10:01 anggrayudi

@anggrayudi 25 still existed while the first compiling.

jp1017 avatar Apr 18 '17 00:04 jp1017

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed with multiple errors, see logs

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })

compile 'com.victor:lib:1.0.4'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:cardview-v7:25.0.1'
compile 'de.hdodenhof:circleimageview:2.1.0'

compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
testCompile 'junit:junit:4.12'
compile 'com.braintreepayments.api:drop-in:3.+'
compile 'com.github.esafirm.android-image-picker:imagepicker:1.3.2'
compile 'com.github.bumptech.glide:glide:3.7.0'

compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.android.support:support-v4:25.0.1'


compile 'com.opentok.android:opentok-android-sdk:2.10.+'
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.code.gson:gson:2.+'

compile(name:'instaply-sdk-1.0.2', ext:'aar')

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

Any suggestion

xicomdev avatar Aug 22 '17 07:08 xicomdev

I have faced same issue and i have tried above all the answers but it want work for me. I think its worked in other cases. After 2 to 3 hours i will got the solution i am just extending the answer so i post this comment. In case my current project minimumSdk 15 and my modal project or dependency library's minimumSdk 18 so i have change my current project minimumSdk 18 and it worked for me. So check your library project's version

aivision369 avatar May 23 '18 13:05 aivision369

@IgorEisberg wow thanks dude.. :+1: just try your trick and my problem get solved, you save my day..

-x :app:prepareReleaseUnitTestDependencies -x :app:mockableAndroidJar -x :app:compileReleaseUnitTestSources

cikal avatar Jun 09 '19 20:06 cikal

@cikal Glad it's still useful!

IgorEisberg avatar Jun 09 '19 21:06 IgorEisberg