收到错误java.lang.NoClassDefFoundError的:com.google.android.gms.common.GooglePlayServicesUtil

收到错误java.lang.NoClassDefFoundError的:com.google.android.gms.common.GooglePlayServicesUtil

问题描述:

我知道it'a已经有很多的问题是这样的,我读了所有的人,反正不能找到解决办法。我做了什么:

I know it'a already many questions was like this, I read all of them, and can't find solution anyway. What i did:

我没有这一切几步 http://developer.android罚款.COM /谷歌/播放服务/ setup.html#安装安装谷歌玩SDK
在Android的标签我的项目属性我有谷歌发挥服务库好了,用Java构建路径:Android的私家藏书我有谷歌,播放service.jar中,而这个库被选中。我做了导入库项目也。

I did all this steps fine from http://developer.android.com/google/play-services/setup.html#Install to install google play sdk In my project property in Android tab I have "google play service library" ok, in Java Builder Path: "Android Private Libraries" i have google-play-service.jar, and this library are selected. I did Import lib project also.

code测试我从 http://developer.android.com了/google/gcm/client.html
我的清单文件:
    
    

Code for testing i took from http://developer.android.com/google/gcm/client.html. My manifest file:

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.intent.RECEIVE" />

<permission
    android:name="lt.vaziouju.vaziuoju.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="lt.vaziouju.vaziuoju.permission.C2D_MESSAGE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="api key here" />

    <receiver
        android:name="lt.vaziouju.vaziuoju.GcmBroadcastReceiver"
        android:permission="lt.vaziouju.vaziuoju.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="lt.vaziouju.vaziuoju.c2dm.intent.RECEIVE" />

            <category android:name="lt.vaziouju.vaziuoju" />
        </intent-filter>
    </receiver>

    <service android:name="lt.vaziouju.vaziuoju.GcmIntentService" />

    <activity
        ...
    </activity>
</application>

我的Java code:
包lt.vaziouju.vaziuoju;

My java code: package lt.vaziouju.vaziuoju;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;


public class Test_GCM extends Activity {

private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private static final String TAG = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test__gcm);

    TextView mDisplay = (TextView) findViewById(R.id.display);

    Context context = getApplicationContext();

    // Check device for Play Services APK.
    if (checkPlayServices()) {
        // If this check succeeds, proceed with normal processing.
        // Otherwise, prompt user to get valid Play Services APK.
    }
}

// You need to do the Play Services APK check here too.
@Override
protected void onResume() {
    super.onResume();
    checkPlayServices();
}

/**
 * Check the device to make sure it has the Google Play Services APK. If
 * it doesn't, display a dialog that allows users to download the APK from
 * the Google Play Store or enable it in the device's system settings.
 */


private boolean checkPlayServices() {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
            Log.i(TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.test__gcm, menu);
    return true;
}

}

如果您有任何想法,我怎么能,这将是炉排。我知道我不够好于机器人编程,刚开始学习GCM,但我已经花6小时来阅读一个谷歌,并没有什么。

If you have any idea how I can it, it will be grate. I know I'm not good enough in android programming, and just started learning GCM but I'm already spend 6h to reading a google, and nothing.

感谢您的任何想法。

您使用Eclipse?如果看到的Eclipse编译一个jar文件,它不一定包含到APK。 (您不得不提到的jar在几个地方,通常人们不多少地方记不清了。)

Are you using Eclipse? If Eclipse sees a jar file for compilation, it does not necessarily include it into the apk. (You have to mention the jar in several places, and usually people do not remember in how many places.)

ritht单击 - 构建路径 - 配置构建路径 - 订单和出口

ritht-click on the project name -- build path -- configure build path -- order and export.

同样的对话框中有一个项目选项卡,这是,您可以指定取决于项目。

The same dialog has a Projects tab, this is where you specify projects you depend on.

如果不工作,把罐子到项目的库子目录。

If that does not work, put the jar into the libs subdirectory of your project.