我在启动应用程序时遇到了麻烦。尝试了在类似主题中找到的所有内容,但仍然没有成功:(
我使用:
Android Studio 3.5.3
版本6
react-native-cli:2.0.1
本机:0.61.5
我已成功使用jetifier迁移到Androidx(希望如此)
@ react-native-community / netinfo版本为5.5.0
build.grandle:
buildscript {
repositories {
google()
jcenter()
maven { url("$rootDir/../node_modules/jsc-android/dist") }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://repo.gradle.org/gradle/repo" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'org.codehaus.groovy:groovy-all:2.4.15'
classpath 'io.fabric.tools:gradle:1.28.1'
}
}
allprojects {
repositories {
mavenLocal()
maven { url ("$rootDir/../node_modules/react-native/android") }
maven { url("$rootDir/../node_modules/jsc-android/dist") }
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
google()
jcenter()
}
}
ext {
compileSdkVersion = 28
targetSdkVersion = 28
minSdkVersion = 16
buildToolsVersion = "29.0.3"
//androidXCore = "1.0.2"
supportLibVersion="28.0.0"
googlePlayServicesVersion = "15.0.1"
googlePlayServicesVisionVersion = "17.0.2"
androidMapsUtilsVersion = "0.5+"
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.core' &&
!details.requested.name.contains('androidx')) {
details.useVersion "1.0.0"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "28.+"
}
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') && !details.requested.name.contains('play-services-stats')) {
details.useVersion "12.+"
}
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') && details.requested.name.contains('play-services-stats')) {
details.useVersion "+"
}
}
}
}
}
settings.gradle
rootProject.name = 'modelalliance_client'
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-image-crop-picker'
project(':react-native-image-crop-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-crop-picker/android')
include ':react-native-share'
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-touch-id'
project(':react-native-touch-id').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-touch-id/android')
include ':react-native-pdf'
project(':react-native-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-document-picker'
project(':react-native-document-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-picker/android')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
include ':react-native-image-resizer'
project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':@react-native-community-netinfo'
project(':@react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
include ':app'
app / build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
def useIntlJsc = false
project.ext.react = [
entryFile: "index.js",
jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/out",
enableHermes: true,
hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
bundleInStaging: true, // Add this
bundleInInternalTest: true, // Add this
bundleInRelease: true
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false)
android {
compileSdkVersion 28
buildToolsVersion '29.0.3'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/INDEX.LIST'
exclude("META-INF/*.kotlin_module")
}
defaultConfig {
applicationId "com.modelalliance_client"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// abiFilters "armeabi-v7a", "x86"
}
missingDimensionStrategy 'react-native-camera', 'general'
}
packagingOptions {
pickFirst '**/armeabi-v7a/libc++_shared.so'
pickFirst '**/x86/libc++_shared.so'
pickFirst '**/arm64-v8a/libc++_shared.so'
pickFirst '**/x86_64/libc++_shared.so'
pickFirst '**/x86/libjsc.so'
pickFirst '**/armeabi-v7a/libjsc.so'
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
project.ext.sentryCli = [
logLevel: "debug",
flavorAware: false,
//add
enableHermes: false
]
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
splits {
abi {
reset()
enable true
universalApk false // If true, also generate a universal APK
include "armeabi-v7a","arm64-v8a","x86","x86_64"
exclude "ldpi", "xxhdpi", "xxxhdpi"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
shrinkResources enableSeparateBuildPerCPUArchitecture
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug{ minifyEnabled enableProguardInReleaseBuilds
shrinkResources enableSeparateBuildPerCPUArchitecture
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release }
all {minifyEnabled enableProguardInReleaseBuilds
shrinkResources enableSeparateBuildPerCPUArchitecture
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a":3,"x86_64":4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
implementation project(':react-native-reanimated')
implementation 'org.codehaus.groovy:groovy-all:2.4.15'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
} else {
implementation 'org.webkit:android-jsc:+'
}
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-share')
implementation project(':rn-fetch-blob')
implementation project(':react-native-fs')
implementation project(':react-native-image-resizer')
implementation project(':react-native-image-picker')
implementation project(':react-native-touch-id')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-pdf')
implementation project(':react-native-vector-icons')
implementation project(':react-native-document-picker')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-firebase')
implementation project(':@react-native-community-netinfo')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.dhaval2404:imagepicker-support:1.5'
implementation 'androidx.arch.core:core-runtime:2.1.0'
implementation 'androidx.arch.core:core-common:2.1.0'
implementation "org.webkit:android-jsc:r241213"
implementation 'androidx.appcompat:appcompat:1.2.0-alpha02'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
implementation "com.google.firebase:firebase-storage:19.1.1"
implementation "com.google.firebase:firebase-database:19.2.1"
implementation "com.google.firebase:firebase-dynamic-links:19.0.0"
implementation "com.google.firebase:firebase-invites:17.0.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.1.0'
implementation "com.facebook.react:react-native:0.61.5" // From node_modules
implementation(project(':react-native-camera')) {
exclude group: 'com.google.android.gms'
implementation ('com.google.android.gms:play-services-vision:15.0.1') {
force = true
}
}
implementation('com.google.android.gms:play-services-vision:19.0.0')
compile(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation "com.google.android.gms:play-services-gcm:17.0.0"
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-firestore:21.4.0'
implementation "com.google.firebase:firebase-database:19.2.1"
implementation 'com.google.guava:guava:27.0.1-android'
implementation 'androidx.leanback:leanback:1.1.0-alpha03'
compile('com.google.guava:guava-jdk5:17.0') { force = true }
implementation 'org.gradle:gradle-core:2.2.1'
implementation(project(':react-native-camera')) {
exclude group: "com.google.android.gms"
compile ('com.google.android.gms:play-services-vision:15.0.1') {
force = true
}
}
implementation 'androidx.annotation:annotation:1.1.0'
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/"
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-awareness:18.0.0'
implementation 'com.google.android.gms:play-services-cast:18.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-iid:20.0.2'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'android.arch.work:work-runtime:1.0.1'
implementation 'com.android.support:multidex:1.0.3'
apply plugin: 'com.google.gms.google-services'
}
configurations {
all*.exclude group: 'com.google.guava', module:'guava-jdk5'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
android.useDeprecatedNdk=true
MYAPP_RELEASE_STORE_FILE=divo.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=Glaz5756523
MYAPP_RELEASE_KEY_PASSWORD=Glaz5756523
org.gradle.jvmargs=-Xmx4608m
android.jetifier.blacklist = your-troublemaker-library.jar