【发布时间】:2016-12-10 11:52:05
【问题描述】:
im trying to dogoogle map application but when running emulator after gradle error occuring.Please tell me exact solution on that.
package com.example.admin.myapplication;
import android.location.Address;
import android.location.Geocoder;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
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;
import java.io.IOException;
import java.util.List;
public class Home extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
Button search_loc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
// 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);
search_loc = (Button)findViewById(R.id.search_button);
search_loc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMapSearch(v);
}
});
}
public void onMapSearch(View view) {
EditText locationSearch = (EditText) findViewById(R.id.editText);
String location = locationSearch.getText().toString();
List<Address> addressList = null;
if (location != null || !location.equals("")) {
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
}
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("Marker"));
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng TutorialsPoint = new LatLng(21, 57);
mMap.addMarker(new MarkerOptions().position(TutorialsPoint).title("Map"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(TutorialsPoint));
}
}
错误:任务 ':app:transformClassesWithDexForDebug' 执行失败。 com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_74 \bin\java.exe'' 以非零退出值 3 结束
【问题讨论】:
-
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' // classpath 'com.android.tools.build:gradle:2.1.0' // 注意:不要将您的应用程序依赖项放在这里;它们属于 // 在单个模块 build.gradle 文件中 } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
标签: android google-maps