React Native:错误包android.support.annotation不存在

时间:2019-11-08 21:26:16

标签: android react-native

引发错误
  

任务:react-native-camera:compileGeneralReleaseJavaWithJavac FAILED

错误略有不同,但是所有插入符号都指向一个不存在的软件包。此后大约还有100个非常相似: enter image description here enter image description here

我有一个RN v0.57项目,需要更新才能进入Play商店,在尝试直接升级后,我开始看到google从未见过的错误,因此我选择制作一个新项目,在我的src文件夹和相关的package.json数据上移植端口。

根据过去的经验,以这种方式解决所有错误可能要花我一周的时间,而不是我期望的升级所带来的错误。在解决这个问题之前,我已经修复了大约十二个错误,因此我不能确定那里的修复程序没有引入该错误,但是我认为那样根本无法使您取得任何进展,所以我在这里找到了自己。 >

我已经阅读了一些有关androidx的信息,或者与此相关或可能的修复程序,但是我要做的最后一件事是开始介绍可能出错的新事物。该代码库很好,可以在0.57上运行,我只想将其升级到最新版本,在商店中使用它,再也不必关注React native。

这是我的package.json:

{
  "name": "(Projectname)",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@babel/runtime": "^7.1.2",
    "@react-native-community/cli-platform-android": "^2.9.0",
    "@svgr/core": "^4.2.0",
    "axios": "^0.18.0",
    "date-fns": "^1.30.1",
    "link": "^0.1.5",
    "moment": "^2.24.0",
    "pod-installer": "0.0.0",
    "qs": "^6.5.2",
    "react": "16.9.0",
    "react-moment": "^0.8.4",
    "react-native": "0.61.4",
    "react-native-action-picker": "^1.0.2",
    "react-native-action-sheet": "^2.2.0",
    "react-native-android-log": "^1.1.0",
    "react-native-button": "^2.3.0",
    "react-native-cached-image": "^1.4.3",
    "react-native-calendar-picker": "^6.0.0",
    "react-native-camera": "^2.11.0",
    "react-native-communications": "^2.2.1",
    "react-native-date-picker": "^2.3.0",
    "react-native-document-picker": "^2.1.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-fit-image": "^1.5.4",
    "react-native-fontawesome": "^6.0.1",
    "react-native-fs": "^2.13.2",
    "react-native-gesture-handler": "^1.0.17",
    "react-native-image-crop-picker": "^0.22.0",
    "react-native-lazyload-deux": "^2.0.4",
    "react-native-photo-editor": "^1.0.0",
    "react-native-responsive-grid": "^0.41.992",
    "react-native-router-flux": "^4.0.0-beta.31",
    "react-native-simple-toast": "0.0.8",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.3.7",
    "react-native-tab-view": "0.0.74",
    "react-native-web-swiper": "^1.15.1",
    "react-navigation": "^3.3.0",
    "react-navigation-stack": "^1.0.10",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0",
    "semver": "^6.0.0",
    "uuid": "^3.3.2"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "babel-core": "^7.0.0-bridge.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.47.0",
    "react-native-svg-transformer": "^0.12.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./src/fonts"
    ]
  }
}

我的Android \ app \ build.gradle:

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.projectname"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        missingDimensionStrategy 'react-native-camera', 'general' (this was a fix I found and tried but hasn't helped)
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            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 {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-gcm:12.+" 
    implementation 'com.android.support:appcompat-v7:28.0.0'
    androidTestImplementation "com.android.support:support-annotations:28.0.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
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

还有我的Android \ build.gradle,与我添加的与google服务相关的任何内容都试图解决该错误,但并没有帮助:

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        googlePlayServicesVersion = "16.+"
        firebaseVersion = "17.3.4"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "26.+"
                }
                if (details.requested.group == 'com.google.android.gms'
                && !details.requested.name.contains('multidex') && (
                    !details.requested.name.contains('play-services-stats') ||
                    !details.requested.name.contains('play-services-vision-image-label') ||
                    !details.requested.name.contains('play-services-clearcut') ||
                    !details.requested.name.contains('play-services-flags') ||
                    !details.requested.name.contains('play-services-phenotype')
                    )) {
                    details.useVersion "12.+"
                }
                if (details.requested.group == 'com.google.android.gms'
                && !details.requested.name.contains('multidex') && (
                    details.requested.name.contains('play-services-stats') ||
                    details.requested.name.contains('play-services-vision-image-label') ||
                    details.requested.name.contains('play-services-clearcut') ||
                    details.requested.name.contains('play-services-flags') ||
                    details.requested.name.contains('play-services-phenotype')
                    )) {
                    details.useVersion "+"
                }
                if (details.requested.group == 'com.google.firebase'
                && !details.requested.name.contains('multidex') && details.requested.name.contains('firebase-messaging')) {
                    details.useVersion "12.+"
                }
            }
        }
    }
}

ext {
    googlePlayServicesVersion = "+" // default: "+"
    firebaseVersion = "+" // default: "+"
    // Other settings
    compileSdkVersion = 28 // default: 23
    buildToolsVersion = "28.0.3" // default: "23.0.1"
    targetSdkVersion = 28 // default: 23
    supportLibVersion = "28.0.0"
}

对此的任何帮助或建议,将不胜感激。最终目标是将我正在使用的RN v0.57应用程序带到商店中,而我正在尝试将我的应用程序移植到新的ind'd RN项目就是为了做到这一点,因此,如果您知道一种更简单的方法,那么我很乐意走这条路。据我所知,没有快速的“修补程序”,我可以申请0.57以使其能被Play商店接受,并直接从0.57升级,我认为鉴于我在进行任何版本更改时遇到的问题,难度会大得多在过去的RN中。

0 个答案:

没有答案