fix: revert breaking change upgrading to sdk 28 and androidx

This reverts commit e2a895ad1c.
This commit is contained in:
Laurin Quast 2019-06-06 21:00:59 +02:00 committed by GitHub
parent aeda5781e4
commit 72a8d7f34c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 62 additions and 151 deletions

View File

@ -5,6 +5,9 @@ def safeExtGet(prop, fallback) {
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com'
}
jcenter()
}
@ -61,7 +64,9 @@ android {
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com'
}
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
@ -76,9 +81,9 @@ dependencies {
implementation "com.google.zxing:core:3.3.3"
implementation "com.drewnoakes:metadata-extractor:2.11.0"
generalImplementation "com.google.android.gms:play-services-vision:$googlePlayServicesVisionVersion"
implementation "androidx.exifinterface:exifinterface:1.0.0"
implementation "androidx.annotation:annotation:1.0.0"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "com.android.support:exifinterface:${safeExtGet('supportLibVersion', '28.0.0')}"
implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '28.0.0')}"
implementation "com.android.support:support-v4:${safeExtGet('supportLibVersion', '28.0.0')}"
mlkitImplementation "com.google.firebase:firebase-ml-vision:${safeExtGet('firebase-ml-vision', '19.0.3')}"
mlkitImplementation "com.google.firebase:firebase-ml-vision-face-model:${safeExtGet('firebase-ml-vision-face-model', '17.0.2')}"
}

View File

@ -1,2 +0,0 @@
android.enableJetifier=true
android.useAndroidX=true

View File

@ -1,4 +1,4 @@
#Wed Jan 23 23:35:17 CST 2019
#Sun Dec 31 13:43:56 BRST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View File

@ -3,7 +3,7 @@ package org.reactnative.facedetector.tasks;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import androidx.exifinterface.media.ExifInterface;
import android.support.media.ExifInterface;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

View File

