Код: Выделить всё
Duplicate class org.hamcrest.BaseDescription found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.BaseMatcher found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.CoreMatchers found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.Description found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.Factory found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.Matcher found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.SelfDescribing found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.StringDescription found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.AllOf found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.AnyOf found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.DescribedAs found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.Is found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.IsAnything found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.IsEqual found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.IsInstanceOf found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.IsNot found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.IsNull found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.core.IsSame found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.internal.ArrayIterator found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.internal.SelfDescribingValue found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Duplicate class org.hamcrest.internal.SelfDescribingValueIterator found in modules hamcrest-core-1.1.jar -> hamcrest-core-1.1 (org.hamcrest:hamcrest-core:1.1) and junit-4.10.jar -> junit-4.10 (junit:junit:4.10)
Код: Выделить всё
package com.packge.webview;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.ViewTreeObserver;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
private SwipeRefreshLayout mySwipeRefreshLayout;
private ViewTreeObserver.OnScrollChangedListener mOnScrollChangedListener;
@SuppressLint({"SetJavaScriptEnabled", "MissingInflatedId"})
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = findViewById(R.id.web_view);
mySwipeRefreshLayout = this.findViewById(R.id.swipeContainer);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(false);
mWebView.getSettings().setDisplayZoomControls(false);
mWebView.setWebChromeClient(new WebChromeClient());
String siteUrl = "https://website.com";
mWebView.loadUrl(siteUrl);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
Toast.makeText(MainActivity.this, "درحال بارگذاری...", Toast.LENGTH_SHORT).show();
}
@Override
public void onPageFinished(WebView view, String url) {
mySwipeRefreshLayout.setRefreshing(false);
Toast.makeText(MainActivity.this, "بارگذاری به اتمام رسید", Toast.LENGTH_SHORT).show();
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(MainActivity.this, "خطایی رخ داد! " + description, Toast.LENGTH_SHORT).show();
//Clear WebView
try {
view.stopLoading();
} catch (Exception e) {
e.printStackTrace();
}
try {
view.clearView();
} catch (Exception e) {
e.printStackTrace();
}
if (view.canGoBack()) {
view.goBack();
}
String ErrorPagePath = "file:///assets/index.html";
view.loadUrl(ErrorPagePath);
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
mWebView.loadUrl(siteUrl);
mySwipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mWebView.reload();
}
});
}
@Override
protected void onStart() {
super.onStart();
mySwipeRefreshLayout.getViewTreeObserver()
.addOnScrollChangedListener(mOnScrollChangedListener =
new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
mySwipeRefreshLayout.setEnabled(mWebView.getScrollY() == 0);
}
});
}
@Override
protected void onStop() {
super.onStop();
mySwipeRefreshLayout.getViewTreeObserver()
.removeOnScrollChangedListener(mOnScrollChangedListener);
}
}
Код: Выделить всё
Код: Выделить всё
plugins {
alias(libs.plugins.android.application)
}
android {
namespace 'com.packge.webview'
compileSdkVersion 34
buildToolsVersion '35.0.0 rc3'
defaultConfig {
applicationId "com.packge.webview"
minSdk 21
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildToolsVersion '35.0.0 rc3'
}
dependencies {
implementation libs.appcompat
implementation libs.material
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
implementation libs.guava
implementation libs.swiperefreshlayout
implementation libs.testng
testImplementation 'junit:junit:4.13.2'
androidTestImplementation libs.espresso.core
constraints {
implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation libs.appcompat.v170beta01
}
Я протестировал решение конфигурации, но оно не сработало, и я столкнулся с еще одной ошибкой, и даже после добавления этого:
Код: Выделить всё
testImplementation 'org.hamcrest:hamcrest-core:1.1'
Создание программного обеспечения для веб-просмотра, которое показывало такую ошибку при выводе. К сожалению, я не знаю решения и мне нужна помощь. Я не нашел решения в Интернете, или предложенные решения не решили проблему
Подробнее здесь: https://stackoverflow.com/questions/784 ... oid-studio