Project Configuration & Description
Add usage rights to AndroidManifest.xml
To ensure the normal operation of the program, you need to add the corresponding usage rights in the configuration file AndroidManifest.xml, such as network location service, mobile connection status, storage status, etc. The code is as follows:
<!-- Allow programs to open network sockets --> <uses-permission android:name="android.permission.INTERNET" />
Add Android version support in AndroidManifest
Based on SDK development, Android2.3 and above are required. You need to make the following settings in AndroidManifest.xml, for example
<user-sdk android:minSdkVersion="9"/>
Add SDK related JAR package
1. Add a JAR package
Click File in the menu and select File>Project Structure... to bring up the Project Structure dialog box.
In the Project Structure dialog, do the following:
(1) Check the "app" tab.
(2) Select the Dependencies tab under the app.
(3) Click the green “+” button on the right to select the jar. Select the required jar package, corresponding to the jar package in the jar folder of the SDK product.
(4) After the addition is successful, the corresponding jar file will appear in the Libraries list.
(5) Click "OK" to complete the addition of the JARs file.
The addition is successful, you can see the referenced jar package in the directory.
Add SDK third-party support library
SDK requires third-party okhttp3 library support, you need to add relevant support in the build.gradle file under the project module (if you have added it can be ignored). Related configuration is as follows
dependencies { implementation("com.squareup.okhttp3:okhttp:3.12.0") }
Use AK
Using AK requires adding the jar and so related to the authorization to the project
In the Project Structure dialog, do the following:
1. Add AK configuration to AndroidManifest
AK is configured in AndroidManifestKey. The code example is as follows:
<application android:icon="@drawable/icon" android:label="@string/app_name" > <meta-data android:name="Navinfo_AK" Android:value="Please enter your user AK"/> …… <application>
2. Initialize the base library in the application
You can customize the Application when the application is initialized, initialize the authorization and pass in the AK. The sample code is as follows:
public class SDKApplication extends Application { @Override public void onCreate() { super.onCreate(); NavinfoApi.init(this); } }
Code confusion
Configure the following when generating apk for code obfuscation (if a warning is reported, a similar statement is added to the package that reported warning: -dontwarn package name)
-dontwarn okio.** -keep class okio.** { *; } -keep interface okio.** { *; } -dontwarn okhttp3.** -keep class okhttp3.** { *; } -keep interface okhttp3.** { *; } -keep class com.navinfo.lbs.** {*;}