java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式的机器人 [英] java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable in android

查看:218
本文介绍了java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android的显示谷歌地图V2的演示。

I tried a demo on displaying google maps v2 in android.

在Java code是,

The java code is,

package com.example.gpslocator;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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


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

在XML code是,

The Xml code is,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<fragment 
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>
</LinearLayout>

在manifest.xml的

我添加API密钥,

I added API key in manifest.xml,

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gpslocator"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="3"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
 The following two permissions are not required to use
 Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<permission
    android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.gpslocator.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="MY_API_KEY" />
</application>

</manifest>

当我试图运行我的应用程序突然关闭。当我调试,这表明我的错误,java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式。    我加入谷歌,播放services.jar文件,我的应用程序。

When I tried to run my Application closes of suddenly. When I debug, It showed me the error, "java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable". I added google-play-services.jar file to my application.

在logcat的是,

04-09 05:33:53.677: E/Trace(1053): error opening trace file: No such file or directory (2)
04-09 05:33:53.807: W/ActivityThread(1053): Application com.example.gpslocator is waiting for the debugger on port 8100...
04-09 05:33:53.878: I/System.out(1053): Sending WAIT chunk
04-09 05:33:54.207: I/dalvikvm(1053): Debugger is active
04-09 05:33:54.288: I/System.out(1053): Debugger has connected
04-09 05:33:54.288: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:54.487: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:54.697: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:54.897: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:55.097: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:55.297: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:55.498: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:55.708: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:55.907: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:56.167: I/System.out(1053): waiting for debugger to settle...
04-09 05:33:56.367: I/System.out(1053): debugger has settled (1344)
04-09 05:34:06.097: W/dalvikvm(1053): VFY: unable to resolve static field 867 (MapAttrs) in Lcom/google/android/gms/R$styleable;
04-09 05:34:06.097: D/dalvikvm(1053): VFY: replacing opcode 0x62 at 0x000e
04-09 05:40:21.278: D/AndroidRuntime(1053): Shutting down VM
04-09 05:40:21.278: W/dalvikvm(1053): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-09 05:40:21.398: E/AndroidRuntime(1053): FATAL EXCEPTION: main
04-09 05:40:21.398: E/AndroidRuntime(1053): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
04-09 05:40:21.398: E/AndroidRuntime(1053):     at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.Activity.onCreateView(Activity.java:4716)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.Activity.setContentView(Activity.java:1881)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at com.example.gpslocator.MainActivity.onCreate(MainActivity.java:12)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.Activity.performCreate(Activity.java:5104)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.os.Looper.loop(Looper.java:137)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at android.app.ActivityThread.main(ActivityThread.java:5041)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at java.lang.reflect.Method.invokeNative(Native Method)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at java.lang.reflect.Method.invoke(Method.java:511)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-09 05:40:21.398: E/AndroidRuntime(1053):     at dalvik.system.NativeStart.main(Native Method)
04-09 05:40:26.487: I/Process(1053): Sending signal. PID: 1053 SIG: 9

在属性 - > Android的 - >

In properties-->Android-->

请任何一个帮助我。我失去了任何参考?

Please any one help me out. Am I missing any reference?

推荐答案

在这里看到答案:
<一href="http://stackoverflow.com/questions/13733911/google-maps-android-api-v2-sample-$c$c-crashes">Google地图Android的API V2 - 样品code崩溃
虽然问题列出了不同的异常,回答特别提到您的具体问题。

See the answer here:
Google Maps Android API v2 - Sample Code crashes
While the question lists a different exception, the answer specifically mentions your exact problem.

具体而言,进口的重要谷歌播放services_lib 项目
选择文件&gt;进出口GT; Android的&GT;现有的Andr​​oid code进入工作区,然后单击下一步。
选择浏览...,进入<$c$c>[android-sdk-folder]/extras/google/google_play_services/libproject/google-play-services_lib,然后单击Finish。
(请参阅<一个href="https://developers.google.com/maps/documentation/android/intro">https://developers.google.com/maps/documentation/android/intro在示例code)
然后按照从链接答案的说明:

Specifically, it's important to import google-play-services_lib as a project:
Select File > Import > Android > Existing Android Code Into Workspace and click Next.
Select Browse..., enter [android-sdk-folder]/extras/google/google_play_services/libproject/google-play-services_lib, and click Finish.
(See https://developers.google.com/maps/documentation/android/intro under "Sample Code")
Then follow the instructions from the linked answer:

      
  • 导入为谷歌播放services_lib项目的实际来源,并将其链接为> 机器人库。   
        
    • 请通过此项目 - >属性 - > Android的 - >库,添加 - >谷歌播放services_lib(你可以右键点击你的项目,并选择属性,然后选择Android的)。
    •   
    • 不可以添加为通过Java构建路径为您的项目相关的项目,这并没有为我工作。
    •   
    • Import the actual source for the "google-play-services_lib" project and link it as an >Android library.
      • Do this through Project -> Properties -> Android -> Library, Add -> google-play-services_lib (you can right click on your project and choose Properties, then select Android).
      • Do not add it as a dependent Project through the "Java Build Path" for your project, that didn't work for me.

    这篇关于java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