@ -18,8 +18,8 @@ package com.google.android.cameraview;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.collection.SparseArrayCompat;
import android.support.annotation.NonNull;
import android.support.v4.util.SparseArrayCompat;
/**
* Immutable class for describing proportional relationship between width and height.

View File

@ -24,7 +24,7 @@ import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Build;
import android.os.Handler;
import androidx.collection.SparseArrayCompat;
import android.support.v4.util.SparseArrayCompat;
import android.util.Log;
import android.view.SurfaceHolder;
@ -89,11 +89,11 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
private boolean mIsRecording;
private final SizeMap mPreviewSizes = new SizeMap();
private boolean mIsPreviewActive = false;
private final SizeMap mPictureSizes = new SizeMap();
private Size mPictureSize;
private AspectRatio mAspectRatio;
@ -209,7 +209,7 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
mCamera.setPreviewCallback(this);
}
}
@Override
public void resumePreview() {
startCameraPreview();
@ -253,12 +253,12 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
}
return idealAspectRatios.ratios();
}
@Override
SortedSet<Size> getAvailablePictureSizes(AspectRatio ratio) {
return mPictureSizes.sizes(ratio);
}
@Override
void setPictureSize(Size size) {
if (size == null) {
@ -283,7 +283,7 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
}
}
}
@Override
Size getPictureSize() {
return mPictureSize;

View File

@ -37,7 +37,7 @@ import android.media.CamcorderProfile;
import android.media.Image;
import android.media.ImageReader;
import android.media.MediaRecorder;
import androidx.annotation.NonNull;
import android.support.annotation.NonNull;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.Surface;

View File

@ -24,12 +24,12 @@ import android.media.CamcorderProfile;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.os.ParcelableCompat;
import androidx.core.os.ParcelableCompatCreatorCallbacks;
import androidx.core.view.ViewCompat;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

View File

@ -18,7 +18,7 @@ package com.google.android.cameraview;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import android.support.annotation.NonNull;
/**
* Immutable class for describing width and height dimensions in pixels.

View File

@ -16,7 +16,7 @@
package com.google.android.cameraview;
import androidx.collection.ArrayMap;
import android.support.v4.util.ArrayMap;
import java.util.Set;
import java.util.SortedSet;

View File

@ -17,7 +17,7 @@
package com.google.android.cameraview;
import android.content.Context;
import androidx.core.view.ViewCompat;
import android.support.v4.view.ViewCompat;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

View File

@ -3,7 +3,7 @@ package com.lwansbrough.RCTCamera;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import androidx.exifinterface.media.ExifInterface;
import android.support.media.ExifInterface;
import android.util.Base64;
import android.util.Log;

View File

@ -1,6 +1,6 @@
package com.lwansbrough.RCTCamera;
import androidx.annotation.Nullable;
import android.support.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.MapBuilder;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera;
import androidx.annotation.Nullable;
import android.support.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder;

View File

@ -7,7 +7,7 @@ import android.graphics.Color;
import android.media.CamcorderProfile;
import android.media.MediaActionSound;
import android.os.Build;
import androidx.core.content.ContextCompat;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.os.AsyncTask;
import com.facebook.react.bridge.*;

View File

@ -6,7 +6,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.media.CamcorderProfile;
import android.os.Build;
import androidx.exifinterface.media.ExifInterface;
import android.support.media.ExifInterface;
import android.view.ViewGroup;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import org.reactnative.camera.CameraViewManager;
import com.facebook.react.bridge.Arguments;
@ -11,6 +11,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.google.zxing.Result;
import com.google.zxing.ResultPoint;
import java.util.Date;
import java.util.Formatter;
public class BarCodeReadEvent extends Event<BarCodeReadEvent> {

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,7 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.util.SparseArray;
import android.support.v4.util.Pools;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import org.reactnative.camera.CameraViewManager;
import com.facebook.react.bridge.Arguments;
@ -8,6 +8,8 @@ import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import java.util.Date;
public class CameraReadyEvent extends Event<CameraReadyEvent> {
private static final Pools.SynchronizedPool<CameraReadyEvent> EVENTS_POOL = new Pools.SynchronizedPool<>(3);
private CameraReadyEvent() {}

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import org.reactnative.camera.CameraViewManager;
import com.facebook.react.bridge.Arguments;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import org.reactnative.camera.CameraViewManager;
import com.facebook.react.bridge.Arguments;
@ -8,6 +8,8 @@ import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import java.util.Date;
public class PictureTakenEvent extends Event<PictureTakenEvent> {
private static final Pools.SynchronizedPool<PictureTakenEvent> EVENTS_POOL = new Pools.SynchronizedPool<>(3);
private PictureTakenEvent() {}

View File

@ -1,6 +1,6 @@
package org.reactnative.camera.events;
import androidx.core.util.Pools;
import android.support.v4.util.Pools;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableArray;

View File

@ -6,7 +6,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.AsyncTask;
import androidx.exifinterface.media.ExifInterface;
import android.support.media.ExifInterface;
import android.util.Base64;
import org.reactnative.camera.RNCameraViewHelper;

View File

@ -1,7 +1,7 @@
package org.reactnative.facedetector.tasks;
import android.content.Context;
import androidx.exifinterface.media.ExifInterface;
import android.support.media.ExifInterface;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

View File

@ -1,101 +0,0 @@
# AndroidX Migration
AndroidX is the replacement for Google Support Libraries. It is the open-source project that the Android team uses to
develop, test, package, version and release libraries within Jetpack. Moving forward, all new Android development
will be in AndroidX, the Support Libraries are depreciated.
> AndroidX is a major improvement to the original Android Support Library. Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases. AndroidX fully replaces the Support Library by providing feature parity and new libraries.
See: https://developer.android.com/jetpack/androidx/
## Migration via Android studio
You can follow the instructions [here](https://developer.android.com/jetpack/androidx/migrate) to migrate you existing
project.
## Manual
#### Update the android section `android/app/build.gradle` to
```
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 28
}
...
```
If you have any `dependencies {` that are using the old Google Support Libraries, you'll need to update them
to use the androidx version. Can check the full migration list [here](https://developer.android.com/jetpack/androidx/migrate).
#### Update `android/app/src/main/AndroidManifest.xml`
remove
```xml
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
```
#### Update `android/build.gradle`
```
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
```
#### Update `android/gradle.properties`
add
```
android.enableJetifier = true;
android.useAndroidX = true;
```
#### Update `android/gradle/wrapper/gradle-wrapper.properties`
make sure your gradle `distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip`

View File

@ -137,7 +137,7 @@ android {
dependencies {
implementation project(':react-native-camera')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}

View File

@ -9,6 +9,10 @@
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26" />
<application
android:name=".MainApplication"
android:allowBackup="true"

View File

@ -23,13 +23,15 @@ buildscript {
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
maven { url "https://jitpack.io" }
}
}

View File

@ -18,5 +18,4 @@ org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=1g -XX:+HeapDumpOnOutOfMemoryError -Df
# org.gradle.parallel=true
android.useDeprecatedNdk=true
android.enableJetifier=true
android.useAndroidX=true
android.enableAapt2=false