我已阅读此source 。但是当我在我的android工作室上添加一个库时,我遇到了以下错误。
与依赖的冲突&com.google.code.findbugs:jsr305'在项目':app'
之后我读了这个article 并使用gradle如下。
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.test.test"
minSdkVersion 21
targetSdkVersion 21
versionCode 4
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.android.gms:play-services-drive:11.8.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:26.1.0'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
}
MainActivity.java
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(Drive.SCOPE_FILE)
.requestScopes(Drive.SCOPE_APPFOLDER)
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
GoogleSignInAccount lastSignedInAccount = GoogleSignIn.getLastSignedInAccount(this);
mDriveClient = Drive.getDriveClient(this, lastSignedInAccount);
mDriveResourceClient =
Drive.getDriveResourceClient(this, lastSignedInAccount);
SortOrder sortOrder = new SortOrder.Builder().addSortAscending(SortableField.TITLE).build();
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, "test.txt"))
.build();
//Drive.DriveApi.fetchDriveId(mGoogleApiClient)
Task<MetadataBuffer> queryTask = mDriveResourceClient.query(query);
queryTask
.addOnSuccessListener(this,
new OnSuccessListener<MetadataBuffer>() {
@Override
public void onSuccess(MetadataBuffer metadataBuffer) {
Log.d("Count file" +metadataBuffer.getCount());
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
但我在项目中找不到 GoogleAccountCredential
功能。
任何指针都将受到赞赏。
答案 0 :(得分:0)
添加&#34;申请插件:&#39; com.google.gms.google-services&#39; &#34; build.gradle文件底部的行。
答案 1 :(得分:0)
Try replacing your dependency with this on.
compile 'com.google.api-client:google-api-client-android:1.20.0'
This might work but not sure.
答案 2 :(得分:0)
实现'com.google.android.gms:play-services-drive:15.0.1'
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, namasteId+"_database.zip"))
.build();
Drive.getDriveResourceClient(context, googleSignInAccount).query(query)
.addOnSuccessListener(new OnSuccessListener<MetadataBuffer>() {
@Override
public void onSuccess(MetadataBuffer metadata) {
try{
Drive.getDriveResourceClient(context, googleSignInAccount);
DriveFile backupfolder = metadata.get(0).getDriveId().asDriveFile();
retrieveContents(backupfolder);
}catch (Exception e){
Toast.makeText(activity, "No Data Found", Toast.LENGTH_SHORT).show();
activity.finish();
progressDialog.cancel();
}
}
})
// if no backup folder is found, create a new backup folder
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
createBackupFolder(context, googleSignInAccount);
}
});
如果您需要文件选择活动,则可以使用此注释代码
pickFile()
.addOnSuccessListener(activity,
driveId -> retrieveContents(driveId.asDriveFile()))
.addOnFailureListener(activity, e -> {
Log.e(TAG, "No file selected", e);
});