Install the SDK Package
Installation steps
- Download the SDK compression package from the Official Website.
- Extract the jar package. This will produce three files: bos-android-sdk-1.0.X.jar, okhttp-3.x.x.jar, and okio-1.x.x.jar.
- Move the jar package to the lib (or libs) directory within your Android project.
-
Right-click on the Eclipse project, select "Properties -> Java Build Path -> Add JARs," and import the copied jar package.
Right-click the Android Studio project - Open Module Settings - Select Project Module - Dependencies-
+, selectFile dependency, and select the copied jar package in the lib (libs) directory to complete the import.Note: Starting from version 1.0.3, BOS android SDK will no longer use Apache HttpClient, but will use the more lightweight and efficient OKHttp. For details, refer to the official website:http://square.github.io/okhttp/
Configure permissions
Ensure that the necessary permissions are configured in your project's AndroidManifest.xml file, as the SDK will not work properly without them.
1<uses-permission android:name="android.permission.INTERNET"/>
2<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
3<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
4<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
5<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Configure Obfuscation Protocol
1-dontwarn com.baidubce.**
2-keep class com.baidubce.**{*;}
3-keep interface com.baidubce.**{*;}
SDK directory structure
1com.baidubce
2 ├── auth //BCE signature classes
3 ├── http //BCE HTTP communication classes
4 ├── internal // SDK internal classes
5 ├── model // BCE common model classes
6 ├── services
7 │ └── bos //BOS service-related classes
8 │ ├── model //Internal BOS models, such as Request or Response
9 │ ├── BosClient.class //BOS client entry class
10 │ └── BosClientConfiguration.class //Configuration for BOS-specific HttpClient
11 │ └── sts //STS service-related classes
12 │ └── model //Internal STS model
13 ├── util //BCE common utilities
14 ├── BceClientConfiguration.class // Configuration for BCE HttpClient
15 ├── BceClientException.class // BCE client exception class
16 ├── BceServiceException.class // Exception class after BCE server interaction
17 ├── ErrorCode.class // BCE common error codes
18 └── Region.class // Regions where BCE provides services
