因此,我正在开发一个android应用程序,我为google maps编写了代码,该代码一段时间后效果很好。但是,比起我连接Firebase,这给了我一些错误,这导致我不得不升级升级(以前我使用play-services-gcm:12.0.1)。现在,我正在研究以下依赖项:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.getdevicelocation"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.google.firebase:firebase-appindexing:10.0.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation 'com.google.firebase:firebase-core:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
我遇到以下错误。
error: package com.google.android.gms.maps does not exist
我知道这意味着在我提供的库中找不到该软件包。以下是我的mapsactivity.xml代码
package com.example.getdevicelocation;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
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.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
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;
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
// Add a marker in Sydney and move the camera
LatLng loc_1 = new LatLng(30.275285, 77.047580);
mMap.addMarker(new MarkerOptions().position(loc_1).title("Open Dumping site unattended since 2 months").
icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
mMap.moveCamera(CameraUpdateFactory .newLatLngZoom(loc_1, 12));
}
}
在较新的依赖项中是否有另一种访问Google地图的方法,我的代码有问题。
答案 0 :(得分:1)
bowStringLinerenderer = bowString.AddComponent<LineRenderer>();
bowStringLinerenderer.SetVertexCount(3);
bowStringLinerenderer.SetWidth(0.05F, 0.05F);
bowStringLinerenderer.useWorldSpace = false;
bowStringLinerenderer.material = Resources.Load ("Materials/bowStringMaterial") as Material;
bowStringPosition = new List<Vector3> ();
bowStringPosition.Add(new Vector3 (-0.44f, 1.43f, 2f));
bowStringPosition.Add(new Vector3 (-0.44f, -0.06f, 2f));
bowStringPosition.Add(new Vector3 (-0.43f, -1.32f, 2f));
bowStringLinerenderer.SetPosition (0, bowStringPosition [0]);
bowStringLinerenderer.SetPosition (1, bowStringPosition [1]);
bowStringLinerenderer.SetPosition (2, bowStringPosition [2]);
arrowStartX = 0.7f;
答案 1 :(得分:0)
错误:包com.google.android.gms.maps不存在
您应该添加
implementation "com.google.android.gms:play-services-maps:15.0.0" //16.0.0
然后 Clean-Rebuild-Run
。
仅供参考
您应该升级 firebase-appindexing
版本。
示例
implementation 'com.google.firebase:firebase-appindexing:16.0.2'