简体   繁体   English

安装新的 react-native 项目时找不到 swiperefreshlayout-1.0.0.aar 错误

[英]Could not find swiperefreshlayout-1.0.0.aar error when installing new react-native project

ok here is step by step what I do:好的,这是我所做的一步一步:

1- Configure the ANDROID_HOME environment variable. 1- 配置 ANDROID_HOME 环境变量。 I set sdk path我设置了 sdk 路径

2- Add platform-tools to environment variable PATH. 2- 将平台工具添加到环境变量 PATH。

3- run npx react-native init MyApp 3-运行 npx react-native init MyApp

4- connect my phone, enabling usb debugging 4-连接我的手机,启用usb调试

5- downloading and installing gradle 6.5.all 5-下载安装gradle 6.5.all

4- downloading and installing sdk build tools 29.0.2 4-下载并安装sdk构建工具29.0.2

5- start npx react-native start 5- 启动 npx react-native 启动

6- open up another terminal and run npx react-native run-android 6-打开另一个终端并运行 npx react-native run-android

this is where app should be installed on my phone but i get this error:这是应该在我的手机上安装应用程序的位置,但我收到此错误:

FAILURE: Build failed with an exception.

* What went wrong:

> Could not find swiperefreshlayout-1.0.0.aar (androidx.swiperefreshlayout:swiperefreshlayout:1.0.0).
 Searched in the following locations:
     file:/C:/Users/ali/Desktop/react-native/myApp/node_modules/react-native/android/androidx/swiperefreshlayout/swiperefreshlayout/1.0.0/swiperefreshlayout-1.0.0.aar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 59s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

this is my build.gradle file(myApp\android\build.gradle):这是我的 build.gradle 文件(myApp\android\build.gradle):

apply plugin: "com.android.application"

import com.android.build.OutputFile


project.ext.react = [
enableHermes: false,  // clean and rebuild if changing
]

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 rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.myapp"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate auniversal 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://reactnative.dev/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"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"  // From node_modules

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
    exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}
}


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)

i've been pulling my hairs out for 3 days.我已经拔了3天的头发了。 I tried this but in vain我试过这个但徒劳无功

Sorry if this is obvious to you, but the react-native masked view library isn't part of a clean react native project:抱歉,如果这对您来说很明显,但是react-native 蒙版视图库不是干净的反应原生项目的一部分:

Execution failed for task ':react-native-community_masked-view:generateDebugRFile'.任务“:react-native-community_masked-view:generateDebugRFile”执行失败。

My best guess is that you are trying to run react-native run-android from a different directory than the one you have just created.我最好的猜测是,您正在尝试从与您刚刚创建的目录不同的目录运行react-native run-android The error log indicates you are running run-android from C:/Users/ali/Desktop/react-native/myApp – can you verify this is the same directory you have installed the clean react-native app into?错误日志表明您正在从C:/Users/ali/Desktop/react-native/myApp运行run-android - 您能否验证这是您安装干净的 react-native 应用程序的同一目录? Running cd (Windows) or pwd (macOS, Unix, …) in the terminal prints the directory you are currently in.在终端中运行cd (Windows) 或pwd (macOS, Unix, ...) 会打印您当前所在的目录。

Again, apologies if this is all clear to you: The following should get started with a fresh project:再次道歉,如果这一切都对你很清楚:以下应该从一个新项目开始:

  1. Run npx react-native init NewApp from a directory of your choice, eg your desktop.从您选择的目录(例如桌面)运行npx react-native init NewApp You should now have a folder called NewApp on your desktop.现在,您的桌面上应该有一个名为NewApp的文件夹。
  2. Make sure you are in the correct folder (and not a subfolder of or a folder above) C:/Users/ali/Desktop/NewApp when starting any react-native tasks like npx react-native run-android .确保在启动任何 react-native 任务(如npx react-native run-android )时位于正确的文件夹(而不是其子文件夹或上面的文件夹) C:/Users/ali/Desktop/NewApp Verify by running cd if in doubt.如有疑问,请运行cd进行验证。
  3. Happy coding!快乐编码!

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

相关问题 运行项目时出错:找不到 swiperrefreshlayout.jar (androidx.swiperrefreshlayout:swiperrefreshlayout:1.0.0) - error in running project: Could not find swiperefreshlayout.jar (androidx.swiperefreshlayout:swiperefreshlayout:1.0.0) React-native android 项目有很多错误:找不到类“android.XXX” - React-native android project with many error: Could not find class 'android.XXX' androidx 迁移后本机应用程序上的 SwipeRefreshLayout 错误 - SwipeRefreshLayout error on a react-native app after androidx migration 如何将 aar 文件添加到 react-native 项目? - How to add aar file to react-native project? React-native项目错误“无法连接到开发服务器” - React-native project error “could not connect to development server” React-native项目中的Gradle @aar依赖关系解析 - Gradle @aar dependency resolution in react-native project 将react-native项目捆绑为iOS框架或(.aar)Android库 - Bundling react-native project as iOS framework or (.aar) Android library 我在建立以前的本机项目时发现错误? - I find error in setup a previous react-native project? 在现有的 React Native iOS 项目中安装 React-Native Android? - Installing React-Native Android in existing React Native iOS project? 尝试运行android react-native项目时出错 - Getting error when try to run android react-native project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM