提问人:Monish Ks 提问时间:8/24/2023 更新时间:8/24/2023 访问量:68
线程“main”java.io.FileNotFoundException中的异常:https://downloads.gradle.org/distributions/gradle-8.1.0-all.zip
Exception in thread "main" java.io.FileNotFoundException: https://downloads.gradle.org/distributions/gradle-8.1.0-all.zip
问:
我正在尝试使用 npm 构建我的应用程序,但我被困在这个错误上几个小时,我仍然无法弄清楚原因。我尝试删除gradle-wrapper.properties文件,创建一个新文件。但它仍然不起作用。
这是我的gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME distributionPath=包装器/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=包装器/dists distributionUrl=https://services.gradle.org/distributions/gradle-8.1.0-all.zip
这就是我一直得到的错误。
Exception in thread "main" java.io.FileNotFoundException: https://downloads.gradle.org/distributions/gradle-8.1.0-all.zipat java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1993)at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)at org.gradle.wrapper.Download.downloadInternal(Download.java:58)at org.gradle.wrapper.Download.download(Download.java:44)at org.gradle.wrapper.Install$1.call(Install.java:59)at org.gradle.wrapper.Install$1.call(Install.java:46)at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)at org.gradle.wrapper.Install.createDist(Install.java:46)at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
gradle.build
apply plugin: "com.android.application"
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 33
buildToolsVersion "33.0.1"
defaultConfig {
applicationId "com.timetable"
minSdkVersion 31
targetSdkVersion 31
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) {
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-splash-screen')
implementation project(':react-native-material-kit')
implementation project(':react-native-vector-icons')
implementation project(':react-native-i18n')
implementation fileTree(dir: "libs", include: \["\*.jar"\])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+"
def work_version = "2.6.0"
classpath 'com.android.tools.build:gradle:7.4.2'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.implementation
into 'libs'
}
subprojects { subproject -\>
if(project\['name'\] == 'react-native-geocoder'){
project.configurations { compile { } }
}
}
答:
1赞
Vampire
8/24/2023
#1
虽然你不应该使用 ,但是,你的问题是“8.1.0”与“8.1”。-all
-bin
只有修补程序版本只有三位数,主要版本只有两位数。
评论
0赞
Monish Ks
8/24/2023
谢谢,这解决了这个问题,但它带来了另一个问题 找不到 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型对象上的参数 [com.android.tools.build:gradle:8.1.0] 的方法 classpath()。我尝试更改版本号,但无法解决此问题
0赞
Vampire
8/24/2023
您不应该在评论中发布后续问题,而应该在评论中发布新问题。另外,请看一下 stackoverflow.com/help/someone-answers。但是关于你的问题,你的构建脚本充满了遗留的东西和不好的做法。其中之一是,您以传统方式应用插件,但做错了。该配置不是生产配置,而是构建脚本配置,您需要在块中声明该依赖项,或者最好停止使用应用 pluigins 的传统方式。classpath
buildscript { ... }
评论