在构建本机应用程序时,出现以下错误。我在下面附加了错误和gradle文件。我还尝试过使用enableJetifier迁移到androidX,并且多次使用true和clean gradle来使用AndroidX,但仍然没有运气。
错误:
> Task :react-native-background-job:compileDebugJavaWithJavac
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\ReactNativeEventStarter.java:7: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\BackgroundJobModule.java:7: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
^
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\ExactJob.java:6: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
^
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\Utils.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\ReactNativeEventStarter.java:29: error: cannot find symbol
ReactNativeEventStarter(@NonNull Context context) {
^
symbol: class NonNull
location: class ReactNativeEventStarter
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\ReactNativeEventStarter.java:34: error: cannot find symbol
public void trigger(@NonNull Bundle jobBundle) {
^
symbol: class NonNull
location: class ReactNativeEventStarter
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\BackgroundJobModule.java:146: error: cannot find symbol
@Nullable @Override public Map<String, Object> getConstants() {
^
symbol: class Nullable
location: class BackgroundJobModule
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\ExactJob.java:14: error: cannot find symbol
@Override protected void onHandleIntent(@Nullable Intent intent) {
^
symbol: class Nullable
location: class ExactJob
C:\Users\Dell\Desktop\Projects\Getz New\app\node_modules\react-native-background-job\android\src\main\java\com\pilloxa\backgroundjob\Utils.java:14: error: cannot find symbol
public static boolean isReactNativeAppInForeground(@NonNull ReactNativeHost reactNativeHost) {
^
symbol: class NonNull
location: class Utils
9 errors.
What went wrong:
Execution failed for task ':react-native-background-job:compileDebugJavaWithJavac'
Build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.3"
}
repositories {
jcenter()
google()
}
dependencies {
// Specifically 3.0.1: concidered stable
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
Build.gradle / app:
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
dexOptions {
preDexLibraries = false
}
defaultConfig {
applicationId "com.dd.medworks"
minSdkVersion 21
targetSdkVersion 28
versionCode 3
versionName "2.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
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
}
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk true // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
shrinkResources false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
manifestPlaceholders = [excludeSystemAlertWindowPermission: "true"]
}
debug {
manifestPlaceholders = [excludeSystemAlertWindowPermission: "false"]
}
}
// 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:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
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
}
}
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
//compile project(':react-native-background-task')
compile(project(':react-native-svg')) {
exclude group: "com.android.support", module: "appcompat-v7"
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile project(':react-native-charts-wrapper')
compile "com.facebook.react:react-native:+" // From node_modules
compile files('libs/dnurseexttestlib.jar')
compile 'me.tankery.lib:circularSeekBar:1.1.7'
compile 'com.facebook.fresco:animated-gif:1.3.0'
compile project(':react-native-push-notification')
compile 'com.google.firebase:firebase-messaging:+'
implementation 'com.google.firebase:firebase-core:+'
compile 'com.google.android.gms:play-services-analytics:+'
compile ('com.google.android.gms:play-services-gcm:17.0.0') {
force = false;
}
// compile (project(':react-native-fcm')){
// exclude group: "com.google.firebase"
// }
implementation project(':rn-fetch-blob')
compile project(':react-native-pdf')
compile project(':react-native-background-job')
}
// 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'
}
答案 0 :(得分:0)
需要在android X中迁移。
在您的媒体库中进行更改
例如:android.support.annotation.NonNull更改为androidx.annotation.NonNull
答案 1 :(得分:0)
在androidx之后,android.support已过时,请在给定节点模块path中从android.support导入时使用androidx。希望这会成功