#maven #android-studio #gradle
Вопрос:
Я только что обновил Android Studio с 4.1.1 до 4.2.2. Ниже приведен файл моего проекта build.gradle. После обновления запуск моего приложения работает нормально, но запуск тестов завершается неудачей. Машины с Android Studio 4.1.1, на которых выполняются тесты, все еще работают.
Я понимаю, что для запроса в репозиторий maven теперь требуется https, но у меня нет ссылки в файле by gradle. Это действует так, как если бы 4.2.2 изменил репозиторий MavenCentral на использование http вместо https, в противном случае я не уверен, почему это сработало в 4.1.1, но не в 4.2.2. Есть ли способ заставить репозиторий быть https?
стройте.
buildscript {
ext {
kotlinVersion = '1.3.72'
}
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:perf-plugin:1.3.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
flatDir {
// Needs to be here to be included in both misnap and app modules
dirs project(':misnapworkflow_UX2').file('libs')
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
buildToolsVersion = '29.0.2'
compileSdkVersion = 29
minSdkVersion = 21
targetSdkVersion = 29
daggerVersion = '2.27'
okHttpVersion = '4.7.2'
}
Ошибка при выполнении тестов
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.robolectric.util.ReflectionHelpers$6 (file:/Users/jwhitsit/.gradle/caches/modules-2/files-2.1/org.robolectric/shadowapi/4.3.1/a93e55b36c418aa3afc17c26eac82590a3bfb63e/shadowapi-4.3.1.jar) to method java.lang.ClassLoader.getPackage(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.robolectric.util.ReflectionHelpers$6
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[Robolectric] com.commercebank.honeybadger.chat.ChatWindowFragmentTest.whenMinimizeClicked_CloseFragment: sdk=28; resources=BINARY
Downloading from maven
Downloading: org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.pom from repository sonatype at https://oss.sonatype.org/content/groups/public/
Error transferring file: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
[WARNING] Unable to get resource 'org.robolectric:android-all:pom:10-robolectric-5803371' from repository sonatype (https://oss.sonatype.org/content/groups/public/): Error transferring file: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
Downloading: org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.pom from repository central at http://repo1.maven.org/maven2
Error transferring file: Server returned HTTP response code: 501 for URL: http://repo1.maven.org/maven2/org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.pom
[WARNING] Unable to get resource 'org.robolectric:android-all:pom:10-robolectric-5803371' from repository central (http://repo1.maven.org/maven2): Error transferring file: Server returned HTTP response code: 501 for URL: http://repo1.maven.org/maven2/org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.pom
Downloading: org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.jar from repository sonatype at https://oss.sonatype.org/content/groups/public/
Error transferring file: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
[WARNING] Unable to get resource 'org.robolectric:android-all:jar:10-robolectric-5803371' from repository sonatype (https://oss.sonatype.org/content/groups/public/): Error transferring file: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
Downloading: org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.jar from repository central at http://repo1.maven.org/maven2
Error transferring file: Server returned HTTP response code: 501 for URL: http://repo1.maven.org/maven2/org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.jar
[WARNING] Unable to get resource 'org.robolectric:android-all:jar:10-robolectric-5803371' from repository central (http://repo1.maven.org/maven2): Error transferring file: Server returned HTTP response code: 501 for URL: http://repo1.maven.org/maven2/org/robolectric/android-all/10-robolectric-5803371/android-all-10-robolectric-5803371.jar
Unable to resolve artifact: Missing:
----------
1) org.robolectric:android-all:jar:10-robolectric-5803371
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=10-robolectric-5803371 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=10-robolectric-5803371 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) org.robolectric:android-all:jar:10-robolectric-5803371
----------
1 required artifact is missing.
for artifact:
org.apache.maven:super-pom:pom:2.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
sonatype (https://oss.sonatype.org/content/groups/public/)
at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:268)
at org.apache.maven.artifact.ant.DependenciesTask.doExecute(DependenciesTask.java:168)
at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751)
at org.robolectric.internal.dependency.MavenDependencyResolver.whileLocked(MavenDependencyResolver.java:95)
at org.robolectric.internal.dependency.MavenDependencyResolver.getLocalArtifactUrls(MavenDependencyResolver.java:74)
at org.robolectric.internal.dependency.MavenDependencyResolver.getLocalArtifactUrls(MavenDependencyResolver.java:39)
at org.robolectric.internal.dependency.MavenDependencyResolver.getLocalArtifactUrl(MavenDependencyResolver.java:107)
at org.robolectric.internal.dependency.CachedDependencyResolver.getLocalArtifactUrl(CachedDependencyResolver.java:44)
at org.robolectric.plugins.CachedMavenDependencyResolver.getLocalArtifactUrl(CachedMavenDependencyResolver.java:32)
at org.robolectric.plugins.LegacyDependencyResolver.getLocalArtifactUrl(LegacyDependencyResolver.java:86)
at org.robolectric.plugins.DefaultSdkProvider$DefaultSdk.getJarPath(DefaultSdkProvider.java:127)
at org.robolectric.android.internal.AndroidTestEnvironment.loadAppPackage_measured(AndroidTestEnvironment.java:309)
at org.robolectric.android.internal.AndroidTestEnvironment.lambda$loadAppPackage$1(AndroidTestEnvironment.java:284)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
at org.robolectric.android.internal.AndroidTestEnvironment.loadAppPackage(AndroidTestEnvironment.java:282)
at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:178)
at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:169)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:301)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:243)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
----------
1) org.robolectric:android-all:jar:10-robolectric-5803371
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=10-robolectric-5803371 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=10-robolectric-5803371 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) org.robolectric:android-all:jar:10-robolectric-5803371
----------
1 required artifact is missing.
for artifact:
org.apache.maven:super-pom:pom:2.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
sonatype (https://oss.sonatype.org/content/groups/public/)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:360)
at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:263)
... 23 more
Ответ №1:
Пожалуйста, попробуйте обновить свой плагин для сборки Android Gradle до
classpath 'com.android.tools.build:gradle:4.2.2'
В качестве альтернативы, в качестве обходного пути, вы можете попытаться заменить mavenCentral()
на
maven { url "https://repo.maven.apache.org/maven2" }