无法解析在Android工作室标志“机器人” [英] cannot resolve symbol 'android' on android studio
问题描述
我一直在显示图形页面的应用程序,它建立了,我甚至我用我的装置
现在,我想添加更功能,但突然间工作室是给错误无法解析符号'机器人'。...... !!!!
我更新工作室0.8.6(最新的)......但该死的.. !!没有什么变化。
错误:
包com.androidhive.googleplacesandmaps;进口的java.util.List;进口android.content.Intent;
进口android.graphics.drawable.Drawable;
进口android.os.Bundle;
进口android.util.Log;进口com.google.android.maps.GeoPoint;
进口com.google.android.maps.MapActivity;
进口com.google.android.maps.MapController;
进口com.google.android.maps.MapView;
进口com.google.android.maps.Overlay;
进口com.google.android.maps.OverlayItem;公共类PlacesMapActivity扩展MapActivity {
//最近的地方
PlacesList nearPlaces; //地图视图
MapView类MapView类; //地图覆盖项目
清单<&叠加GT; mapOverlays; AddItemizedOverlay itemizedOverlay; GeoPoint对象的GeoPoint;
//地图控制器
MapController MC; 双纬度;
双经度;
OverlayItem overlayitem; @覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.map_places); //获取数据的意图
意向I = getIntent(); //用户当前的地理位置
串user_latitude = i.getStringExtra(user_latitude);
串user_longitude = i.getStringExtra(user_longitude); // Nearplaces名单
nearPlaces =(PlacesList)i.getSerializableExtra(near_places); 图形页面=(图形页面)findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(真); mapOverlays =调用MapView.getOverlays(); // GeoPoint对象放置在地图上
的GeoPoint =新的GeoPoint((INT)(Double.parseDouble(user_latitude)* 1E6)
(中间体)(Double.parseDouble(user_longitude)* 1E6)); //可绘制标记图标
可绘制drawable_user = this.getResources()
.getDrawable(R.drawable.mark_red); itemizedOverlay =新AddItemizedOverlay(drawable_user,这一点); //地图覆盖项目
overlayitem =新OverlayItem(GeoPoint对象,您的位置
那是你!); itemizedOverlay.addOverlay(overlayitem); mapOverlays.add(itemizedOverlay);
itemizedOverlay.populateNow(); //可绘制标记图标
可绘制可绘制= this.getResources()
.getDrawable(R.drawable.mark_blue); itemizedOverlay =新AddItemizedOverlay(绘制,这一点); MC = mapView.getController(); //这些值用来获取地图边界区域
//在这里你可以看到屏幕上的所有标记区域
INT minLat = Integer.MAX_VALUE的;
INT闽龙= Integer.MAX_VALUE的;
INT maxLat = Integer.MIN_VALUE的;
INT MAXLONG = Integer.MIN_VALUE的; //检查空的情况下,空
如果(nearPlaces.results!= NULL){
//通过所有的地方环
对于(地点地点:nearPlaces.results){
纬度= place.geometry.location.lat; //纬度
经度= place.geometry.location.lng; //经度 // GeoPoint对象放置在地图上
的GeoPoint =新的GeoPoint((int)的(纬度* 1E6)
(中间体)(经度* 1E6)); //地图覆盖项目
overlayitem =新OverlayItem(GeoPoint对象,place.name,
place.vicinity); itemizedOverlay.addOverlay(overlayitem);
//计算地图边界区域
minLat =(int)的Math.min(geoPoint.getLatitudeE6(),minLat);
闽龙=(INT)Math.min(geoPoint.getLongitudeE6(),闽龙);
maxLat =(int)的Math.max(geoPoint.getLatitudeE6(),maxLat);
MAXLONG =(INT)Math.max(geoPoint.getLongitudeE6(),MAXLONG);
}
mapOverlays.add(itemizedOverlay); //显示所有物品叠加
itemizedOverlay.populateNow();
} //调节缩放比例,这样就可以看到地图上的所有标记
。mapView.getController()zoomToSpan(Math.abs(minLat - maxLat),Math.abs(闽龙 - MAXLONG)); //显示在地图的中心
mc.animateTo(新的GeoPoint((maxLat + minLat)/ 2,(MAXLONG +闽龙)/ 2));
mapView.postInvalidate(); } @覆盖
保护布尔isRouteDisplayed(){
返回false;
}}
的build.gradle文件:
buildscript {
库{
mavenCentral()
}
依赖{
编译com.google.android.gms:播放服务:5.0.77
类路径'com.android.tools.build:gradle:0.12.+
}
}
应用插件:'机器人'依赖{ 编译文件树(导演:'库',包括:的* .jar)
}安卓{
compileSdkVersion 12
buildToolsVersion20.0.0 sourceSets {
主要{
manifest.srcFile'的AndroidManifest.xml
java.srcDirs = ['src'中]
resources.srcDirs = ['src'中]
aidl.srcDirs = ['src'中]
renderscript.srcDirs = ['src'中]
res.srcDirs = ['水库']
assets.srcDirs = ['资产']
} //移动测试,测试/ JAVA,测试/ RES等...
instrumentTest.setRoot(测试) //移动构建类型构建类型/<&型GT;
//例如,建立类型/调试/ JAVA,内置类型/调试/ AndroidManifest.xml中,...
//这个动作出来在src / LT他们默认位置和的;类型> / ...这将
//与SRC /冲突正在使用的主要来源集。
//添加新的构建类型或产品的口味应该陪同
//通过类似定制。
debug.setRoot(集结类型/调试)
release.setRoot(集结类型/释放)
}
}
请帮助..
在此先感谢
建议使用新的地图版API。
要使用它,添加下面的依赖关系到你的的build.gradle
:
编译com.google.android.gms:发挥服务:5.0.77
然后按照谷歌的指导来进行设置。 你可以在这里找到它
编辑:进一步阐述了的build.gradle
文件,这里是我的样子
应用插件:'机器人'安卓{
compileSdkVersion 19
buildToolsVersion'20'
defaultConfig {
14的minSdkVersion
targetSdkVersion 19
版本code 1
的versionName'1.0' 的applicationID'<&程序包GT;'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
发布 {
runProguard假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard的-rules.txt
}
调试{
调试的真
runProguard假
}
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
编译com.android.support:appcompat-v7:19.+
编译com.android.support:support-annotations:+
编译com.google.android.gms:播放服务:5.0.77
}
重要提示:有一个在每一个项目中的两个的build.gradle
文件。在一个是相应的模块文件夹内将这个。该模块通常被称为应用
,如果你还没有给它改名。
添加它确保您点击同步工程与摇篮文件顶部
按钮,这样它会下载所需要的依赖 <后/ p>
I have been making an app showing MapView, It got build and I even am using it on my device now that i want to add still more functionality , but suddenly studio is giving errors "cannot resolve symbol 'android'."...!!!!
I updated studio to 0.8.6 (latest) .... but damn..!! nothing changes ..
Errors :
package com.androidhive.googleplacesandmaps;
import java.util.List;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
public class PlacesMapActivity extends MapActivity {
// Nearest places
PlacesList nearPlaces;
// Map view
MapView mapView;
// Map overlay items
List<Overlay> mapOverlays;
AddItemizedOverlay itemizedOverlay;
GeoPoint geoPoint;
// Map controllers
MapController mc;
double latitude;
double longitude;
OverlayItem overlayitem;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_places);
// Getting intent data
Intent i = getIntent();
// Users current geo location
String user_latitude = i.getStringExtra("user_latitude");
String user_longitude = i.getStringExtra("user_longitude");
// Nearplaces list
nearPlaces = (PlacesList) i.getSerializableExtra("near_places");
mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
// Geopoint to place on map
geoPoint = new GeoPoint((int) (Double.parseDouble(user_latitude) * 1E6),
(int) (Double.parseDouble(user_longitude) * 1E6));
// Drawable marker icon
Drawable drawable_user = this.getResources()
.getDrawable(R.drawable.mark_red);
itemizedOverlay = new AddItemizedOverlay(drawable_user, this);
// Map overlay item
overlayitem = new OverlayItem(geoPoint, "Your Location",
"That is you!");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
itemizedOverlay.populateNow();
// Drawable marker icon
Drawable drawable = this.getResources()
.getDrawable(R.drawable.mark_blue);
itemizedOverlay = new AddItemizedOverlay(drawable, this);
mc = mapView.getController();
// These values are used to get map boundary area
// The area where you can see all the markers on screen
int minLat = Integer.MAX_VALUE;
int minLong = Integer.MAX_VALUE;
int maxLat = Integer.MIN_VALUE;
int maxLong = Integer.MIN_VALUE;
// check for null in case it is null
if (nearPlaces.results != null) {
// loop through all the places
for (Place place : nearPlaces.results) {
latitude = place.geometry.location.lat; // latitude
longitude = place.geometry.location.lng; // longitude
// Geopoint to place on map
geoPoint = new GeoPoint((int) (latitude * 1E6),
(int) (longitude * 1E6));
// Map overlay item
overlayitem = new OverlayItem(geoPoint, place.name,
place.vicinity);
itemizedOverlay.addOverlay(overlayitem);
// calculating map boundary area
minLat = (int) Math.min( geoPoint.getLatitudeE6(), minLat );
minLong = (int) Math.min( geoPoint.getLongitudeE6(), minLong);
maxLat = (int) Math.max( geoPoint.getLatitudeE6(), maxLat );
maxLong = (int) Math.max( geoPoint.getLongitudeE6(), maxLong );
}
mapOverlays.add(itemizedOverlay);
// showing all overlay items
itemizedOverlay.populateNow();
}
// Adjusting the zoom level so that you can see all the markers on map
mapView.getController().zoomToSpan(Math.abs( minLat - maxLat ), Math.abs( minLong - maxLong ));
// Showing the center of the map
mc.animateTo(new GeoPoint((maxLat + minLat)/2, (maxLong + minLong)/2 ));
mapView.postInvalidate();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
build.gradle file :
buildscript {
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android.gms:play-services:5.0.77'
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 12
buildToolsVersion "20.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Please help .. Thanks in advance
It is recommended to use the new Maps v2 API.
To use it, add the following dependency to your build.gradle
:
compile 'com.google.android.gms:play-services:5.0.77'
And then follow Google's guide to set it up. You can find it here
Edit: To elaborate more on the build.gradle
file, here is what mine looks like.
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName '1.0'
applicationId '<package_name>'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
debuggable true
runProguard false
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-annotations:+'
compile 'com.google.android.gms:play-services:5.0.77'
}
Important Note: There is two build.gradle
files in every project. Put this in the one that is inside the corresponding module folder. The module is often called app
, if you haven't renamed it.
After adding it make sure you click on the Sync Project with Gradle Files
button on the top, so it will download the required dependencies
这篇关于无法解析在Android工作室标志“机器人”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!