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

Upgrading Android API Level from 29 to 32. #333

Merged
merged 6 commits into from Feb 15, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions android/README.md
Expand Up @@ -41,9 +41,9 @@ Alternatively, you can download the apks from the assets of any [release](https:

### Prerequisites

- [Android Studio 3.2 or later](https://developer.android.com/studio/index.html) for building and installing the apks.
- [Android Studio Electric Eel | 2022.1.1 or later](https://developer.android.com/studio/index.html) for building and installing the apks.
- Android device and Android development environment with minimum API 21.
- Currently, we use API 30 as compile SDK and API 29 as target SDK. It should get installed automatically, but if not you can install the SDK manually. Go to Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK. Make sure API 30 is checked and click apply.
- Currently, we use API 33 as compile SDK and API 32 as target SDK. It should get installed automatically, but if not you can install the SDK manually. Go to Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK. Make sure API 33 is checked and click apply.

![Android SDK](../docs/images/android_studio_sdk.jpg)

Expand All @@ -59,3 +59,9 @@ Alternatively, you can download the apks from the assets of any [release](https:
![Run](../docs/images/android_studio_bar_run.jpg)
6. If it asks you to use Instant Run, click *Proceed Without Instant Run*.

### Troubleshooting

#### Versions

If you get a message like `The project is using an incompatible version (AGP 7.4.0) of the Android Gradle plugin. Latest supported version is AGP 7.3.0` you need to upgrade Android Studio or downgrade your gradle plugin. You can read more about the version compatablility between Android Studio and the gradle plugin [here](https://developer.android.com/studio/releases/gradle-plugin#android_gradle_plugin_and_android_studio_compatibility).

29 changes: 14 additions & 15 deletions android/app/build.gradle
Expand Up @@ -15,12 +15,12 @@ apply plugin: 'de.undercouch.download'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileSdkVersion 33
buildToolsVersion '33.0.1'
defaultConfig {
applicationId "org.openbot"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 32
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
Expand All @@ -32,26 +32,25 @@ android {
}
}

lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}

buildFeatures {
viewBinding true
}

aaptOptions {
noCompress "tflite", "mp3"
}
compileOptions {
coreLibraryDesugaringEnabled true

sourceCompatibility = '11'
targetCompatibility = '11'
}
androidResources {
noCompress 'tflite', 'mp3'
}
lint {
abortOnError false
checkReleaseBuilds false
}
namespace 'org.openbot'
}

// Download default models
Expand Down Expand Up @@ -114,12 +113,12 @@ dependencies {
implementation 'androidx.fragment:fragment:1.3.4'

testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.test.ext:junit:1.1.5'
testImplementation 'androidx.test:core:1.5.0'
testImplementation "org.robolectric:robolectric:4.4"

// Core library
androidTestImplementation 'androidx.test:core:1.3.0'
androidTestImplementation 'androidx.test:core:1.5.0'

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.3.0'
Expand Down
20 changes: 17 additions & 3 deletions android/app/src/main/AndroidManifest.xml
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.openbot">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

Expand Down Expand Up @@ -36,7 +37,8 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".main.MainActivity"
android:launchMode="singleInstance">
android:launchMode="singleInstance"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -66,13 +68,25 @@
<activity
android:name=".modelManagement.BackHandlingFilePickerActivity"
android:label="@string/app_name"
android:theme="@style/FilePickerTheme">
android:theme="@style/FilePickerTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:exported="true"
tools:node="merge"/>

<activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:exported="true"
tools:node="merge"/>

<activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:exported="true"
tools:node="merge"/>
<service
android:name=".logging.SensorService"
android:enabled="true"
Expand Down
Expand Up @@ -265,7 +265,8 @@ protected void sendIndicatorToSensorService() {

private void startLogging() {
logFolder =
Environment.getExternalStorageDirectory().getAbsolutePath()
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)
.getAbsolutePath()
+ File.separator
+ getString(R.string.app_name)
+ File.separator
Expand Down
Expand Up @@ -1082,7 +1082,8 @@ protected void sendVehicleDataToSensorService(long timestamp, String data, int t

private void startLogging() {
logFolder =
Environment.getExternalStorageDirectory().getAbsolutePath()
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)
.getAbsolutePath()
+ File.separator
+ getString(R.string.app_name)
+ File.separator
Expand Down
11 changes: 9 additions & 2 deletions android/app/src/main/java/org/openbot/vehicle/UsbConnection.java
Expand Up @@ -13,6 +13,7 @@
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;
import android.os.AsyncTask;
import android.os.Build;
import android.widget.Toast;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.felhr.usbserial.UsbSerialDevice;
Expand Down Expand Up @@ -50,8 +51,14 @@ public UsbConnection(Context context, int baudRate) {
this.baudRate = baudRate;
localBroadcastManager = LocalBroadcastManager.getInstance(this.context);
usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
usbPermissionIntent =
PendingIntent.getBroadcast(this.context, 0, new Intent(ACTION_USB_PERMISSION), 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
usbPermissionIntent =
PendingIntent.getBroadcast(
this.context, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_IMMUTABLE);
} else {
usbPermissionIntent =
PendingIntent.getBroadcast(this.context, 0, new Intent(ACTION_USB_PERMISSION), 0);
}
}

private final UsbSerialInterface.UsbReadCallback callback =
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.5.20'
ext.kotlin_version = '1.6.21'
ext.webrtc_version = '1.0.32006'
ext.location_version = '19.0.1'
ext.nearby_version = '18.0.2'
Expand All @@ -10,7 +10,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.4.0'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath 'de.undercouch:gradle-download-task:4.1.1'
Expand Down
13 changes: 8 additions & 5 deletions android/controller/build.gradle
Expand Up @@ -15,12 +15,12 @@ appVersioning {
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 33
buildToolsVersion "33.0.1"

defaultConfig {
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 32

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -52,10 +52,13 @@ android {
kotlinOptions {
jvmTarget = '11'
}

packagingOptions {
exclude 'META-INF/*.kotlin_module'
resources {
excludes += ['META-INF/*.kotlin_module']
}
}

namespace 'org.openbot.controller'
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions android/controller/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.openbot.controller">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Expand Down Expand Up @@ -36,7 +35,8 @@
android:name="org.openbot.controller.ControllerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Expand Up @@ -48,7 +48,7 @@ class FadeableTextView @JvmOverloads constructor(
val fadeOut = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f)
fadeOut.duration = 500
fadeOut.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationEnd(animation: Animator) {
hide()
}
})
Expand Down
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 3 additions & 4 deletions android/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,6 @@
#Thu Dec 10 15:38:09 IST 2020
#Mon Feb 13 15:23:50 CET 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip

zipStoreBase=GRADLE_USER_HOME