Fix android build

Fixes changes to grpc services and downgrades appcompat due to a bug in dependency versions
This commit is contained in:
piv
2022-10-15 14:30:20 +10:30
parent 4d8dddbef0
commit b56467dd1c
7 changed files with 90 additions and 31 deletions

1
.idea/.name generated Normal file
View File

@@ -0,0 +1 @@
CarController

17
.idea/deploymentTargetDropDown.xml generated Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_3a_API_33_x86_64.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-10-15T03:44:49.580415Z" />
</component>
</project>

40
.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenLocal" />
<option name="name" value="MavenLocal" />
<option name="url" value="file:$USER_HOME$/.m2/repository" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenLocal" />
<option name="name" value="MavenLocal" />
<option name="url" value="file:$USER_HOME$/.m2/repository/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
</component>
</project>

View File

@@ -2,7 +2,7 @@
This software allows for the control of an RC Car using a linux system. Currently it's been tested to work on a Traxxas Slash and raspberry pi 3b+. This software allows for the control of an RC Car using a linux system. Currently it's been tested to work on a Traxxas Slash and raspberry pi 3b+.
See the individuals modules for more detailed READMEs, including build instructions. See the individual modules for more detailed READMEs, including build instructions.
### Current Functinoality ### Current Functinoality

View File

@@ -32,7 +32,7 @@ android {
dependencies { dependencies {
implementation project(':protobuf') implementation project(':protobuf')
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.6.1' implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.preference:preference:1.2.0' implementation 'androidx.preference:preference:1.2.0'
@@ -42,9 +42,9 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0' androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'io.grpc:grpc-okhttp:1.29.0' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-okhttp:1.29.0'
implementation 'io.grpc:grpc-protobuf-lite:1.39.0' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-protobuf-lite:1.39.0'
implementation 'io.grpc:grpc-stub:1.39.0' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-stub:1.39.0'
implementation 'javax.annotation:javax.annotation-api:1.3.2' implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'org.zeromq:jeromq:0.5.2' implementation 'org.zeromq:jeromq:0.5.2'
} }

View File

@@ -17,12 +17,12 @@ public class PiLoader implements Runnable {
private Integer steeringValue = 50; private Integer steeringValue = 50;
private Integer throttleValue = 50; private Integer throttleValue = 50;
private ManagedChannel mChannel; private final ManagedChannel mChannel;
private CarControlGrpc.CarControlBlockingStub stub; private final CarControlGrpc.CarControlBlockingStub stub;
private AtomicBoolean stop = new AtomicBoolean(false); private final AtomicBoolean stop = new AtomicBoolean(false);
private Thread piUpdaterThread; private Thread piUpdaterThread;
private boolean useGrpcStream; private final boolean useGrpcStream;
public PiLoader(String host, Integer port, boolean useGrpcStream) { public PiLoader(String host, Integer port, boolean useGrpcStream) {
mChannel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build(); mChannel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
@@ -72,10 +72,10 @@ public class PiLoader implements Runnable {
try { try {
SteeringResponse steeringResponse = stub.setSteering( SteeringResponse steeringResponse = stub.setSteering(
SteeringRequest.newBuilder().setSteering((float) steeringValue / 50f - 1) SteeringRequest.newBuilder().setSteering((float) steeringValue / 50f - 1)
.build()); .build());
ThrottleResponse throttleResponse = stub.setThrottle( ThrottleResponse throttleResponse = stub.setThrottle(
ThrottleRequest.newBuilder().setThrottle((float) throttleValue / 50f - 1) ThrottleRequest.newBuilder().setThrottle((float) throttleValue / 50f - 1)
.build()); .build());
} catch (Exception e) { } catch (Exception e) {
System.out.println("Error"); System.out.println("Error");
stop(); stop();
@@ -93,9 +93,9 @@ public class PiLoader implements Runnable {
private void doStreamUpdates() { private void doStreamUpdates() {
// Stream if user sets use_grpc_streams to true. This method is more efficient but less compatible. // Stream if user sets use_grpc_streams to true. This method is more efficient but less compatible.
final CountDownLatch finishLatch = new CountDownLatch(1); final CountDownLatch finishLatch = new CountDownLatch(1);
StreamObserver<Empty> responseObserver = new StreamObserver<Empty>() { StreamObserver<Vehicle2DResponse> responseObserver = new StreamObserver<Vehicle2DResponse>() {
@Override @Override
public void onNext(Empty value) { public void onNext(Vehicle2DResponse value) {
finishLatch.countDown(); finishLatch.countDown();
Log.d("PiLoader", "Finished streaming"); Log.d("PiLoader", "Finished streaming");
} }
@@ -113,23 +113,23 @@ public class PiLoader implements Runnable {
} }
}; };
StreamObserver<Vehicle2DRequest> requestStreamObserver = CarControlGrpc.newStub(mChannel) StreamObserver<Vehicle2DRequest> requestStreamObserver = CarControlGrpc.newStub(mChannel)
.streamVehicle2d( .streamVehicle2d(
responseObserver); responseObserver);
while (!stop.get() && !Thread.interrupted() && finishLatch.getCount() > 0) { while (!stop.get() && !Thread.interrupted() && finishLatch.getCount() > 0) {
requestStreamObserver.onNext(Vehicle2DRequest.newBuilder() requestStreamObserver.onNext(Vehicle2DRequest.newBuilder()
.setThrottle(ThrottleRequest.newBuilder() .setThrottle(ThrottleRequest.newBuilder()
.setThrottle( .setThrottle(
(float) throttleValue / (float) throttleValue /
50f - 50f -
1) 1)
.build()) .build())
.setSteering(SteeringRequest.newBuilder() .setSteering(SteeringRequest.newBuilder()
.setSteering( .setSteering(
(float) steeringValue / (float) steeringValue /
50f - 50f -
1) 1)
.build()) .build())
.build()); .build());
try { try {
// Use the same update rate as a typical screen refresh rate. // Use the same update rate as a typical screen refresh rate.
TimeUnit.MILLISECONDS.sleep(200); TimeUnit.MILLISECONDS.sleep(200);
@@ -141,12 +141,12 @@ public class PiLoader implements Runnable {
public void saveRecording() { public void saveRecording() {
// Ideally don't want to use a blocking stub here, android may complain. // Ideally don't want to use a blocking stub here, android may complain.
Empty done = stub.saveRecordedData(SaveRequest.newBuilder().setFile("Test").build()); SaveResponse done = stub.saveRecordedData(SaveRequest.newBuilder().setFile("Test").build());
} }
public void record(boolean record) { public void record(boolean record) {
// Ideally don't want to use a blocking stub here, android may complain. // Ideally don't want to use a blocking stub here, android may complain.
Empty done = stub.record(RecordingReqeust.newBuilder().setRecord(record).build()); RecordingResponse done = stub.record(RecordingReqeust.newBuilder().setRecord(record).build());
} }
} }

View File

@@ -3,6 +3,7 @@
buildscript { buildscript {
repositories { repositories {
google() google()
mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.3.1' classpath 'com.android.tools.build:gradle:7.3.1'
@@ -16,7 +17,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
mavenLocal() mavenCentral()
} }
} }