无法添加Google Drive Drive.API,Google授权无法正常工作
问题描述:
我不知道哪里出错了,但是根据下面的链接并使用Google文档,我无处可去。无法添加Google Drive Drive.API,Google授权无法正常工作
https://www.numetriclabz.com/integrate-google-drive-in-android-tutorial/
这一段代码似乎不起作用(Drive.API无法识别):
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
我已经添加了API密钥和谷歌的服务版本的清单,但本网站不会让我发布。
这有什么奇怪的是,谷歌登录工作像一个魅力。
GoogleSignInOptions gso = new
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /*
OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
这让我非常困惑。在console.developers上,我启用了谷歌驱动器。在Gradle中,我导入了Google服务,因此不会专门导入Google Drive,但我不认为这是问题。不要犹豫,问我更多的问题或请求屏幕截图。 。
答
在你的Gradle模块,
对于摇篮3.0 +
dependencies {
implementation 'com.google.android.gms:play-services-drive:11.8.0'
}
对于摇篮低于3.0:
dependencies {
compile 'com.google.android.gms:play-services-drive:11.8.0'
}
之后,该库将准备。然后,用下面的语句导入它:
import com.google.android.gms.drive.Drive;
你试过这个..? http://stackoverflow.com/q/38132225/7012517 – Shobhit
我绝对尝试过这一点,因为它在我写的个人日志中,但现在看来似乎。谢谢。 – Nephilim