简体   繁体   English

异常java.lang.NoClassDefFoundError:com.google.android.gms.common.AccountPicker

[英]Exception java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker

I'm trying the Quickstart: Run a Drive App on Android from Google Drive SDK. 我正在尝试快速入门:在 Google Drive SDK 上运行Android上的云端硬盘应用 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 我已经生成了证书

  • Enabled the API (with the certificate fingerprint) 启用API(带证书指纹)

  • Created and configurated the android project in Eclipse 在Eclipse中创建并配置了android项目

    • Added the APIs with the Google plugin 添加了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 此外,我还添加了应用程序的权限,甚至还有其他权限

I even added the Google Play Android Developer API and its perimssions. 我甚至添加了Google Play Android Developer API及其perimssions。

But when I run the App, it still crashes. 但是当我运行App时,它仍然会崩溃。 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). 我想知道它是否特定于Android APIv17,因为我的设备是APIv10和APIv15(我也添加了支持库)。

Please, help. 请帮忙。 And excuse me for my bad english. 请原谅我糟糕的英语。 Thank you. 谢谢。

I had the same issue with the jtwitter.jar library. 我在jtwitter.jar库中遇到了同样的问题。 If you're running Android Studio, you have to do a clean & build (which AS doesn't truly do right now). 如果您正在运行Android Studio,则必须进行清理和构建(AS现在并不是真正做到的)。

Go to your command line, navigate to your project root and execute ./gradlew clean 转到命令行,导航到项目根目录并执行./gradlew clean

BEFORE YOU DO THIS 在你做这件事之前

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 ). 确保将.jar文件添加到/libs文件夹中(如果您使用的是build 17或更高版本,则必须是libs ,而不是lib )。 Right-click and select Add as Library... 右键单击并选择“ 添加为库”...

Then you're going to have to edit your build.gradle file (located in your /src directory). 然后你将不得不编辑build.gradle文件(位于/src目录中)。

It should look something like this: 它应该看起来像这样:

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
    }
}

Change the dependencies block to look like this: dependencies块更改为如下所示:

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('[path/to/.jar]')
}

Then you can build and run your project. 然后,您可以构建和运行您的项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 收到错误java.lang.NoClassDefFoundError:com.google.android.gms.common.GooglePlayServicesUtil - getting error java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil java.lang.NoClassDefFoundError:com.google.android.gms.common.internal.zzbo - java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbo java.lang.NoClassDefFoundError:com.google.android.gms.gcm.GoogleCloudMessaging使用java.lang.NoClassDefFoundError: - java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging using java.lang.NoClassDefFoundError: Google AdMob java.lang.NoClassDefFoundError:com.google.android.gms.ads.AdView - Google AdMob java.lang.NoClassDefFoundError: com.google.android.gms.ads.AdView Android错误:java.lang.NoClassDefFoundError:com.google.android.gms.R $ string - Android error: java.lang.NoClassDefFoundError: com.google.android.gms.R$string java.lang.NoClassDefFoundError:无法解决以下问题:Lcom / google / android / gms / common / internal / zzbp; - java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbp; java.lang.NoClassDefFoundError:无法解决以下问题:Lcom / google / android / gms / common / internal / zzbq附近的地方应用 - java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq Nearby Place App Android Google Maps v2:java.lang.NoClassDefFoundError:com.google.android.gms.R $ styleable - Android Google Maps v2: java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 运行时错误:java.lang.NoClassDefFoundError:com.google.android.gms.R $ styleable - Run Time Error : java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable java.lang.noclassdeffounderror:com.google.android.gms.R $ styleable没什么帮助我的 - java.lang.noclassdeffounderror: com.google.android.gms.R$styleable nothing helped me
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM