Issue
binding is NULL when running "ApplicationTest" but is correct when running "app". This post doesn't work.
ApplicationTest
@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
@Rule
public ActivityTestRule<LoadingActivity> mActivityRule =
new ActivityTestRule<>(LoadingActivity.class);
@Test
public void loginClickMarkerAndUploadDamageReport() {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
//Some initialization code, and then LoginActivity gets started by the App
//This works..
onView(withId(R.id.user_email)).perform(replaceText("[email protected]"));
}
}
LoginActivity
public class LoginActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final LoginActivityBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_login);
}
}
activity_login
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="dataSource"
type="nl.brandmkrs.damageapp.model.User" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:id="@+id/user_email"
android:text="@{dataSource.password}"/>
</LinearLayout>
</layout>
build.gradle
defaultConfig {
minSdkVersion 17
targetSdkVersion 25
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
productFlavors {
// The actual application flavor
production {
minSdkVersion 17
}
// Test application flavor for UIAutomator tests
uiTest {
minSdkVersion 18
}
}
dataBinding {
enabled = true
}
Output:
E/MonitoringInstrumentation: Exception encountered by: nl.brandmkrs.damageapp.view.LoginActivity@d8d4afd. Dumping thread state to outputs and pining for the fjords. java.lang.NullPointerException: Attempt to read from field 'android.widget.VideoView nl.brandmkrs.damageapp.databinding.LoginActivityBinding.videoView' on a null object reference at nl.brandmkrs.damageapp.view.LoginActivity.onCreate(LoginActivity.java:96)
Solution
Updating
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
to
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
Solved the problem...
Answered By - Jim Clermonts
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.