@@ -37,15 +37,35 @@ public void onException(Exception e) {
37
37
*/
38
38
public static void doUpdate (@ Nullable String apiKey ,@ Nullable String appKey , ExceptionHandler handler ){
39
39
if (TextUtils .isEmpty (apiKey ) || TextUtils .isEmpty (appKey )){
40
+ Class reflect = null ;
41
+ try {
42
+ reflect = Class .forName (AppUtils .getAppPackageName () + ".BuildConfig" );
40
43
44
+ } catch (ClassNotFoundException e ) {
45
+ LogUtils .i (e );
46
+ String path = Utils .getApp ().getClass ().getName ();
47
+ LogUtils .i ("application class path: " +path );
48
+ path = path .substring (0 ,path .lastIndexOf ("." ));
49
+ try {
50
+ reflect = Class .forName (path + ".BuildConfig" );
51
+ } catch (ClassNotFoundException ex ) {
52
+ LogUtils .w (ex );
53
+ }
54
+ }
55
+ if (reflect == null ){
56
+ LogUtils .w ("没有找到BuildConfig,拿不到蒲公英的key,无法发起更新请求" );
57
+ return ;
58
+ }
41
59
try {
42
- Class reflect = Class .forName (AppUtils .getAppPackageName () + ".BuildConfig" );
43
- apiKey = (String ) reflect .getDeclaredField ("pyger_api_key" ).get (reflect );
60
+ apiKey = (String ) reflect .getDeclaredField ("pyger_api_key" ).get (reflect );
44
61
appKey = (String ) reflect .getDeclaredField ("pyger_app_key" ).get (reflect );
45
62
LogUtils .i ("get api_key and app_key : " + apiKey +"->" +appKey );
46
- } catch (Exception e ) {
47
- LogUtils .w (e );
63
+ } catch (Throwable e ) {
64
+ LogUtils .i ("app更新->没有配置相关key" ,e );
65
+ //return;
48
66
}
67
+
68
+
49
69
}
50
70
//FileDownloader.setup(Utils.getApp());
51
71
//UpdateAppManager.setDefaultHttpImpl(new UpdateAppPgyer());
0 commit comments