繁体   English   中英

React-native 找不到包 android.support.v7.app

[英]React-native Cant find package android.support.v7.app

我遇到了这个非常烦人的错误,它不会让我构建......它说它找不到包 android.support.v7.app 我的 SplashScreen js 文件中到处都是错误

error: package android.support.v7.app does not exist
import android.support.v7.app.AppCompatActivity;
                             ^
D:\FifaLeagueApp\FifaIL\android\app\src\main\java\com\fifail\SplashActivity.java:7: error: cannot find symbol
public class SplashActivity extends AppCompatActivity {
                                ^

我会提供我的毕业证书(我认为问题来自他们,但我无法弄清楚究竟是什么原因造成的)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.2')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
}

...

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
...
    defaultConfig {
        applicationId "com.fifail"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
 ...

dependencies {
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-restart')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation "com.facebook.react:react-native:+"  // From node_modules
}
....
}

听起来您已经启用了AndroidX

检查您的android / gradle.properties并禁用它

useAndroidX=true

useAndroidX=false

如果启用此功能,则会跳过appcompat v7

编辑:如果您需要AndroidX做我上面提到的,并添加到您的android / app / build.gradle新版本的appcompat

implementation 'androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}'

并在android / build.gradle上

supportLibVersion = '1.0.0'

终于解决了这个问题,在这里为像我这样来这里寻找解决方案的人发布解决方案:

只需将导入更改为以下内容: 在此处输入图片说明

干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM