將Android Studio從2.2.1更新至2.2.2已完全破壞我的項目,因爲我無法訪問與Google地圖相關的任何內容。我的項目在更新之前運行良好,但現在沒有任何效果。在Google地圖活動中製作全新的項目也不起作用,併爲我提供完全相同的崩潰報告和結果。更新Android Studio打破Google地圖
我試過的東西: - 更新我所有的SDK,特別是與Google相關的SDK。 - 生成一個新的谷歌API密鑰 - 從頭開始創建 一個全新的項目 - 改變SupportMapFragment到MapFragment
錯誤,當我嘗試運行我的項目,我的手機上的全新地圖項目我得到(同樣的錯誤(所有其他gmaps應用我的手機上,所以我不認爲這是個問題)):
Caused by: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
我的build.gradle(從頭開始新的項目):
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.simon.afinal"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.8.0'
testCompile 'junit:junit:4.12'
}
標準地圖活動:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
Gmaps XML版式文件:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.simon.afinal.MapsActivity"
tools:layout="@layout/activity_maps" />
所有幫助深表感謝!
給了我同樣的錯誤 –