2012-02-26 28 views
6

我想在我的應用程序中使用的地圖和我得到這個錯誤, 未能找到風格「mapViewStyle」在當前主題Android的地圖:無法找到風格「mapViewStyle」在當前主題

我已經生成了關鍵是正確的,並嘗試了在其他地方針對相同問題提供的所有解決方案。

1.my target api and the one mentioned in the manifest file are the same. 
2.There is no import.R in my project 
3.I have cleaned my project. 
4.Uses-library element is a child of the application. 

這是我的xml文件

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

    <com.google.android.maps.MapView 
     android:id="@+id/mapview1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clickable="true" 
     android:apiKey="*****************" 
     android:enabled="true" 
     /> 

</LinearLayout> 

,這是我的相應的Java文件

包com.epidemicator.prototype;

import android.os.Bundle; 
import com.google.android.maps.MapActivity; 

public class Mapacti extends MapActivity { 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mapview); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     // TODO Auto-generated method stub 
     return false; 
    } 
} 

請幫我在這裏... 謝謝。

+0

重複http://stackoverflow.com/questions/6975203/android-google-maps-failed-to-find-style-mapviewstyle-in-current-theme? – dmon 2012-02-26 19:13:29

+0

我同意dmon看到他/她引用的問題並查看文檔http://code.google.com/android/add-ons/google-apis/maps-overview.html#useslibrary – dbryson 2012-02-26 19:37:24

回答

6

我的答案可能是遲到的,但我希望它會處理實際的原因,並確信它可能對那些將來要搜索相同問題的人有所幫助。

這種類型的錯誤,從上面的列表

1. Android Google Maps Failed to find style 'mapViewStyle' in current theme 
2. Failed to find style 'imageButtonStyle' in current theme 
3. Failed to find style 'editTextStyle' in current theme 
4. Failed to find style 'textViewStyle' in current theme 

任何可能,

的根本原因是,

我們選擇了不可用Themelayout

這可能是因爲以下原因而發生,

  1. 選定theme不可用themes.xml文件。
  2. 所選theme屬於更高版本sdk,但我們當前的目標sdk是較低的一個。

此問題主要集中,

  1. 當你複製整個layout文件,並嘗試實施它在你的project。 a。您可能忘記複製themes.xml文件 b。你可能有更低的target sdk,原來的layout用更高的target sdk創建。

這個問題是解決方案,

打開查看layout文件中的Graphical Layout View,並期待在右上角。 有你themeslayout已選定。)

  1. 所以單擊下拉列表中選擇theme並選擇可用的themes根據項目themestargeted sdk themes(OR)
  2. 如果themecustom一個,如果你需要它,那麼themes.xml文件從其中複製layout xml文件的源複製到您的項目。 (OR)
  3. 如果themesdk無濟於事theme,如果你需要它,那麼你根據你選擇的themetarget改變。

希望 - 這可能對某人有幫助。

0

我想我會添加這個小珍聞。我得到了上面的錯誤#4。我花了很長時間才意識到,我爲我的Preferences所做的主題自動應用於我已經制作的每個佈局文件。如上所述選擇另一個解決了我的問題。我不知道爲什麼Android Studio會自動將它應用於所有其他佈局,但我希望它不會。

我仍然不知道爲什麼我製作的主題打破了一切,因爲它只是將backgroundColor應用於我的Preferences頁面,但希望有一天我會。

相關問題