一键登录

2.9.12+ 版本新增支持

需要拷贝的文件

需要引入工程的aar文件

路径 文件
SDK\libs elogin-1.2.0.1.aar
SDK\libs gtc-2.1.4.aar
SDK\libs gysdk-2.0.0.8.aar
SDK\libs oauth-univerify-release.aar

需要修改的配置选项

需要在build.gradle 中 defaultConfig 节点下的 manifestPlaceholders 新增配置选项

  1. "GETUI_APPID" : "%GETUI_APPID%",
  2. "GY_APP_ID" : "%GY_APP_ID%",
  3. "GT_INSTALL_CHANNEL":"HBuilder",
  4. GT_INSTALL_CHANNEL 固定值 "HBuilder"

GETUI_APPID与GY_APP_ID对应开发者中心一键登录->基础配置->一键登录应用ID(离线打包使用),GETUI_APPID与GY_APP_ID取值相同。

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在assets/data目录下

  1. <feature name="OAuth" value="io.dcloud.feature.oauth.OAuthFeatureImpl"><module name="OAuth-IGETui" value="io.dcloud.feature.igetui.GeTuiOAuthService"/></feature>

应用中使用一键登录功能请参考 一键登录 使用指南

微信登录

需要拷贝的文件

需要引入工程的jar文件

需要将以下jar文件放到工程的libs目录下

路径 文件
SDK\libs oauth-weixin-release.aar,wechat-sdk-android-without-mta-6.7.9.aar

需要将WXEntryActivity.java代码文件引入到工程

注意:文件位于离线sdk的/SDK/src/wxapi下,可直接拷贝并将文件内的包名替换成自己的包名。

路径 文件
%应用包名%\wxapi WXEntryActivity.java

Androidmainfest.xml文件需要修改的项

需要在application节点前添加权限

  1. <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
  2. <application>节点下配置如下代码
  3. <meta-data android:value="%用户申请的微信Appcert%" android:name="WX_SECRET"/>
  4. <meta-data android:value="%用户申请的微信Appid%" android:name="WX_APPID"/>
  5. <activity android:name="%用户包名%.wxapi.WXEntryActivity"
  6. android:label="@string/app_name"
  7. android:exported="true"
  8. android:launchMode="singleTop">
  9. <intent-filter><action android:name="android.intent.action.VIEW"/>
  10. <category android:name="android.intent.category.DEFAULT"/>
  11. <data android:scheme="%用户申请的微信Appid%"/>
  12. </intent-filter>
  13. </activity>

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在assets/data目录下

  1. <feature name="OAuth" value="io.dcloud.feature.oauth.OAuthFeatureImpl"><module name="OAuth-Weixin" value="io.dcloud.feature.oauth.weixin.WeiXinOAuthService"/></feature>

QQ登录

需要拷贝的文件

需要引入工程的jar文件

需要将以下jar文件放到工程的libs目录下

路径 文件
SDK\libs oauth-qq-release.aar,qq_mta-sdk-1.6.2.jar,qq_open_sdk_3.5.2.152.jar

Androidmainfest.xml文件需要修改的项

需要在application节点前添加权限

  1. <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

节点下配置如下代码

  1. <!-- Oauth QQ start -->
  2. <meta-data android:value="%appid%" android:name="QQ_APPID"/>
  3. <activity android:name="com.tencent.tauth.AuthActivity" android:launchMode="singleTask" android:noHistory="true">
  4. <intent-filter>
  5. <action android:name="android.intent.action.VIEW"/>
  6. <category android:name="android.intent.category.DEFAULT"/>
  7. <category android:name="android.intent.category.BROWSABLE"/>
  8. <data android:scheme="%appid%"/>
  9. </intent-filter>
  10. </activity>
  11. <activity android:name="com.tencent.connect.common.AssistActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:screenOrientation="portrait"/>
  12. <!-- Oauth QQ end -->

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在assets/data目录下

  1. <feature name="OAuth" value="io.dcloud.feature.oauth.OAuthFeatureImpl"><module name="OAuth-QQ" value="io.dcloud.feature.oauth.qq.QQOAuthService"/></feature>

