Access to the development process of Google drive

Access to the development process of Google drive

Start

At the beginning, Google drive was connected to the apk compiled with Android studio. Later, the apk compiled by the company in the system source code environment also needed to be connected to the apk, and a record was made for the two developments.

Key words

Google drive, Android studio, Android system source code, aar

Reference

Google driver development API: https://developers.google.com/drive/
Documentation: https://developers.google.com/drive/android/intro
official demo download address: https://github.com/googledrive/ android-demos
maven address: https://mvnrepository.com/artifact/com.google.android.gms
Android.mk reference aar: https://www.jianshu.com/p/63715928063b

step 1

Whether or Android studio compile Android source code compiler will need to sign a development platform Google acquired API, the URL is https://console.developers.google.com/
Insert picture description here
Click "credentials" - "Creating credentials" - "OAuth client ID"
Insert picture description here
fill Create after entering the correct information.

Step 2

  1. Compile using Android studio:

Add the reference package in build.gradle(app)

//google auth 验证
implementation 'com.google.android.gms:play-services-auth:11.6.0'
//google drive
implementation 'com.google.android.gms:play-services-drive:11.6.0'

Then refer to https://github.com/googledrive/android-demos official demo interface.

  1. Compile with source code: You
    need to download the corresponding aar package in maven (I tried to find it for a long time, I don’t know which one to use). You can refer to the External Libraries compiled by Android studio in the
    Insert picture description here
    red box. You need to go to maven by yourself ( URL: https://mvnrepository.com/artifact/com.google.android.gms) downloaded.
    Insert picture description here
    After downloading, put it in the libs folder of the apk that needs to be compiled in the system, and then write the Android.mk file
LOCAL_STATIC_JAVA_AAR_LIBRARIES := play-services-auth_aar \
                                   play-services-auth-api-phone_aar \
                                   play-services-auth-base_aar \
                                   play-services-base_aar \
                                   play-services-basement_aar \
                                   play-services-drive_aar \
                                   play-services-tasks_aar

LOCAL_AAPT_FLAGS := \
    --rename-manifest-package com.settings.istv811 \
    --auto-add-overlay \
    --extra-packages com.google.android.gms

include frameworks/opt/setupwizard/library/common-gingerbread.mk
include frameworks/base/packages/SettingsLib/common.mk
#include device/hisilicon/bigfish/appIst/CommonLib/Commonlib/cuslib/common.mk
include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := play-services-auth_aar:app/libs/play-services-auth-11.6.0.aar \
                                        play-services-auth-api-phone_aar:app/libs/play-services-auth-api-phone-11.6.0.aar \
                                        play-services-auth-api-phone-license_aar:app/libs/play-services-auth-api-phone-license-11.6.0.aar \
                                        play-services-auth-base_aar:app/libs/play-services-auth-base-11.6.0.aar \
                                        play-services-auth-base-license_aar:app/libs/play-services-auth-base-license-11.6.0.aar \
                                        play-services-base_aar:app/libs/play-services-base-11.6.0.aar \
                                        play-services-base-license_aar:app/libs/play-services-base-license-11.6.0.aar \
                                        play-services-basement_aar:app/libs/play-services-basement-11.6.0.aar \
                                        play-services-basement-license_aar:app/libs/play-services-basement-license-11.6.0.aar \
                                        play-services-drive_aar:app/libs/play-services-drive-11.6.0.aar \
                                        play-services-drive-license_aar:app/libs/play-services-drive-license-11.6.0.aar \
                                        play-services-tasks_aar:app/libs/play-services-tasks-11.6.0.aar \
                                        play-services-tasks-license_aar:app/libs/play-services-tasks-license-11.6.0.aar \


include $(BUILD_MULTI_PREBUILT)

Use LOCAL_STATIC_JAVA_LIBRARIES to import the jar to define a variable name.
Use LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES to set a reference path for the defined variable

These two correspond to the key code

Add in androidmianfest.xml (write specific numbers on xxx)

 <uses-sdk android:minSdkVersion='xxx' />
 <uses-sdk android:targetSdkVersion='xxx' />

Step 3

Next is to refer to the Google demo to use the interface to write your own code
Google drive interface demo: https://github.com/googledrive/android-demos

Guess you like

Origin blog.csdn.net/weixin_41820878/article/details/107346535
Recommended