Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work around shrinked resources #148

Merged
merged 3 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/content/test/TestMinimized.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,30 @@ However we could miss some bugs, because debug(not release) sources included, so
## Sample

You can check configuration in `:test-app` module.

## If you still have problems

Keeper can't do all the work here, so if you still can't run test, check these:
dsvoronin marked this conversation as resolved.
Show resolved Hide resolved

### Dynamically referenced resources

You can see in `PageObjectTest`, that we referenced `R.layout.page_object_1`, dynamically creating layout.\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled shrinkResourses delete resourses referenced only from tests.
Example in PageObjectTest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left as it was, i can hardly parse new variant

These layouts referenced nowhere in app code, so if `shrinkResources` enabled you will face strange error:

```text
error inflating class x
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.x" on path: DexPathList
```

What it really hides, `R.layout.page_object_1` got shrinked to:

```xml
<x />
```

If this is your case, add these resources to `res/raw/keep.xml` like this:

```xml
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@layout/page_object*"/>
```
2 changes: 1 addition & 1 deletion subprojects/android-test/test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ android {
setMatchingFallbacks("debug")

isMinifyEnabled = true
isShrinkResources = false
isShrinkResources = true

proguardFiles(getDefaultProguardFile(ProguardFile.DONT_OPTIMIZE.fileName), "proguard-rules.pro")
}
Expand Down
3 changes: 3 additions & 0 deletions subprojects/android-test/test-app/src/main/res/raw/keep.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@layout/page_object*"/>