Skip to content

Instantly share code, notes, and snippets.

View rafaeltoledo's full-sized avatar

Rafael Toledo rafaeltoledo

View GitHub Profile
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Android Application Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
<exclude-pattern>.*/R.java</exclude-pattern>
<exclude-pattern>.*/gen/.*</exclude-pattern>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:app:pmd’.
> 1 PMD rule violations were found. See the report at: file:///Users/rafael/Project/quality-tools/app/build/reports/findbugs/findbugs.html
* Try:
Run with — stacktrace option to get the stack trace. Run with — info or — debug option to get more log output.
BUILD FAILED
lint --list
android {
...
lintOptions {
disable 'InvalidPackage'
}
}
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="InvalidPackage" severity="ignore" />
</lint>
android {
lintConfig {
lintConfig file("${project.rootDir}/config/lint.xml")
}
}
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private TextView text;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(this);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class);
@Test
public void shouldUpdateTextAfterButtonClick() {
onView(withId(R.id.button)).perform(click());
android {
...
buildTypes {
debug {
testCoverageEnabled true
}
...
}
}