[英]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:再次道歉,如果这一切都对你很清楚:以下应该从一个新项目开始:
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
的文件夹。C:/Users/ali/Desktop/NewApp
when starting any react-native tasks like npx react-native run-android
.npx react-native run-android
)时位于正确的文件夹(而不是其子文件夹或上面的文件夹) C:/Users/ali/Desktop/NewApp
Verify by running cd
if in doubt.cd
进行验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.