You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2019/07/15 09:12:10 UTC

[incubator-weex] branch master updated: [Android] Throw link error if load so failed in debugApp (#2705)

This is an automated email from the ASF dual-hosted git repository.

kyork pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new cea65ec  [Android] Throw link error if load so failed in debugApp (#2705)
cea65ec is described below

commit cea65ecd866f2356300847f90e01387b47d5ff9d
Author: darin <dy...@qq.com>
AuthorDate: Mon Jul 15 17:12:03 2019 +0800

    [Android] Throw link error if load so failed in debugApp (#2705)
---
 .../com/taobao/weex/utils/WXSoInstallMgrSdk.java   | 94 ++++++++++++----------
 1 file changed, 52 insertions(+), 42 deletions(-)

diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
index 2bfc9f0..1fc329a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
@@ -125,19 +125,25 @@ public class WXSoInstallMgrSdk {
 
     boolean InitSuc = false;
 //    if (checkSoIsValid(libName, BuildConfig.ARMEABI_Size) ||checkSoIsValid(libName, BuildConfig.X86_Size)) {
-
-
-    try {
-      // If a library loader adapter exists, use this adapter to load library
-      // instead of System.loadLibrary.
-      if (mSoLoader != null) {
-        mSoLoader.doLoadLibrary("c++_shared");
-      } else {
-        System.loadLibrary("c++_shared");
+      try {
+        // If a library loader adapter exists, use this adapter to load library
+        // instead of System.loadLibrary.
+        if (mSoLoader != null) {
+          mSoLoader.doLoadLibrary("c++_shared");
+        } else {
+          System.loadLibrary("c++_shared");
+        }
+      } catch (Exception | Error e) {
+        WXExceptionUtils.commitCriticalExceptionRT(null,
+                WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT,
+                "initSo",
+                        "load c++_shared failed Detail Error is: " +e.getMessage(),
+                null);
+
+        if(WXEnvironment.isApkDebugable()) {
+          throw e;
+        }
       }
-    } catch (Exception e) {
-        e.printStackTrace();
-    }
 
       /**
        * Load library with {@link System#loadLibrary(String)}
@@ -160,40 +166,44 @@ public class WXSoInstallMgrSdk {
                           "\n Detail Error is: " +e2.getMessage(),
                   null);
         }
-        InitSuc = false;
-      }
-
-      try {
-
-        if (!InitSuc) {
-
-          //File extracted from apk already exists.
-          if (isExist(libName, version)) {
-            boolean res = _loadUnzipSo(libName, version, utAdapter);
-            if (res) {
-              return res;
-            } else {
-              //Delete the corrupt so library, and extract it again.
-              removeSoIfExit(libName, version);
-            }
-          }
-
-          //Fail for loading file from libs, extract so library from so and load it.
-          if (cpuType.equalsIgnoreCase(MIPS)) {
-            return false;
-          } else {
-            try {
-              InitSuc = unZipSelectedFiles(libName, version, utAdapter);
-            } catch (IOException e2) {
-              e2.printStackTrace();
-            }
-          }
 
+        if(WXEnvironment.isApkDebugable()) {
+          throw e2;
         }
-      } catch (Exception | Error e) {
         InitSuc = false;
-        e.printStackTrace();
       }
+
+//      try {
+
+//        if (!InitSuc) {
+//
+//          //File extracted from apk already exists.
+//          if (isExist(libName, version)) {
+//            boolean res = _loadUnzipSo(libName, version, utAdapter);
+//            if (res) {
+//              return res;
+//            } else {
+//              //Delete the corrupt so library, and extract it again.
+//              removeSoIfExit(libName, version);
+//            }
+//          }
+//
+//          //Fail for loading file from libs, extract so library from so and load it.
+//          if (cpuType.equalsIgnoreCase(MIPS)) {
+//            return false;
+//          } else {
+//            try {
+//              InitSuc = unZipSelectedFiles(libName, version, utAdapter);
+//            } catch (IOException e2) {
+//              e2.printStackTrace();
+//            }
+//          }
+//
+//        }
+//      } catch (Exception | Error e) {
+//        InitSuc = false;
+//        e.printStackTrace();
+//      }
   //  }
     return InitSuc;
   }