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

Update Android Version #717

Merged
merged 10 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
31 changes: 20 additions & 11 deletions brouter-routing-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

plugins {
id 'base'
id 'com.android.application'
id 'checkstyle'
id 'brouter.version-conventions'
}

android {
compileSdkVersion 33
compileSdk 34

base {
archivesName = "BRouterApp." + project.version
}

defaultConfig {
namespace 'btools.routingapp'
Expand All @@ -17,10 +22,9 @@ android {
versionName project.version

resValue('string', 'app_version', defaultConfig.versionName)
setProperty("archivesBaseName", "BRouterApp." + defaultConfig.versionName)

minSdkVersion 14
targetSdkVersion 33
minSdkVersion 21
targetSdkVersion 35
Copy link
Contributor

Choose a reason for hiding this comment

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

Current target API level requirement is 34:
https://developer.android.com/google/play/requirements/target-sdk

35 will not be required until August 2025.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@devemux86
That is correct. But my Studio tells me 'not targeting the latest versions of Android' when I use API level 34.

Anyway the main problem I see is the minSdkVersion.
With using new libraries, level 21 is required.

When going back with e.g. androidx.appcompat:appcompat:1.6.1 we could go back to level 19. This will bring an error: Cannot fit requested classes in a single dex file for deprecated classes.
But setting minifyEnabled false for debug mode takes care of this. And should not bring to much trouble in development because we set all BRouter classes to keep in last update.

What do you think? Going back?

BTW: Is there still an IDEA problem with
classpath 'com.android.tools.build:gradle:8.3.1

Copy link
Contributor

Choose a reason for hiding this comment

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

@afischerdev

The latest stable version is compile and target SDK 34.
Android 15 will be released the next months.

With using new libraries, level 21 is required.

This should be normal, we can update the dependencies and use min sdk 21.

Is there still an IDEA problem with

Unfortunately we still have to use version 8.2.2 for IDEA.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be normal, we can update the dependencies and use min sdk 21.

Well, I would prefer that. For me it is cleaner.

@ALL
Other comments for the min version API level 21?

Copy link
Collaborator

Choose a reason for hiding this comment

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

API 21 was released 10 years ago and is the latest version supported by Google Play Services. This shouldn't affect many devices so I think it's a good idea to increase the minSdkVersion. I think targetSdkVersion should be API 34 because API 35 is only released as preview.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll change the version back. I don't mind.
But no, there is no preview Android installed, it's a 35 rev. 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

Android 15 is currently on Beta 4.
https://developer.android.com/about/versions/15/overview

Also we need first to compile with sdk 35 and then advance the target to 35.
There is no need to hurry until August 2025.

The current requirement for August 2024 is just the target 34.

Copy link
Contributor

Choose a reason for hiding this comment

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

IDEA has been updated and now supports the latest Android Gradle plugin 8.5.1.


testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -96,22 +100,22 @@ repositories {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'androidx.work:work-runtime:2.8.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'com.google.android.material:material:1.12.0'

implementation project(':brouter-mapaccess')
implementation project(':brouter-core')
implementation project(':brouter-expressions')
implementation project(':brouter-util')
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.preference:preference:1.2.1'

testImplementation 'junit:junit:4.13.2'

androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.work:work-testing:2.8.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.work:work-testing:2.9.0'
}

gradle.projectsEvaluated {
Expand Down Expand Up @@ -159,3 +163,8 @@ task generateReadmesZip(type: Zip) {
}
destinationDirectory = layout.buildDirectory.dir("assets")
}

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['-Xlint:unchecked']
options.compilerArgs += ['-Xlint:deprecation']
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package btools.routingapp;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;

import android.os.Build;
import android.os.Environment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package btools.routingapp;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import android.content.Context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

public class BInstallerActivity extends AppCompatActivity {

private static final String TAG = "BInstallerActivity";

private static final int DIALOG_CONFIRM_DELETE_ID = 1;
private static final int DIALOG_CONFIRM_NEXTSTEPS_ID = 2;
private static final int DIALOG_CONFIRM_GETDIFFS_ID = 3;
Expand Down Expand Up @@ -216,7 +218,7 @@ public void downloadAll(ArrayList<Integer> downloadList, int all) {
Object data;
Toast.makeText(this, R.string.msg_too_much_data, Toast.LENGTH_LONG).show();

e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
return;
}

Expand All @@ -242,10 +244,9 @@ public void downloadAll(ArrayList<Integer> downloadList, int all) {
//WorkManager.getInstance(getApplicationContext()).cancelWorkById(downloadWorkRequest.getId());
}
} catch (ExecutionException e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
} catch (InterruptedException e) {
Log.d("worker", "canceled " + e.getMessage());
//e.printStackTrace();
Log.d(TAG, "canceled " + e.getMessage());
}

workManager
Expand Down Expand Up @@ -516,10 +517,10 @@ private boolean isDownloadRunning(Class<?> serviceClass) {
}
return running;
} catch (ExecutionException e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
return false;
} catch (InterruptedException e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

public class BRouterView extends View {

private static final String TAG = "BRouterView";

private final int memoryClass;
RoutingEngine cr;
private int imgw;
Expand Down Expand Up @@ -148,8 +150,8 @@ public void startSetup(File baseDir, boolean storeBasedir, boolean silent) {
try {
td.mkdirs();
} catch (Exception e) {
Log.d("BRouterView", "Error creating base directory: " + e.getMessage());
e.printStackTrace();
Log.d(TAG, "Error creating base directory: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
}

if (!td.isDirectory()) {
Expand All @@ -173,7 +175,7 @@ public void startSetup(File baseDir, boolean storeBasedir, boolean silent) {

// new init is done move old files
if (waitingForMigration) {
Log.d("BR", "path " + oldMigrationPath + " " + basedir);
Log.d(TAG, "path " + oldMigrationPath + " " + basedir);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Expand All @@ -184,7 +186,7 @@ public void run() {
try {
t.join(500);
} catch (InterruptedException e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
}
waitingForMigration = false;
}
Expand Down Expand Up @@ -333,9 +335,9 @@ private void copyFile(String inputPath, String inputFile, String outputPath) {
out.close();

} catch (FileNotFoundException fileNotFoundException) {
Log.e("tag", fileNotFoundException.getMessage());
Log.e(TAG, fileNotFoundException.getMessage());
} catch (Exception e) {
Log.e("tag", e.getMessage());
Log.e(TAG, e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;

Expand Down Expand Up @@ -146,7 +147,7 @@ static public List<RoutingParam> getParamsFromProfile(final InputStream fis) thr
list.add(p);
}
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
}
}
} while (line != null);
Expand Down Expand Up @@ -240,6 +241,7 @@ public void onDetach() {
}

@Override
@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Expand All @@ -262,10 +264,10 @@ public void onCreate(Bundle savedInstanceState) {

if (i.hasExtra("PARAMS")) {
List<?> result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
result = (List<?>) i.getExtras().getSerializable("PARAMS", ArrayList.class);
} else {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
result = (List<?>) i.getExtras().getSerializable("PARAMS");
} else {
result = (List<?>) i.getExtras().getSerializable("PARAMS", ArrayList.class);
}
if (result instanceof ArrayList) {
for (Object o : result) {
Expand All @@ -277,7 +279,7 @@ public void onCreate(Bundle savedInstanceState) {
sparams = i.getExtras().getString("PARAMS_VALUES", "");
}
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
}

getPreferenceManager().setSharedPreferencesName("prefs_profile_" + profile_hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.res.AssetManager;
import android.util.Log;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -13,6 +14,9 @@
import java.util.zip.ZipInputStream;

public class ServerConfig {

private static final String TAG = "ServerConfig";

private static String mServerConfigName = "serverconfig.txt";

private String mSegmentUrl = "https://brouter.de/brouter/segments4/";
Expand Down Expand Up @@ -52,7 +56,7 @@ private void readConfigFile(File file) {
}
}
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
} finally {
try {
if (br != null) br.close();
Expand Down
Loading