google maps - Cannot resolve symbol 'mapView' on android studio -
after tons of tries couldn't found how solve this. android won't resolve symbol 'mapview' on:
mmapview = (mapview) v.findviewbyid(r.id.mapview);
what i'm trying google maps work on emulator. know code working on pc, guess here there's else.. (a system issue or google maps api problem)
here's code. can help? thank you..
package com.example.matant.gpsportclient.controllers; import android.app.fragment; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import com.example.matant.gpsportclient.asyncresponse; import com.example.matant.gpsportclient.r; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapview; import com.google.android.gms.maps.mapsinitializer; import com.google.android.gms.maps.model.bitmapdescriptorfactory; import com.google.android.gms.maps.model.cameraposition; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.markeroptions; /** * created matant on 8/24/2015. */ public class googlemapfragmentcontroller extends fragment implements asyncresponse { mapview mmapview; private googlemap googlemap; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflat , return layout view v = inflater.inflate(r.layout.fragment_google_map_fragment_controller, container, false); mmapview = (mapview) v.findviewbyid(r.id.mapview); mmapview.oncreate(savedinstancestate); mmapview.onresume();// display map try { mapsinitializer.initialize(getactivity().getapplicationcontext()); } catch (exception e) { e.printstacktrace(); } googlemap = mmapview.getmap(); // latitude , longitude double latitude = 17.385044; double longitude = 78.486671; // create marker markeroptions marker = new markeroptions().position( new latlng(latitude, longitude)).title("hello maps"); // changing marker icon marker.icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_rose)); // adding marker googlemap.addmarker(marker); cameraposition cameraposition = new cameraposition.builder() .target(new latlng(17.385044, 78.486671)).zoom(12).build(); googlemap.animatecamera(cameraupdatefactory .newcameraposition(cameraposition)); googlemap.getuisettings().setzoomcontrolsenabled(true); // perform camera updates here return v; } @override public void onresume() { super.onresume(); mmapview.onresume(); } @override public void onpause() { super.onpause(); mmapview.onpause(); } @override public void ondestroy() { super.ondestroy(); mmapview.ondestroy(); } @override public void onlowmemory() { super.onlowmemory(); mmapview.onlowmemory(); } @override public void handleresponse(string resstr) { } @override public void senddatatodbcontroller() { } @override public void preprocess() { } }
manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.matant.gpsportclient" android:versioncode="1" android:versionname="1.0" > <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-sdk android:minsdkversion="17" android:targetsdkversion="17" /> <permission android:name="com.example.matant.gpsportclient.permission.maps_receive" android:protectionlevel="signature" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.manage_documents" /> <uses-permission android:name="android.permission.read_external_storage" /> <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" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="com.example.matant.gpsportclient.permission.maps_receive" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".splashscreen" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".controllers.forgotpassword" android:label="@string/app_name" > </activity> <activity android:name=".controllers.login" android:label="@string/title_activity_login" > </activity> <activity android:name=".controllers.signup" android:label="@string/title_activity_sign_up" > </activity> <activity android:name=".mainscreen" android:label="@string/title_activity_main_screen" > </activity> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="@string/google_maps_key" /> </application> </manifest>
build.gradle:
apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "23.0.0 " defaultconfig { applicationid "com.example.matant.gpsportclient" minsdkversion 23 targetsdkversion 22 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } productflavors { } } dependencies { compile files('c:/users/adi/androidstudioprojects/gpsportclient/libs/additionnal.jar') compile files('c:/users/adi/androidstudioprojects/gpsportclient/libs/mail.jar') compile files('c:/users/adi/androidstudioprojects/gpsportclient/libs/activation.jar') compile filetree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.google.android.gms:play-services-maps:7.8.0' }
layout:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.mapfragment" /> </relativelayout>
replace
mmapview = (mapview) v.findviewbyid(r.id.mapview);
with
mmapview = (mapview) v.findviewbyid(r.id.map);
as id of fragment map
. see xml
<fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.mapfragment" />
Comments
Post a Comment