Skip to content

Commit

Permalink
fixed gradle build and lint for android (#451)
Browse files Browse the repository at this point in the history
* fixed gradle build and lint for android
  • Loading branch information
isha382 authored Oct 6, 2024
1 parent c524b69 commit 1169244
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 33 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
run:
working-directory: android
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: 'zulu'
cache: 'gradle'
- name: Style
Expand All @@ -39,12 +39,12 @@ jobs:
- name: Build
run: ./gradlew build
- name: Upload OpenBot App
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: robot-debug.apk
path: android/robot/build/outputs/apk/debug/robot-debug.apk
- name: Upload Controller App
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: controller-debug.apk
path: android/controller/build/outputs/apk/debug/controller-debug.apk
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '1.8.0'
ext.webrtc_version = '1.0.32006'
ext.location_version = '19.0.1'
ext.nearby_version = '18.0.2'
Expand All @@ -8,6 +8,7 @@ buildscript {
google()
mavenCentral()
mavenLocal()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
Expand Down
2 changes: 2 additions & 0 deletions android/comlib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
libs
44 changes: 44 additions & 0 deletions android/comlib/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//Abemart wroup and google webRtc are both deprecated on maven and other similar repositories
//Hence created a local implementation of those libraries using pre-compiled .aar files in a shared modules called comlib
plugins {
id 'java-library'
id 'de.undercouch.download'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

// Define the libs directory
project.ext.LIB_DIR = "${projectDir}/libs"
apply from: 'download.gradle'

def googleWebrtcFile = file("${project.ext.LIB_DIR}/google-webrtc-1.0.32006.aar")
def wroupFile = file("${project.ext.LIB_DIR}/Wroup-master-release.aar")

// Task to check for AAR files
task checkAars {
dependsOn downloadAars // Ensure this matches the actual download task name

doLast {
if (!googleWebrtcFile.exists() || !wroupFile.exists()) {
throw new GradleException("Required AAR files are missing. Please run the download task.")
}
}
}

dependencies {
if (googleWebrtcFile.exists()) {
api files(googleWebrtcFile)
}

if (wroupFile.exists()) {
api files(wroupFile)
}
}

// Ensure that checkAars runs before any Java compile tasks
tasks.withType(JavaCompile) {
dependsOn checkAars
}
9 changes: 9 additions & 0 deletions android/comlib/download.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
task downloadAars(type: Download) {
src([
'https://storage.googleapis.com/openbot_aar/Wroup-master-release.aar',
'https://storage.googleapis.com/openbot_aar/google-webrtc-1.0.32006.aar',
])
dest project.ext.LIB_DIR
onlyIfModified true
overwrite false
}
27 changes: 16 additions & 11 deletions android/controller/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ android {

defaultConfig {
minSdkVersion 21
targetSdkVersion 32
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


defaultConfig {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
Expand All @@ -45,12 +46,12 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '11'
jvmTarget = '17'
}
packagingOptions {
resources {
Expand All @@ -59,10 +60,20 @@ android {
}

namespace 'org.openbot.controller'
ndkVersion '23.1.7779620'
}

// Define the path to the comlib lib directory
def comlibDir = file("${project.rootDir}/comlib/libs")

dependencies {

// WiFi direct + WebRTC
implementation project(':comlib')

// Include AAR files from comlib/lib
implementation fileTree(dir: comlibDir, include: ['*.aar'])

//noinspection GradleDependency
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
Expand All @@ -78,17 +89,11 @@ dependencies {
implementation "io.reactivex.rxjava2:rxjava:2.2.8"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"

// WiFi direct
implementation 'com.abemart.wroup:wroup:0.9'

// material design
implementation 'com.google.android.material:material:1.4.0'

// WebRTC
implementation "org.webrtc:google-webrtc:$webrtc_version"

// For a library module, uncomment the following line and comment the one after
// apply plugin: 'com.android.library'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
}
}
6 changes: 3 additions & 3 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Feb 13 15:23:50 CET 2023
#Thu Sep 19 11:12:47 IST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
32 changes: 20 additions & 12 deletions android/robot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ appVersioning {
apply plugin: 'com.android.application'
apply plugin: 'de.undercouch.download'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'


android {
compileSdkVersion 33
buildToolsVersion '33.0.1'
defaultConfig {
applicationId "org.openbot"
minSdkVersion 21
targetSdkVersion 32
targetSdkVersion 33
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
Expand All @@ -42,8 +44,8 @@ android {
compileOptions {
coreLibraryDesugaringEnabled true

sourceCompatibility = '11'
targetCompatibility = '11'
sourceCompatibility = '17'
targetCompatibility = '17'
}
androidResources {
noCompress 'tflite', 'mp3'
Expand All @@ -62,10 +64,18 @@ android {
project.ext.ASSET_DIR = projectDir.toString() + '/src/main/assets'
apply from: 'download.gradle'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'

// Define the path to the comlib lib directory
def comlibDir = file("${project.rootDir}/comlib/libs")

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

// WiFi direct + WebRTC
implementation project(':comlib')

// Include AAR files from comlib/lib
implementation fileTree(dir: comlibDir, include: ['*.aar'])

implementation 'com.google.android.material:material:1.4.0'

// Build off of stable TensorFlow Lite
Expand Down Expand Up @@ -115,15 +125,15 @@ dependencies {
implementation "androidx.camera:camera-lifecycle:$camerax_version"
// CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha24"
implementation 'com.github.anastr:speedviewlib:1.5.3'
implementation 'com.github.anastr:speedviewlib:1.6.1'

implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'androidx.fragment:fragment:1.3.4'

testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test.ext:junit:1.1.5'
testImplementation 'androidx.test:core:1.5.0'
testImplementation "org.robolectric:robolectric:4.4"
testImplementation 'androidx.test.ext:junit:1.2.1'
testImplementation 'androidx.test:core:1.6.1'
testImplementation "org.robolectric:robolectric:4.12.1"

// Core library
androidTestImplementation 'androidx.test:core:1.5.0'
Expand Down Expand Up @@ -157,14 +167,12 @@ dependencies {
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.nononsenseapps:filepicker:4.1.0'
implementation 'com.nononsenseapps:filepicker:4.2.1'

// arcore
implementation 'com.google.ar:core:1.29.0'
implementation 'de.javagl:obj:0.2.1'

// WebRTC
implementation "org.webrtc:google-webrtc:$webrtc_version"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
implementation 'com.koushikdutta.ion:ion:3.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
Expand Down
1 change: 1 addition & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include ':robot', ':controller'
include ':comlib'

0 comments on commit 1169244

Please sign in to comment.