在尝试按照此链接的建议使用 google maps v2 进行应用程序时,我开始执行获取密钥的程序,然后按照导入 google play 服务的程序进行操作。但是当我在我的项目中导入库时,我发现 R 文件丢失了。谁能建议如何解决此错误。
编辑
代码和它的日志猫。
public class Maptest extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maplayout);
}
}
XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
然后是清单文件中给出的权限
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<permission
android:name="com.curioussolutions.autoistdiary.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.curioussolutions.autoistdiary.permission.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
02-20 10:30:16.093: E/AndroidRuntime(21076): FATAL EXCEPTION: main
02-20 10:30:16.093: E/AndroidRuntime(21076): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
02-20 10:30:16.093: E/AndroidRuntime(21076): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
02-20 10:30:16.093: E/AndroidRuntime(21076): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:271)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-20 10:30:16.093: E/AndroidRuntime(21076): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.Activity.setContentView(Activity.java:1657)
02-20 10:30:16.093: E/AndroidRuntime(21076): at com.curioussolutions.autoistdiary.MainActivity.onCreate(MainActivity.java:25)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.os.Looper.loop(Looper.java:130)
02-20 10:30:16.093: E/AndroidRuntime(21076): at android.app.ActivityThread.main(ActivityThread.java:3687)
02-20 10:30:16.093: E/AndroidRuntime(21076): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 10:30:16.093: E/AndroidRuntime(21076): at java.lang.reflect.Method.invoke(Method.java:507)
02-20 10:30:16.093: E/AndroidRuntime(21076): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
02-20 10:30:16.093: E/AndroidRuntime(21076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-20 10:30:16.093: E/AndroidRuntime(21076): at dalvik.system.NativeStart.main(Native Method)
02-20 10:30:17.500: W/jdwp(21076): Debugger is telling the VM to exit with code=1
02-20 10:30:17.500: I/dalvikvm(21076): GC lifetime allocation: 2194 bytes