新浪微博登录

需要拷贝的文件

需要引入工程的aar文件

路径 文件
SDK\libs openDefault-4.4.1.aar,oauth-sina-release.aar

Androidmainfest.xml文件需要修改的项

节点下配置如下代码

  1. <!-- Oauth Sina start -->
  2. <meta-data android:value="%redirect_uri%" android:name="SINA_REDIRECT_URI"/>
  3. <meta-data android:value="_%appkey%" android:name="SINA_APPKEY"/>
  4. <activity android:name="com.sina.weibo.sdk.web.WeiboSdkWebActivity"
  5. android:configChanges="keyboardHidden|orientation"
  6. android:exported="false"
  7. android:windowSoftInputMode="adjustResize">
  8. </activity>
  9. <!-- Oauth Sina end -->

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在assets/data目录下

  1. <feature name="OAuth" value="io.dcloud.feature.oauth.OAuthFeatureImpl"><module name="OAuth-Sina" value="io.dcloud.feature.oauth.sina.SinaOAuthService"/></feature>

小米登录

需要拷贝的文件

需要将以下jar文件拷贝到工程中

路径 文件
SDK\libs oauth-miui-release.aar

Androidmainfest.xml文件需要修改的项

需要在application节点前添加权限

  1. <uses-permission android:name="com.xiaomi.permission.AUTH_SERVICE"/>

application节点下配置如下代码

  1. <meta-data android:value="_%小米登陆的APPID%" android:name="MIUI_APPID"/>
  2. <meta-data android:value="%小米登陆的APPSecret%" android:name="MIUI_APPSECRET"/>
  3. <meta-data android:value="%小米登陆的RegURL%" android:name="MIUI_REDIRECT_URI"/>
  4. <activity android:name="com.xiaomi.account.openauth.AuthorizeActivity"/>

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在ADT工程assets/data目录下

Features节点下添加

  1. <feature name="OAuth" value="io.dcloud.feature.oauth.OAuthFeatureImpl">
  2. <module name="OAuth-MiUi" value="io.dcloud.feature.oauth.miui.MiUiOAuthService"/>
  3. </feature>

Google登录Android离线打包

3.2.7+ 版本新增支持

需要拷贝的文件

需要引入工程的aar文件

路径 文件
SDK\libs oauth-google-release.aar

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在assets/data目录下

  1. <module name="OAuth-Google" value="io.dcloud.feature.google.GoogleOAuthService"/>

gradle配置

在project目录下build.gradle配置如下:

  1. buildscript {
  2. repositories {
  3. google()
  4. }
  5. dependencies {
  6. ...
  7. classpath 'com.google.gms:google-services:4.2.0'
  8. }
  9. }

在app目录下的build.gradle配置如下:

  1. dependencies {
  2. ...
  3. implementation 'com.google.android.gms:play-services-auth:19.2.0'
  4. }

Facebook登录Android离线打包

3.2.7+ 版本新增支持

需要拷贝的文件

需要引入工程的aar文件

路径 文件
SDK\libs oauth-facebook-release.aar

应用目录 res/values/strings.xml 需要添加如下资源

facebook_app_id 和 fb_login_protocol_scheme

下面是一个完整的示例

  1. <string name="facebook_app_id">1966893263469923</string>
  2. <string name="fb_login_protocol_scheme">fb1966893263469923</string>

dcloud_properties.xml需要添加如下代码

dcloud_properties.xml文件在assets/data目录下

  1. <module name="OAuth-Facebook" value="io.dcloud.feature.facebook.FacebookOAuthService"/>

gradle配置

在app目录下的build.gradle配置如下:

  1. dependencies {
  2. ...
  3. implementation 'com.facebook.android:facebook-login:4.42.0'
  4. }