Android Studio config debug under debug using formal signature

Source: Internet
Author: User

Today, as part of the integration Sharing feature, follow the official documentation step-by-step. This is to send the content we want to share, all kinds of methods to see the document, the code is as follows:

Iwxapi API = MyApplication. getinstance(). Getwxapi();if (!api. iswxappinstalled()) {Toastfactory. Gettoast(Activity,"You have not installed the client"). Show();Return;} wxwebpageobject webpage = new Wxwebpageobject ();Webpage. Webpageurl= Notice. GetUrl();Wxmediamessage msg = new Wxmediamessage (webpage);Msg. Title= Notice. GetDesc();Msg. Description= Notice. GetDesc();Bitmap thumb = bitmapfactory. Decoderesource(Activity. Getresources(), R. drawable. Umeng_socialize_wechat);Msg. Setthumbimage(thumb);Sendmessagetowx. Reqreq = new Sendmessagetowx. Req();Req. Transaction= String. ValueOf(System. Currenttimemillis());Req. Message= Msg;Req. Scene= Sendmessagetowx. Req. Wxscenesession;Api. Sendreq(req);

Written here, can be said to be finished. If we want to know if we are sending it successfully, we can write it this way.

 Public  class wxentryactivity extends Activity  implements  Iwxapieventhandler {    @Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_wxentry);        Iwxapi Iwxapi = Hhcookapp.getinstance (). GETWXAPI (); Iwxapi.handleintent (Getintent (), This); }@Override    protected void Onresume() {Super. Onresume ();    Finish (); }@Override     Public void Onreq(Basereq basereq) {    }@Override     Public void Onresp(Baseresp resp) {String result ="";Switch(Resp.errcode) { CaseBaseResp.ErrCode.ERR_OK:result ="Errcode_success"; Break; CaseBaseResp.ErrCode.ERR_USER_CANCEL:result ="Errcode_cancel"; Break; CaseBaseResp.ErrCode.ERR_AUTH_DENIED:result ="Errcode_deny"; Break;default: result ="Errcode_unknown"; Break; } toastfactory.gettoast ( This, result). Show (); }}

All right, the code's done. But the test refused directly, Errcode_deny direct toast show out. This is depressing me. This is why, continue to check the code, OK no problem, so think of the damned application signature, to tell the truth, I still like this signature, after all, the security of the application has been greatly improved. I suddenly found that the generated signature file Xxx.jks has been lost. Okay, I was wrong. Regenerate a replacement application signature to submit the audit. Alas... Waited a few hours. Finally the audit passed. I excitedly in the Build.gradle file with the following code configuration, note that my. jks file is copied from the app's root directory:

  signingConfigs {        release {            ‘xxx‘            ‘xxxx‘            file(‘./xxx.jks‘)            ‘xxx‘        }        config {            ‘xxx‘            ‘xxx‘            file(‘./xxx.jks‘)            ‘xxx‘        }    }

Test, failure, my heart is also pulled cold pull cold. The wind is rustling and easy water cold, the heroes of a go to Xi no return. Clean up the old mountains and make a new formal bag. To continue testing:

OK, pass.
Suddenly placid. Because I think this can not pass, I should be a unloads. I think that we usually debug in debug mode, that is, I use the formal application signature, and I adjust the debug signature is not the same. I'm not going to have to pack it every time I debug, obviously it's unreasonable. So I wrote:

defaultconfig {applicationid  "xxx.xxx . xxx " minsdkversion 9  targetsdkversion 23<        /span> versioncode 1  versionname  "1.0"  Signingconfig Signingconfigs.release} buildtypes {release {minifyenabled false  proguardfiles getdefaultproguardfile ( ' proguard-android.txt ' ),  ' Proguard-rules.pro '  debuggable true  Signingconfig signingconfigs.release} debug  {Signi Ngconfig Signingconfigs.release}}  

OK, test, debug mode through, OK. Basically complete the sharing function, which is why? Signingconfig Signingconfigs.release is equivalent to renaming the APK and using a formal signature under Debug. is not a bit counter switch taste AH.

Summary: The key to integrating a third party is careful, the process is not difficult, but often the details determine success or failure.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Studio config debug under debug using formal signature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.