我在链接中运行了几个单元测试:https://github.com/googlemaps/google-maps-services-java。我无法在com.google.maps.model包中找到DirectionsResult类。我附加了gradle依赖项快照和我从其中一个测试用例中使用的代码片段。请让我知道我哪里错了?谢谢!
测试用例摘录如下:
package com.google.maps;
import com.google.maps.DirectionsApi.RouteRestriction;
import com.google.maps.errors.NotFoundException;
import com.google.maps.model.AddressType;
import com.google.maps.model.DirectionsResult;
import com.google.maps.model.GeocodedWaypointStatus;
import com.google.maps.model.TrafficModel;
import com.google.maps.model.TransitMode;
import com.google.maps.model.TransitRoutingPreference;
import com.google.maps.model.TravelMode;
import com.google.maps.model.Unit;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@Category(LargeTests.class)
public class DirectionsApiTest extends AuthenticatedTest {
private GeoApiContext context;
public DirectionsApiTest(GeoApiContext context) {
this.context = context
.setQueryRateLimit(3)
.setConnectTimeout(1, TimeUnit.SECONDS)
.setReadTimeout(1, TimeUnit.SECONDS)
.setWriteTimeout(1, TimeUnit.SECONDS);
}
@Test
public void testGetDirections() throws Exception {
DirectionsResult result = DirectionsApi.getDirections(context, "Sydney, AU",
"Melbourne, AU").await();
assertNotNull(result.routes);
assertNotNull(result.routes[0]);
assertThat(result.routes[0].overviewPolyline.decodePath().size(), not(0));
assertEquals("Sydney NSW, Australia", result.routes[0].legs[0].startAddress);
assertEquals("Melbourne VIC, Australia", result.routes[0].legs[0].endAddress);
}
}
答案 0 :(得分:0)
错误是包中找不到类。我认为在从编译'com.google.maps:goo gle-maps-services:0.1.2'更改依赖关系后,编译'com.google.maps:goo gle-maps-services:0.1 0.12' 。我发现没有任何文档提到类包含的DirectionsResult已从com.google.maps.mode包中弃用l.DirectionsResult;