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

chore(#324): upgrading to android 13 #325

Merged
merged 5 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def getVersionName = {
}

android {
compileSdkVersion 31
compileSdkVersion 33
buildToolsVersion '30.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
Expand All @@ -104,7 +104,7 @@ android {

defaultConfig {
//noinspection OldTargetApi
targetSdkVersion 31
targetSdkVersion 33
minSdkVersion 21 // Android 5.0
versionCode getVersionCode()
versionName getVersionName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public class RequestStoragePermissionActivity extends FragmentActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
trace(this, "RequestStoragePermissionActivity :: READ_EXTERNAL_STORAGE permission is ignored in Android 13+.");
setResult(RESULT_OK, createResponseIntent());
finish();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just in case if someone is wondering

You can call finish() from within this function, in which case onDestroy() will be immediately called after onCreate(Bundle)

source

return;
}

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.request_storage_permission);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.stream.IntStream;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 31) // ToDo: Remove when upgrading robolectric
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're getting this error because our current version of robolectric doesn't support target 33

java.lang.IllegalArgumentException at RobolectricTestRunner.java:260
        Caused by: java.lang.IllegalArgumentException at DefaultSdkPicker.java:118

In this link, they recommend to use Config(sdk = 31) to make the test pass as a temporary fix.

public class SmsSenderTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -17,6 +18,7 @@
import java.util.stream.Stream;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 31) // ToDo: Remove when upgrading robolectric
public class FilterableListAdapterTest {
private static final List<Map<String, ?>> SERVER_DATA = List.of(
Map.of("name", "first server name", "url", "https://my.first.server")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import org.mockito.junit.MockitoRule;
import org.mockito.quality.Strictness;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 31) // ToDo: Remove when upgrading robolectric
public class AsyncExecutorTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = 31) // ToDo: Remove when upgrading robolectric
public class VibratorTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
Expand Down