0

저는 Android가 처음이며 Google지도 활동이있는 Android 앱에서 작업하고 있습니다. 키 스토어로 앱에 서명하고 API 키를 생성했습니다. API 키를 앱에 삽입하고 Android 매니페스트에 키와 권한을 추가했습니다. API가 Google 개발 콘솔에서 활성화되어 있는지 확인했습니다. 로그 앵커에서 오류가 발생하지도 않고 앱이 다운되지도 않지만지도 활동을 시작할 때 화면에 위치가 표시되지 않습니다. 저는 개발과 테스트를 위해 Mac과 Samsung Grand Prime을 사용하고 있으며, 정기적 인 WiFI를 통해 연결되어 있습니다.Google지도 활동 빈 화면 표시

Here's지도 ​​활동 :

package de.die_web_agenten.www.batprice; 

import android.content.Context; 
import android.support.v4.app.FragmentActivity; 
import android.os.Bundle; 
import android.webkit.WebView; 
import android.widget.Toast; 
import com.google.android.gms.maps.CameraUpdateFactory; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.OnMapReadyCallback; 
import com.google.android.gms.maps.SupportMapFragment; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.MarkerOptions; 

public class MapsActivity extends FragmentActivity { 

    //private GoogleMap mMap; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.webview); 
     WebView myWebView = (WebView) findViewById(R.id.webview); 
     //myWebView.loadUrl("http://www.batprice.com"); 

     // 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); 

    } 




    /** 
    * Manipulates the map once available. 
    * This callback is triggered when the map is ready to be used. 
    * This is where we can add markers or lines, add listeners or move the camera. In this case, 
    * we just add a marker near Sydney, Australia. 
    * If Google Play services is not installed on the device, the user will be prompted to install 
    * it inside the SupportMapFragment. This method will only be triggered once the user has 
    * installed Google Play services and returned to the app. 
    */ 
    //@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)); 

    }*/ 
} 

Here's 안드로이드 매니페스트 :

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="de.die_web_agenten.www.batprice"> 

    <!-- To auto-complete the email text field in the login form with the user's emails --> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.READ_PROFILE" /> 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
    <uses-permission android:name="de.die_web_agenten.www.batprice.permission.MAPS_RECEIVE" /> 

    <permission 
     android:name="de.die_web_agenten.www.batprice.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 
    <!-- 
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use 
     Google Maps Android API v2, but you must specify either coarse or fine 
     location permissions for the 'MyLocation' functionality. 
    --> 
    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <meta-data 
      android:name="com.facebook.sdk.ApplicationId" 
      android:value="@string/facebook_app_id" /> 

     <activity 
      android:name=".SplashActivity" 
      android:label="@string/app_name" 
      android:theme="@style/SplashTheme"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".LoginActivity" 
      android:label="@string/app_name" /> 
     <activity 
      android:name="com.facebook.FacebookActivity" 
      android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" 
      android:label="@string/app_name" 
      android:theme="@android:style/Theme.Translucent.NoTitleBar" /> 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/title_activity_main" 
      android:theme="@style/AppTheme.NoActionBar" /> 

     <activity 
      android:name=".MapsActivity" 
      android:label="@string/title_activity_maps" /> 
     <!-- 
      The API key for Google Maps-based APIs is defined as a string resource. 
      (See the file "res/values/google_maps_api.xml"). 
      Note that the API key is linked to the encryption key used to sign the APK. 
      You need a different API key for each encryption key, including the release key that is used to 
      sign the APK for publishing. 
      You can define the keys for the debug and release targets in src/debug/ and src/release/. 
     --> 
     <meta-data 
      android:name="com.google.android.geo.API_KEY" 
      android:value="@string/google_maps_key" /> 
     /> 

     <meta-data 
      android:name="com.facebook.sdk.ApplicationId" 
      android:value="@string/facebook_app_id" /> 
     <meta-data 
      android:name="com.google.android.gms:play-services-maps:8.4.0" 
      android:value="MyAPIkey" /> 

     <activity 
      android:name=".ResultsActivity" 
      android:label="@string/title_activity_results" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name=".TrainingActivity" 
      android:label="@string/title_activity_training" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name=".SecondListActivity" 
      android:label="@string/title_activity_list" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name=".AndroidBarcodeQrExample" 
      android:label="@string/title_barcode_class" 
      android:theme="@style/AppTheme.NoActionBar" /> 

    </application> 

</manifest> 

Here's 레이아웃 파일 webview.xml :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <WebView android:id="@+id/webview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 

</LinearLayout> 

무엇 내가 여기에 누락되었거나 잘못하고 있습니까? 모든 힌트와 도움을 주시면 대단히 감사하겠습니다.

+1

활동에 바인딩중인 레이아웃을 친절하게 확인하십시오. 당신에 따르면 그것은 당신이 뭔가 잘못하고있는 것처럼 보입니다. – dhuma1981

+0

@ dhuma1981 - 알았어, 고마워, - 액티비티가 사용하고있는 레이아웃 파일을 추가했다. 여기 뭐가 잘못 됐니? –

+1

왜 WebView를 사용하고 있습니까? Google지도를 Android에 통합하는 방법에 대한 Google의 답변은 – dhuma1981

답변

1

코드는 Google지도를 만들지 않으며 웹보기 전용입니다.

+0

입니다. 감사합니다. 지금까지 감사드립니다. 지침에 따라 게시물의 코드를 사용했지만 여전히 빈 화면이 있습니다. 모든 것이 잘 작동하고 오류는 없지만 여전히 위치는 표시되지 않습니다. 더 이상의 힌트? –

+0

Logcat 안에 메시지가 있습니까? 그것은 우리를 도울 것입니다. –

+0

@ Mahmoud Ibrahim - 힌트를 주셔서 감사합니다. 문제가 해결되었습니다. 현재 수정 된 Google API 키에 문제가 있습니다. –