1.I will explain how to use the three-party SDK smart deployment tool by implementing the Twitter login SDK
The first is to post Twitter related documents and native examples

Development document address

https://dev.twitter.com/twitterkit/overview

How to use Android SDK

https://dev.twitter.com/twitterkit/android/installation

Sample download address:

https://github.com/twitter

https://github.com/twitter/twitter-kit-android

 

2.Download the Android SDK for Twitter

Mainly twitter-core.aar

Others are dependent packages

 

 

3.Download the three-party SDK smart deployment tool
Compiled:

http://www.orangeui.cn/download/sdk/OrangeSDK_SmartDeploy.zip

Or download the source code and compile it yourself:

https://github.com/DelphiTeacher/OrangeFreeSDK

The interface of the three-party SDK smart deployment tool is as follows:

 

 

 

4.First click the “Select Project” button to select the project to be configured

 

 

5.Then click the “Add Android Jar” button to add all jars, and then click “Process Android Jar”
Click the “Add Android Aar” button, add the desired aar, and then click “Process Android Aar”

Jar and aar have been added to the project

The Aar package is also decompressed, and the resources in it are deployed to the project

 

 

6.Next, translate the jar into a Delphi calling unit, call it in the form, first create a Twitter button and display it on the form

Button“Create Login Button”

Button “Get user info”

 

 

 

7.Then run to the real machine to check the effect, click “Create Login Button”, an exception will pop up,

Screenshot_2021-02-21-22-00-01-960_com.embarcader

Because the aar package needs to access the resources in its own package, we need to generate the R.java of the aar package and package it into a jar to add to the project.

You need to click the “Generate R.jar” button

It will generate R.jar and add it to the project

 

 

8.Compile and run to the real machine to see the effect

Screenshot_2021-02-21-22-24-09-586_com.embarcader

Screenshot_2021-02-21-22-24-15-358_com.twitter.an

Screenshot_2021-02-21-22-24-25-282_com.embarcader

 

 

9.If the resource file deployment of the project has been changed, you need to click the “Generate R.jar” button again. If you find this troublesome, you can use OrangeSDKHelper.exe to automatically handle it.
Configure Post-build events in the project as:

“C:\OrangeFreeSDK\OrangeSDKSmartDeployment\Win32\Debug\OrangeSDKHelper.exe” $(PROJECTPATH)

After each compilation, you can view related information in the Output page

  1. 我会以实现推特登陆SDK来讲解如何使用三方SDK智能布署工具
  2. 首先是贴出推特相关文档和原生示例

开发文档地址

https://dev.twitter.com/twitterkit/overview

如何使用Android的SDK

https://dev.twitter.com/twitterkit/android/installation

示例下载地址:

https://github.com/twitter

https://github.com/twitter/twitter-kit-android

  1. 下载推特的Android SDK

主要是twitter-core.aar

其他是依赖包

  1. 再下载三方SDK智能布署工具

编译好的:

http://www.orangeui.cn/download/sdk/OrangeSDK_SmartDeploy.zip

或者直接下载源码地址自己编译:

https://github.com/DelphiTeacher/OrangeFreeSDK

三方SDK智能布署工具的界面如下:

  1. 先点击“Select Project”按钮来选择要配置的工程

  1. 再点击”Add Android Jar”按钮,添加所有的jar,再点击”Process Android Jar”

点击”Add Android Aar”按钮,添加所要的aar,再点击“Process Android Aar”

Jar和aar都已经添加到工程中去了

Aar包也解压出来了,其中的资源也布署到工程中去了

  1. 接下来将jar翻译成Delphi的调用单元,在窗体中进行调用,先创建推特按钮,显示在窗体上

Button“Create Login Button”

Button “Get user info”

  1. 接下来运行到真机上查看效果,点击“Create Login Button”,会弹出一个异常,

Screenshot_2021-02-21-22-00-01-960_com.embarcader

因为aar包需要访问自己包中的资源,因此我们需要生成该aar包的R.java,并打包成jar添加到工程中去。

您需要点击“Generate R.jar”按钮

它会生成R.jar并添加到工程中去

  1. 再编译并运行到真机查看效果

Screenshot_2021-02-21-22-24-09-586_com.embarcader

Screenshot_2021-02-21-22-24-15-358_com.twitter.an

Screenshot_2021-02-21-22-24-25-282_com.embarcader

  1. 如果工程的资源文件布署被改动过之后,需要重新点击“Generate R.jar”按钮,如果你嫌这个麻烦,那么可以使用OrangeSDKHelper.exe来自动处理

在工程中配置Post-build events为:

“C:\OrangeFreeSDK\OrangeSDKSmartDeployment\Win32\Debug\OrangeSDKHelper.exe” $(PROJECTPATH)

每次编译后,你都能在Output页中查看相关的信息

Getting Started

新建Android工程,

包名为com.ggggcexx.orangeui

配置Gradle

