Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit cea65ec

Browse files
Darin726YorkShen
authored andcommitted
[Android] Throw link error if load so failed in debugApp (#2705)
1 parent eae533c commit cea65ec

File tree

1 file changed

+52
-42
lines changed

1 file changed

+52
-42
lines changed

android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,25 @@ public static boolean initSo(String libName, int version, IWXUserTrackAdapter ut
125125

126126
boolean InitSuc = false;
127127
// if (checkSoIsValid(libName, BuildConfig.ARMEABI_Size) ||checkSoIsValid(libName, BuildConfig.X86_Size)) {
128-
129-
130-
try {
131-
// If a library loader adapter exists, use this adapter to load library
132-
// instead of System.loadLibrary.
133-
if (mSoLoader != null) {
134-
mSoLoader.doLoadLibrary("c++_shared");
135-
} else {
136-
System.loadLibrary("c++_shared");
128+
try {
129+
// If a library loader adapter exists, use this adapter to load library
130+
// instead of System.loadLibrary.
131+
if (mSoLoader != null) {
132+
mSoLoader.doLoadLibrary("c++_shared");
133+
} else {
134+
System.loadLibrary("c++_shared");
135+
}
136+
} catch (Exception | Error e) {
137+
WXExceptionUtils.commitCriticalExceptionRT(null,
138+
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT,
139+
"initSo",
140+
"load c++_shared failed Detail Error is: " +e.getMessage(),
141+
null);
142+
143+
if(WXEnvironment.isApkDebugable()) {
144+
throw e;
145+
}
137146
}
138-
} catch (Exception e) {
139-
e.printStackTrace();
140-
}
141147

142148
/**
143149
* Load library with {@link System#loadLibrary(String)}
@@ -160,40 +166,44 @@ public static boolean initSo(String libName, int version, IWXUserTrackAdapter ut
160166
"\n Detail Error is: " +e2.getMessage(),
161167
null);
162168
}
163-
InitSuc = false;
164-
}
165-
166-
try {
167-
168-
if (!InitSuc) {
169-
170-
//File extracted from apk already exists.
171-
if (isExist(libName, version)) {
172-
boolean res = _loadUnzipSo(libName, version, utAdapter);
173-
if (res) {
174-
return res;
175-
} else {
176-
//Delete the corrupt so library, and extract it again.
177-
removeSoIfExit(libName, version);
178-
}
179-
}
180-
181-
//Fail for loading file from libs, extract so library from so and load it.
182-
if (cpuType.equalsIgnoreCase(MIPS)) {
183-
return false;
184-
} else {
185-
try {
186-
InitSuc = unZipSelectedFiles(libName, version, utAdapter);
187-
} catch (IOException e2) {
188-
e2.printStackTrace();
189-
}
190-
}
191169

170+
if(WXEnvironment.isApkDebugable()) {
171+
throw e2;
192172
}
193-
} catch (Exception | Error e) {
194173
InitSuc = false;
195-
e.printStackTrace();
196174
}
175+
176+
// try {
177+
178+
// if (!InitSuc) {
179+
//
180+
// //File extracted from apk already exists.
181+
// if (isExist(libName, version)) {
182+
// boolean res = _loadUnzipSo(libName, version, utAdapter);
183+
// if (res) {
184+
// return res;
185+
// } else {
186+
// //Delete the corrupt so library, and extract it again.
187+
// removeSoIfExit(libName, version);
188+
// }
189+
// }
190+
//
191+
// //Fail for loading file from libs, extract so library from so and load it.
192+
// if (cpuType.equalsIgnoreCase(MIPS)) {
193+
// return false;
194+
// } else {
195+
// try {
196+
// InitSuc = unZipSelectedFiles(libName, version, utAdapter);
197+
// } catch (IOException e2) {
198+
// e2.printStackTrace();
199+
// }
200+
// }
201+
//
202+
// }
203+
// } catch (Exception | Error e) {
204+
// InitSuc = false;
205+
// e.printStackTrace();
206+
// }
197207
// }
198208
return InitSuc;
199209
}

0 commit comments

Comments
 (0)