嘗試使用google maps v2作爲this link建議的應用程序時,我介紹了獲取密鑰然後跟隨procedure導入Google Play服務的過程。但當我在我的項目中導入庫時,我發現R文件丟失。任何人都可以建議如何解決這個錯誤。在Android項目中導入Google-Play-Services會刪除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
它與您的清單文件有關,請嘗試掃描您的清單中已損壞的標記和錯誤的屬性。 – 2013-02-23 18:31:42
@hardcoded我已經發布了我的清單文件snipet你可以檢查它並讓我知道如果我缺少一些東西 – sankettt 2013-02-26 05:40:03
順便說一句,你運行你的應用程序,並得到這個logcat堆棧跟蹤?如果是這樣,那麼你的R班現在工作正常? – 2013-02-26 09:55:22