dependencies {

compile ‘com.twitter.sdk.android:twitter-core:3.1.1’

compile ‘com.twitter.sdk.android:tweet-ui:3.1.1’

compile ‘com.twitter.sdk.android:tweet-composer:3.1.1’

compile ‘com.twitter.sdk.android:twitter-mopub:3.1.1’

}

初始方式一:

在values.xml中添加:

<resources>

<string android:name=”com.twitter.sdk.android.CONSUMER_KEY”>XXXXXXXXXXX</string>

<string android:name=”com.twitter.sdk.android.CONSUMER_SECRET”>XXXXXXXXXXX</string>

</resources>

在Application创建时添加:

public class CustomApplication {

public void onCreate() {

Twitter.initialize(this);

}

}

初始方式二:

public void onCreate() {

TwitterConfig config = new TwitterConfig.Builder(this)

.logger(new DefaultLogger(Log.DEBUG))

.twitterAuthConfig(new TwitterAuthConfig(“CONSUMER_KEY”, “CONSUMER_SECRET”))

.debug(true)

.build();

Twitter.initialize(config);

}

用推特登陆: Log In with Twitter:

https://dev.twitter.com/twitterkit/android/log-in-with-twitter

登陆方式一: Log In Button

import com.twitter.sdk.android.core.Callback;

import com.twitter.sdk.android.core.Result;

import com.twitter.sdk.android.core.TwitterException;

import com.twitter.sdk.android.core.TwitterSession;

import com.twitter.sdk.android.core.identity.TwitterLoginButton;

loginButton = (TwitterLoginButton) findViewById(R.id.login_button);

loginButton.setCallback(new Callback<TwitterSession>() {

@Override

public void success(Result<TwitterSession> result) {

// Do something with result, which provides a TwitterSession for making API calls

}

@Override

public void failure(TwitterException exception) {

// Do something on failure

}

});

获取到登陆后的Token:

TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();

TwitterAuthToken authToken = session.getAuthToken();

String token = authToken.token;

String secret = authToken.secret;

请求获取用户的邮箱地址:Request User Email Address

Before using this feature, ensure that “Request email addresses from users” is checked for your Twitter app.

TwitterAuthClient authClient = new TwitterAuthClient();

authClient.requestEmail(session, new Callback<String>() {

@Override

public void success(Result<String> result) {

// Do something with the result, which provides the email address

}

@Override

public void failure(TwitterException exception) {

// Do something on failure

}

});

The function introduction of the three-party SDK smart deployment tool (supports both Chinese and English)

 

Because I often need to dock some third-party SDKs in the process of developing APP, in order to improve work efficiency, I developed this third-party SDK smart deployment tool.

Currently open source:https://github.com/DelphiTeacher/OrangeFreeSDK/tree/master/OrangeSDKSmartDeployment

 

1.Deploying documents is more convenient

  • Can deploy folders directly, instead of selecting the subfolders and files one by one.

For example, the Android Three-Party SDK for multi-select pictures I use has a res folder in it, and all sub-files in this folder must be deployed.

This tool can simply add the res folder to the deployment item,

Then click the “Preview” button to list all the files that need to be deployed

Select the project to be deployed, and then click “Process” to complete the deployment.

Look, the files in the res folder have been deployed, and they have been deployed to both Android and Android64 platforms at the same time.

    • When deploying files, you can directly select the commonly used remote directory RemotePath.

Such as StartUp\Documents\、.\assets\internal\、library\lib\armeabi-v7a\

 

 

 

2.Able to directly configure the permissions required by the SDK and Android components (such as activity, service, receiver, provider, etc.) to the project’s AndroidManifest.template.xml

  • Enter the Android permission list in the “Android permissions” memo, and enter the required Android components in the “Android components” memo

Click the “Process Permissions” and “Process Components” buttons on the right to configure them in the project

We can open the AndroidManifest.template.xml under the project directory to check:

 

3.Ability to directly add the JAR required by the SDK to the project.

Click “Add Android Jar”, select the Jar file you need to add,

Click the “Process Android Jar” button on the right to configure Jar to the project.

Let’s expand the Android->Libraries node of the project to check:

 

4.Aar package that can automatically configure Android easily

Click the “Add Android Aar” button to add the aar package,

Then click the “Process Android Aar” button on the right to configure aar into the project

 

Aar is a zip compressed package, which contains jar, resource files, so dynamic library, AndroidManifest.xml configuration, etc. My tool can decompress the aar compressed package, and configure the jar and res resource files in the project into the project, but AndroidManifest The configuration in .xml needs to be configured manually.

 

For example, the mediaselector-release.aar in the example, after clicking the “Process Android Aar” button, it will be decompressed to folder mediaselector-release_aar,

The content in it is as follows:

The tool will automatically configure this jar into the project,

The tool will also automatically deploy the res directory to the project,

But the permissions and Android components in AndroidManifest.xml in the aar package need to be manually configured to AndroidManifest.template.xml in the project directory

Another very important button is “Generate R.jar”.

Because aar needs to access the resource file according to the ID, otherwise an error will be reported, so this button is used to generate the ID of the resource file and package it into a jar. It is generated in the OrangeSDK_JarGen directory in the project directory. You need to manually add the jar Go to the project.

 

