score:0
i guess you're using an incompatible robolectric and android sdk versions:
with robolectric 3, you should use :
myactivity activity = robolectric.setupactivity(myactivity.class);
score:1
i’m using android studio 3.1.1 and also got a nullpointerexception when calling robolectric.buildactivity(…).create().get(). then i found the following link:
http://robolectric.org/getting-started/
where it is recommended to add the following block to your app’s build.gradle file:
android {
testoptions {
unittests {
includeandroidresources = true
}
}
}
with this addition the exception was avoided. i’m not sure if this solution works for your case. just sharing.
Source: stackoverflow.com
Related Query
- Robolectric - BuildActivity(MyActivity.class).create() throw NullPointerException
- How can Eclipse create a class with unresolved compilation problems?
- Automatically create builder for class in Eclipse
- Quickly create class from an interface in eclipse
- Eclipse, shortcut to create new Java class
- create a new class do not appear right click menu eclipse
- Failed to create BuildConfig class error message in eclipse
- Android Eclipse issue Failed to create BuildConfig class
- How to create a custom 'new class wizard' for Eclipse?
- How to Create class diagram from Code?
- ClassNotFoundException: Didn't find class "com.example.app.MainActivity" for every app I create
- Eclipse can't create Groovy class in 4.3.2
- GWT automatically create Java Class from UiBinder
- Create a persistent class in eclipse for abap (ADT)
- Eclipse: Create jar containing one class + dependencies
- Batch Create Java Class Stubs
- HTTP 500 - Cannot create JDBC driver of class '' for connect URL 'null'
- How to create Configuration class with Beans in spring boot?
- Java - Create a web service from an available class
- Eclipse Create Multiple Class at Once
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] Unable to load class [org.postgresql.Driver]
- Create eclipse template for class members
- Simple ATL transformation - create new classes as children of a certain class
- how to create an eclipse plugin to auto create read/ writeExternal methods of existing class
- How can I create a subclass of an abstract class automatically in Eclipse in Java?
- Have a class that only has main. Should I create an object and call obj.Main() or ClassObj.Main()?
- Libgdx Screen NullPointerException when referencing another class
- How to create JUnit test cases for Guava's ArrayListMultiMap class in Eclipse?
- Not able to create executable jar for webdriver+TestNg project which does not contain main method in any class
- Create jar of a class in order to send objects JAVA
More Query from same tag
- Eclipse: No repository found at xyz (ProvisionException)
- NoClassDefFoundError when running app in emulator/phone [Update to previous question]
- FDT: An internal error occurred during debugging
- How to recover my Eclipse Workspace - Everything is gone?
- Eclipse css content-assist (bootstrap)
- How to iterate over a method parameters in an eclipse template?
- How can I get Eclipse to store .class files in a folder outside the Project folder where I store the .java source files?
- error when launching eclipse on Mac
- Linking css built in eclipse to jsp and getting results
- How to execute two java projects at one go in eclipse?
- Eclipse neon weird behaviour in Ubuntu 16.04 LTS
- How to fix Eclipse Luna hanging/stuck on splash screen before asking for workspace?
- Call the php function inside the html tag
- you do not have the permissions necessary to view the contents of eclipse
- Tomcat 6 Eclipse config -- Server Locations locked for edit
- Code after glfwTerminate() never runs
- Google Play Services Imported but still gives error
- Eclipse CDT - hover window recursion / nested hover windows
- Trying to develop on forge 1.12 using the mdk in eclipse. getting error with just base imported project
- Android NDK Confusion
- How do I change certain plugins under Eclipse 3.6 product export to deploy as exploded Jars?
- Cannot type ampersand (&) character into java editor in Eclipse
- Where is the odb file?
- Maven package structure changed after build Eclipse
- Java separate methods and final variables
- Hosting Eclipse Program inside C# Program
- Source Folder in Runnable Jar Disappearing
- Generating junit xml report from Android in Eclipse
- Extract class with imported classes in eclipse
- What is the purpose of Resolving model jre:call:zip:1.0.0?