mirror of https://github.com/grpc/grpc-java.git
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 #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.
This commit is contained in:
parent
3ad4d9bfb7
commit
5ae6f9ca25
|
@ -15,6 +15,7 @@ Some parts of grpc-java depend on Android. Since many Java developers don't have
|
|||
the Android SDK installed and don't need to run or modify the Android
|
||||
components, the build can skip it. To skip, create the file
|
||||
`<project-root>/gradle.properties` and add `skipAndroid=true`.
|
||||
Otherwise, create the file `<project-root>/gradle.properties` and add `android.useAndroidX=true`.
|
||||
|
||||
Then, to build, run:
|
||||
```
|
||||
|
|
|
@ -29,12 +29,12 @@ android {
|
|||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
compileSdkVersion 26
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
applicationId "io.grpc.android.integrationtest"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
@ -47,14 +47,17 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
lintOptions { disable 'InvalidPackage', 'HardcodedText' }
|
||||
lintOptions {
|
||||
disable 'InvalidPackage', 'HardcodedText',
|
||||
'MissingClass' // https://github.com/grpc/grpc-java/issues/8799
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'com.android.support:support-annotations:26.1.0'
|
||||
implementation 'com.google.android.gms:play-services-base:16.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.0'
|
||||
implementation libraries.androidx_annotation
|
||||
implementation 'com.google.android.gms:play-services-base:18.0.1'
|
||||
|
||||
implementation project(':grpc-auth'),
|
||||
project(':grpc-census'),
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Base.V7.Theme.AppCompat.Light"
|
||||
android:name="android.support.multidex.MultiDexApplication" >
|
||||
android:name="androidx.multidex.MultiDexApplication" >
|
||||
<activity
|
||||
android:name=".TesterActivity"
|
||||
android:label="@string/app_name" >
|
||||
|
|
|
@ -19,7 +19,6 @@ package io.grpc.android.integrationtest;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -28,6 +27,7 @@ import android.widget.Button;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.google.android.gms.security.ProviderInstaller;
|
||||
import io.grpc.ManagedChannel;
|
||||
import java.io.InputStream;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package io.grpc.android.integrationtest;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import androidx.annotation.Nullable;
|
||||
import io.grpc.ChannelCredentials;
|
||||
import io.grpc.Grpc;
|
||||
import io.grpc.InsecureChannelCredentials;
|
||||
|
|
|
@ -21,10 +21,12 @@ echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
|
|||
# Proto deps
|
||||
buildscripts/make_dependencies.sh
|
||||
|
||||
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
|
||||
|
||||
# Build and run interop instrumentation tests on Firebase Test Lab
|
||||
cd android-interop-testing
|
||||
../gradlew assembleDebug
|
||||
../gradlew assembleDebugAndroidTest
|
||||
../gradlew assembleDebug $GRADLE_FLAGS
|
||||
../gradlew assembleDebugAndroidTest $GRADLE_FLAGS
|
||||
gcloud firebase test android run \
|
||||
--type instrumentation \
|
||||
--app build/outputs/apk/debug/grpc-android-interop-testing-debug.apk \
|
||||
|
@ -41,7 +43,7 @@ gcloud firebase test android run \
|
|||
|
||||
# Build and run binderchannel instrumentation tests on Firebase Test Lab
|
||||
cd ../binder
|
||||
../gradlew assembleDebugAndroidTest
|
||||
../gradlew assembleDebugAndroidTest $GRADLE_FLAGS
|
||||
gcloud firebase test android run \
|
||||
--type instrumentation \
|
||||
--app ../android-interop-testing/build/outputs/apk/debug/grpc-android-interop-testing-debug.apk \
|
||||
|
|
|
@ -28,13 +28,16 @@ echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
|
|||
# Proto deps
|
||||
buildscripts/make_dependencies.sh
|
||||
|
||||
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
|
||||
|
||||
./gradlew \
|
||||
:grpc-android-interop-testing:build \
|
||||
:grpc-android:build \
|
||||
:grpc-cronet:build \
|
||||
:grpc-binder:build \
|
||||
assembleAndroidTest \
|
||||
publishToMavenLocal
|
||||
publishToMavenLocal \
|
||||
$GRADLE_FLAGS
|
||||
|
||||
if [[ ! -z $(git status --porcelain) ]]; then
|
||||
git status
|
||||
|
@ -89,7 +92,7 @@ cd $BASE_DIR/github/grpc-java
|
|||
./gradlew clean
|
||||
git checkout HEAD^
|
||||
./gradlew --stop # use a new daemon to build the previous commit
|
||||
./gradlew publishToMavenLocal
|
||||
./gradlew publishToMavenLocal $GRADLE_FLAGS
|
||||
cd examples/android/helloworld/
|
||||
../../gradlew build
|
||||
|
||||
|
|
|
@ -14,25 +14,29 @@ readonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)"
|
|||
# use --include-build for its grpc-core dependency
|
||||
echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
|
||||
LOCAL_MVN_TEMP=$(mktemp -d)
|
||||
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
|
||||
pushd "$GRPC_JAVA_DIR/android"
|
||||
../gradlew publish \
|
||||
-Dorg.gradle.parallel=false \
|
||||
-PskipCodegen=true \
|
||||
-PrepositoryDir="$LOCAL_MVN_TEMP"
|
||||
-PrepositoryDir="$LOCAL_MVN_TEMP" \
|
||||
$GRADLE_FLAGS
|
||||
popd
|
||||
|
||||
pushd "$GRPC_JAVA_DIR/cronet"
|
||||
../gradlew publish \
|
||||
-Dorg.gradle.parallel=false \
|
||||
-PskipCodegen=true \
|
||||
-PrepositoryDir="$LOCAL_MVN_TEMP"
|
||||
-PrepositoryDir="$LOCAL_MVN_TEMP" \
|
||||
$GRADLE_FLAGS
|
||||
popd
|
||||
|
||||
pushd "$GRPC_JAVA_DIR/binder"
|
||||
../gradlew publish \
|
||||
-Dorg.gradle.parallel=false \
|
||||
-PskipCodegen=true \
|
||||
-PrepositoryDir="$LOCAL_MVN_TEMP"
|
||||
-PrepositoryDir="$LOCAL_MVN_TEMP" \
|
||||
$GRADLE_FLAGS
|
||||
popd
|
||||
|
||||
readonly MVN_ARTIFACT_DIR="${MVN_ARTIFACT_DIR:-$GRPC_JAVA_DIR/mvn-artifacts}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
pluginManagement {
|
||||
plugins {
|
||||
id "com.android.application" version "3.5.0"
|
||||
id "com.android.library" version "3.5.0"
|
||||
id "com.android.application" version "4.2.0"
|
||||
id "com.android.library" version "4.2.0"
|
||||
id "com.github.johnrengelman.shadow" version "6.1.0"
|
||||
id "com.github.kt3k.coveralls" version "2.10.2"
|
||||
id "com.google.osdetector" version "1.6.2"
|
||||
|
|
Loading…
Reference in New Issue