Skip to content

Commit 5ae6f9c

Browse files
authored
all: Upgrade Android plugin to 4.2.0
- bump android plugin version to 4.2.0 - migrate deprecated android.support dependencies to androidx dependencies - bump `targetSdkVersion` to 29 - temporarily ignore lint error for 'MissingClass' due to grpc#8799 - run android CIs with `-Pandroid.useAndroidX=true -Pandroid.enableJetifier=true` flags - android examples are still using android.support dependencies, will not be updated in this PR.
1 parent 3ad4d9b commit 5ae6f9c

File tree

9 files changed

+33
-20
lines changed

9 files changed

+33
-20
lines changed

COMPILING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Some parts of grpc-java depend on Android. Since many Java developers don't have
1515
the Android SDK installed and don't need to run or modify the Android
1616
components, the build can skip it. To skip, create the file
1717
`<project-root>/gradle.properties` and add `skipAndroid=true`.
18+
Otherwise, create the file `<project-root>/gradle.properties` and add `android.useAndroidX=true`.
1819

1920
Then, to build, run:
2021
```

android-interop-testing/build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ android {
2929
sourceCompatibility JavaVersion.VERSION_1_8
3030
targetCompatibility JavaVersion.VERSION_1_8
3131
}
32-
compileSdkVersion 26
32+
compileSdkVersion 29
3333

3434
defaultConfig {
3535
applicationId "io.grpc.android.integrationtest"
3636
minSdkVersion 19
37-
targetSdkVersion 26
37+
targetSdkVersion 29
3838
versionCode 1
3939
versionName "1.0"
4040
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -47,14 +47,17 @@ android {
4747
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4848
}
4949
}
50-
lintOptions { disable 'InvalidPackage', 'HardcodedText' }
50+
lintOptions {
51+
disable 'InvalidPackage', 'HardcodedText',
52+
'MissingClass' // https://github.com/grpc/grpc-java/issues/8799
53+
}
5154
}
5255

5356
dependencies {
54-
implementation 'com.android.support:appcompat-v7:26.1.0'
55-
implementation 'com.android.support:multidex:1.0.3'
56-
implementation 'com.android.support:support-annotations:26.1.0'
57-
implementation 'com.google.android.gms:play-services-base:16.1.0'
57+
implementation 'androidx.appcompat:appcompat:1.3.0'
58+
implementation 'androidx.multidex:multidex:2.0.0'
59+
implementation libraries.androidx_annotation
60+
implementation 'com.google.android.gms:play-services-base:18.0.1'
5861

5962
implementation project(':grpc-auth'),
6063
project(':grpc-census'),

android-interop-testing/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
android:icon="@mipmap/ic_launcher"
1010
android:label="@string/app_name"
1111
android:theme="@style/Base.V7.Theme.AppCompat.Light"
12-
android:name="android.support.multidex.MultiDexApplication" >
12+
android:name="androidx.multidex.MultiDexApplication" >
1313
<activity
1414
android:name=".TesterActivity"
1515
android:label="@string/app_name" >

android-interop-testing/src/main/java/io/grpc/android/integrationtest/TesterActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import android.content.Context;
2020
import android.content.Intent;
2121
import android.os.Bundle;
22-
import android.support.v7.app.AppCompatActivity;
2322
import android.text.TextUtils;
2423
import android.util.Log;
2524
import android.view.View;
@@ -28,6 +27,7 @@
2827
import android.widget.CheckBox;
2928
import android.widget.EditText;
3029
import android.widget.TextView;
30+
import androidx.appcompat.app.AppCompatActivity;
3131
import com.google.android.gms.security.ProviderInstaller;
3232
import io.grpc.ManagedChannel;
3333
import java.io.InputStream;

android-interop-testing/src/main/java/io/grpc/android/integrationtest/TesterOkHttpChannelBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.grpc.android.integrationtest;
1818

19-
import android.support.annotation.Nullable;
19+
import androidx.annotation.Nullable;
2020
import io.grpc.ChannelCredentials;
2121
import io.grpc.Grpc;
2222
import io.grpc.InsecureChannelCredentials;

buildscripts/kokoro/android-interop.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
2121
# Proto deps
2222
buildscripts/make_dependencies.sh
2323

24+
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
25+
2426
# Build and run interop instrumentation tests on Firebase Test Lab
2527
cd android-interop-testing
26-
../gradlew assembleDebug
27-
../gradlew assembleDebugAndroidTest
28+
../gradlew assembleDebug $GRADLE_FLAGS
29+
../gradlew assembleDebugAndroidTest $GRADLE_FLAGS
2830
gcloud firebase test android run \
2931
--type instrumentation \
3032
--app build/outputs/apk/debug/grpc-android-interop-testing-debug.apk \
@@ -41,7 +43,7 @@ gcloud firebase test android run \
4143

4244
# Build and run binderchannel instrumentation tests on Firebase Test Lab
4345
cd ../binder
44-
../gradlew assembleDebugAndroidTest
46+
../gradlew assembleDebugAndroidTest $GRADLE_FLAGS
4547
gcloud firebase test android run \
4648
--type instrumentation \
4749
--app ../android-interop-testing/build/outputs/apk/debug/grpc-android-interop-testing-debug.apk \

buildscripts/kokoro/android.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
2828
# Proto deps
2929
buildscripts/make_dependencies.sh
3030

31+
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
32+
3133
./gradlew \
3234
:grpc-android-interop-testing:build \
3335
:grpc-android:build \
3436
:grpc-cronet:build \
3537
:grpc-binder:build \
3638
assembleAndroidTest \
37-
publishToMavenLocal
39+
publishToMavenLocal \
40+
$GRADLE_FLAGS
3841

3942
if [[ ! -z $(git status --porcelain) ]]; then
4043
git status
@@ -89,7 +92,7 @@ cd $BASE_DIR/github/grpc-java
8992
./gradlew clean
9093
git checkout HEAD^
9194
./gradlew --stop # use a new daemon to build the previous commit
92-
./gradlew publishToMavenLocal
95+
./gradlew publishToMavenLocal $GRADLE_FLAGS
9396
cd examples/android/helloworld/
9497
../../gradlew build
9598

buildscripts/kokoro/linux_artifacts.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@ readonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)"
1414
# use --include-build for its grpc-core dependency
1515
echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
1616
LOCAL_MVN_TEMP=$(mktemp -d)
17+
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
1718
pushd "$GRPC_JAVA_DIR/android"
1819
../gradlew publish \
1920
-Dorg.gradle.parallel=false \
2021
-PskipCodegen=true \
21-
-PrepositoryDir="$LOCAL_MVN_TEMP"
22+
-PrepositoryDir="$LOCAL_MVN_TEMP" \
23+
$GRADLE_FLAGS
2224
popd
2325

2426
pushd "$GRPC_JAVA_DIR/cronet"
2527
../gradlew publish \
2628
-Dorg.gradle.parallel=false \
2729
-PskipCodegen=true \
28-
-PrepositoryDir="$LOCAL_MVN_TEMP"
30+
-PrepositoryDir="$LOCAL_MVN_TEMP" \
31+
$GRADLE_FLAGS
2932
popd
3033

3134
pushd "$GRPC_JAVA_DIR/binder"
3235
../gradlew publish \
3336
-Dorg.gradle.parallel=false \
3437
-PskipCodegen=true \
35-
-PrepositoryDir="$LOCAL_MVN_TEMP"
38+
-PrepositoryDir="$LOCAL_MVN_TEMP" \
39+
$GRADLE_FLAGS
3640
popd
3741

3842
readonly MVN_ARTIFACT_DIR="${MVN_ARTIFACT_DIR:-$GRPC_JAVA_DIR/mvn-artifacts}"

settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pluginManagement {
22
plugins {
3-
id "com.android.application" version "3.5.0"
4-
id "com.android.library" version "3.5.0"
3+
id "com.android.application" version "4.2.0"
4+
id "com.android.library" version "4.2.0"
55
id "com.github.johnrengelman.shadow" version "6.1.0"
66
id "com.github.kt3k.coveralls" version "2.10.2"
77
id "com.google.osdetector" version "1.6.2"

0 commit comments

Comments
 (0)