問題描述
我正在嘗試來自 Google Drive 的 快速入門:在 Android 上運行 Drive 應用開發工具包.我遵循了漏洞過程,但是當我在我的設備(真實設備)中運行該應用程序時,它會崩潰并出現以下異常:
I'm trying the Quickstart: Run a Drive App on Android from Google Drive SDK. I have followed the hole process, but when I ran the app in my devices (real ones), it crashes with the following exception:
java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
最后,它在這段代碼的第二行指向我的源代碼:
And finally, it points to my source in the second line of this code:
credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); // <- This one
我的困惑來自于我已經完成了文章指示我做的所有事情:
My confussion comes from the fact I have done everything the article instructs me to do:
我已生成證書
I have generated the certificate
啟用 API(使用證書指紋)
Enabled the API (with the certificate fingerprint)
在Eclipse中創建并配置android項目
Created and configurated the android project in Eclipse
- 添加了帶有 Google 插件的 API
復制了樣本(我實際上做了復制粘貼)
Copied the sample (I actually did copy-paste)
當然,我更正了包名和類名
Ofcourse, I corrected the package and class names
我還添加了應用程序的權限,甚至是其他與帳戶相關的權限
Also I added the permissions for the App, even other permissions reffering to acounts
我什至添加了 Google Play Android Developer API 及其權限.
I even added the Google Play Android Developer API and its perimssions.
但是當我運行應用程序時,它仍然崩潰.所有的圖書館似乎都很好.我想知道它是否特定于 Android APIv17,因為我的設備是 APIv10 和 APIv15(我也添加了支持庫).
But when I run the App, it still crashes. All the libraries seem to be fine. I wonder if it is specific to Android APIv17, since my devices are APIv10 and APIv15 (I added the support library also).
請幫忙.請原諒我的英語不好.謝謝.
Please, help. And excuse me for my bad english. Thank you.
推薦答案
我在 jtwitter.jar 庫中遇到了同樣的問題.如果你運行的是 Android Studio,你必須做一個干凈的 &構建(AS 目前還沒有真正做到這一點).
I had the same issue with the jtwitter.jar library. If you're running Android Studio, you have to do a clean & build (which AS doesn't truly do right now).
轉到您的命令行,導航到您的項目根目錄并執行 ./gradlew clean
Go to your command line, navigate to your project root and execute ./gradlew clean
在你這樣做之前
確保您的 .jar 文件已添加到您的 /libs
文件夾(如果您使用的是 build 17 或更高版本,它必須是 libs
,而不是 <代碼>庫).右鍵單擊并選擇添加為庫...
Ensure that your .jar file is added to your /libs
folder (if you're using build 17 or later, it has to be libs
, and not lib
). Right-click and select Add as Library...
然后您將不得不編輯您的 build.gradle 文件(位于您的 /src
目錄中).
Then you're going to have to edit your build.gradle file (located in your /src
directory).
它應該看起來像這樣:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 5
targetSdkVersion 16
}
}
將 dependencies
塊更改為如下所示:
Change the dependencies
block to look like this:
dependencies {
compile files('libs/android-support-v4.jar')
compile files('[path/to/.jar]')
}
然后您可以構建并運行您的項目.
Then you can build and run your project.
這篇關于異常 java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!