5.Can directly configure IOS link parameters for the project Options passed to the LD linker

If some third-party IOS SDKs need to configure link parameters, then enter them in the “Linker Options” on the “IOS Framework” page, and click the “Process IOS Linker Options” on the right to directly configure them in the project.

 

6.Can directly add commonly used Frameworks to the IOS SDK, such as SystemConfiguration, CoreTelephony, etc.

  • “Add Frameworks below to All iPhone SDKS” button. After clicking this button, the frameworks in the list box will be added to Delphi’s IOS SDK, because adding one by one is too time-consuming. After clicking this, you need to restart the IDE and click “Update Local File Cache” in the SDK Manager to complete the configuration.
  • “Add Dylibs below to All iPhone SDKs”按钮,这个功能和上面这个功能类似。

 

 

7.Set project icon and launch screen

As long as you select an icon, you can generate icons of various sizes, and you can set them all at once, no need to select one by one.

 

8.All configuration items can be saved to the configuration file, which is convenient for direct use next time.

 

 

三方SDK智能布署工具的功能介绍(支持中英文)

因为我在开发APP的过程中经常需要对接一些三方的SDK,为了提升工作的效率,我开发了这个三方SDK智能布署工具。

  1. 布署文件更加方便
    1. 能直接布署文件夹,而不用一个个选择里面的子文件夹和文件。

比如我使用的多选图片的Android三方SDK,它里面有一个res文件夹,这个文件夹里面的所有子文件都要布署。

这个工具可以简单的将res文件夹添加到部署项中,

之后点击“Preview”按钮即可列出需要布署的所有文件

选择要布署到的工程,再点击“Process”即可完成布署。

你们看,res文件夹中的文件布署进去了,并且同时布署到了Android和Android64这两个平台。

    1. 布署文件时可以直接选择常用的远程目录RemotePath。

比如StartUp\Documents\、.\assets\internal\、library\lib\armeabi-v7a\等。

  1. 能够直接将SDK所需的权限和Android元件(比如activity、service、receiver、provider等)配置到工程的AndroidManifest.template.xml。
    1. 在安卓权限框中输入安卓权限列表,在安卓组件框中输入需要的安卓组件

点击右边的布署按钮,即可配置到工程中

我们可以打开工程目录下面的AndroidManifest.template.xml查看一下:

  1. 能够直接将SDK所需的JAR添加到工程。

点击“Add Android Jar”,选择所需要添加的Jar文件,

点击右边的“Process Android Jar”按钮,即可将Jar配置到工程中去。

我们展开工程的Android->Libraries节点检查一下:

  1. 能够简单的自动配置Android的Aar包

点击“Add Android Aar”按钮来添加aar包,

再点击右边的“Process Android Aar”按钮来将aar配置到工程中

Aar是一个zip压缩包,里面包含jar、资源文件、so动态库、AndroidManifest.xml的配置等,我这个工具可以解压aar压缩包,把jar和里面的res资源文件配置到工程中去,但是AndroidManifest.xml中的配置需要手动配置。

比如示例中的这个mediaselector-release.aar,点击了“Process Android Aar”按钮之后,会将它解压到mediaselector-release_aar,

它里面的内容如下:

工具会自动将这个jar配置到工程中,

工具还会自动将res目录布署到工程中,

但是aar包中的AndroidManifest.xml中的权限和Android元件需要手动配置到工程目录中的AndroidManifest.template.xml中

另外一个很重要的按钮是“Generate R.jar”。

因为aar中需要根据ID来访问资源文件,否则会报错,因此这个按钮就是用于生成资源文件的ID,并且打包到成jar,它生成在工程目录中的OrangeSDK_JarGen目录,您需要手动将该jar添加到工程中去。

  1. 能够直接给工程配置IOS的链接参数Options passed to the LD linker

如果一些三方IOS SDK需要配置链接参数,那么就在“IOS Framework”页面中的”Linker Options”中输入好,点击右边的“Process IOS Linker Options”即可直接配置到工程中去。

  1. 能够直接给IOS SDK添加常用的Framework,比如SystemConfiguration、CoreTelephony等。

    1. “Add Frameworks below to All iPhone SDKS”按钮,点击了这个按钮之后,会将列表框中的framework添加到Delphi的IOS SDK中,因为一个个添加太费时间了。点击了这个之后,需要重启IDE,并且在SDK Manager中点击“Update Local File Cache”才算配置完。
    2. “Add Dylibs below to All iPhone SDKs”按钮,这个功能和上面这个功能类似。
  1. 设置工程图标和启动图片

只要选好一个图标即可生成各种尺寸的图标,并且一次性全部设置完毕,不用再一个个去选了。

  1. 所有的配置项都能保存到配置文件中,方便下次直接使用。
  2. 选择工程文件,勾选所需要的SDK(支付宝支付),进行一次性配置,并且将该工程所需要的SDK保存起来,下次重建工程的时候,再次重新配置即可