Jelajahi Sumber

Merge pull request #27 from VoryWork/main

Fix Dex File Load Error On API 34+
JonaNorman 7 bulan lalu
induk
melakukan
8529f9750c

+ 1 - 10
app/build.gradle

@@ -8,14 +8,9 @@ android {
         compileSdk 33
         applicationId "com.norman.webviewup.demo"
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 35
         versionCode 1
         versionName "1.0"
-
-        ndk {
-            abiFilters "armeabi-v7a"
-//            abiFilters "arm64-v8a", "armeabi-v7a"
-        }
     }
 
     aaptOptions {
@@ -51,10 +46,6 @@ android {
             jniLibs.srcDirs = ["libs"]
         }
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_8
-        targetCompatibility JavaVersion.VERSION_1_8
-    }
     namespace 'com.norman.webviewup.demo'
 }
 

+ 12 - 0
app/src/main/java/com/norman/webviewup/demo/MainActivity.java

@@ -96,6 +96,17 @@ public class MainActivity extends Activity implements UpgradeCallback {
                         "com.google.android.webview",
                         "122.0.6261.64",
                         "https://mirror.ghproxy.com/https://raw.githubusercontent.com/JonaNorman/ShareFile/main/com.google.android.webview_122.0.6261.64_x86.zip",
+                        "网络"),
+                new UpgradeInfo("com.google.android.webview",
+                        "131.0.6778.105",
+                        "com.google.android.webview_131.0.6778.105-677810506_minAPI26_maxAPI28(x86)(nodpi)_apkmirror.com.apk",
+                        "内置")
+        ));
+        UPGRADE_PACKAGE_MAP.put("x86_64", Arrays.asList(
+                new UpgradeInfo(
+                        "com.google.android.webview",
+                        "131.0.6778.135",
+                        "https://www.ghproxy.cn/https://github.com/VoryWork/AndroidWebviewNew/releases/download/131.0.6778.135/x64.apk",
                         "网络")
         ));
 
@@ -177,6 +188,7 @@ public class MainActivity extends Activity implements UpgradeCallback {
         builder.setTitle("Choose WebView");
         List<UpgradeInfo> upgradeInfoList = UPGRADE_PACKAGE_MAP.get(ProcessUtils.getCurrentInstruction());
 
+        assert upgradeInfoList != null;
         String[] items = new String[upgradeInfoList.size()];
         for (int i = 0; i < items.length; i++) {
             items[i] = upgradeInfoList.get(i).title;

+ 9 - 0
core/src/main/java/com/norman/webviewup/lib/WebViewReplace.java

@@ -8,6 +8,7 @@ import android.os.IBinder;
 import android.os.IInterface;
 import android.os.Looper;
 import android.text.TextUtils;
+import android.util.Log;
 import android.webkit.WebView;
 
 import com.norman.webviewup.lib.hook.PackageManagerServiceHook;
@@ -18,6 +19,8 @@ import com.norman.webviewup.lib.service.interfaces.IWebViewFactory;
 import com.norman.webviewup.lib.service.interfaces.IWebViewUpdateService;
 import com.norman.webviewup.lib.util.FileUtils;
 
+import java.io.File;
+
 
 public class WebViewReplace {
 
@@ -55,12 +58,18 @@ public class WebViewReplace {
                 }
             }
             managerHook = new PackageManagerServiceHook(context, packageInfo.packageName, apkPath,libsPath);
+            Log.i("Upgrade","apkPath:"+apkPath);
+
             updateServiceHook = new WebViewUpdateServiceHook(context, packageInfo.packageName);
             managerHook.hook();
             updateServiceHook.hook();
             if (SYSTEM_WEB_VIEW_PACKAGE_INFO == null) {
                 SYSTEM_WEB_VIEW_PACKAGE_INFO = loadCurrentWebViewPackageInfo();
             }
+            File file = new File(apkPath);
+            if(file.exists()){
+                file.setReadOnly();
+            }
             checkWebView(context);
             REPLACE_WEB_VIEW_PACKAGE_INFO = loadCurrentWebViewPackageInfo();
         } catch (Throwable throwable) {

+ 2 - 0
core/src/main/java/com/norman/webviewup/lib/source/UpgradeAssetSource.java

@@ -3,6 +3,7 @@ package com.norman.webviewup.lib.source;
 import android.content.Context;
 import android.content.res.AssetFileDescriptor;
 import android.content.res.AssetManager;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
 
@@ -35,6 +36,7 @@ public class UpgradeAssetSource extends UpgradePathSource {
                 outputStream = new FileOutputStream(getApkPath());
                 FileChannel dstChannel = outputStream.getChannel();
                 AssetManager assetManager = getContext().getAssets();
+                Log.d("AssetsUpdater",assetManager.openFd(assetName).toString());
                 AssetFileDescriptor assetFileDescriptor = assetManager.openFd(assetName);
                 inputStream = assetFileDescriptor.createInputStream();
                 FileChannel fileChannel = inputStream.getChannel();

+ 0 - 1
gradle.properties

@@ -24,4 +24,3 @@ MAVEN_LIB_GROUP=io.github.jonanorman.android.webviewup
 MAVEN_LIB_GIT_URL=https://github.com/JonaNorman/WebViewUpgrade
 MAVEN_LIB_LICENSE=MIT
 
-org.gradle.java.home=/Applications/Android Studio.app/contents/jbr/Contents/Home