智能J 15中Android应用中的谷歌地图
我知道有很多这样的问题,但是我找不到任何有用的答案 我已经试过了,还有一些其他的: stackoverflow.com/questions/17960315/import-google-play-services-lib-into-intellij-idea-12-and-13/1797773417977734 stackoverflow.com/questions/14372391/java-lang-noclassdeffounderror-com-google-android-gms-rstylable/15826681815826818 stackoverflow.com/questions/14002488/google-play-services-library-in-intellij-12 但到目前为止没有任何效果。。。我不知道这是Intellij15问题还是我的问题 这里是一些截图 i、 stack.imgur.com/Wfm9k.png i、 stack.imgur.com/bcShb.png i、 stack.imgur.com/SNkSZ.png 我曾尝试直接从android sdk/extras/将其作为模块导入,我曾尝试将整个google services项目复制并粘贴到我的工作区中,但没有任何效果。屏幕截图来自我找到并尝试的上一个安装教程/答案 以下是当前的错误:智能J 15中Android应用中的谷歌地图,android,google-maps,intellij-idea,Android,Google Maps,Intellij Idea,我知道有很多这样的问题,但是我找不到任何有用的答案 我已经试过了,还有一些其他的: stackoverflow.com/questions/17960315/import-google-play-services-lib-into-intellij-idea-12-and-13/1797773417977734 stackoverflow.com/questions/14372391/java-lang-noclassdeffounderror-com-google-android-gms-rs
java.lang.RuntimeException: Unable to start activity ComponentInfo{hci4.project.FriendsWithCars/hci4.project.FriendsWithCars.MainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
Caused by: android.app.Fragment$InstantiationException: Trying to instantiate a class com.google.android.gms.maps.SupportMapFragment that is not a Fragment
请帮帮我
编辑1:
新设置中有一个新错误
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
public class MainActivity extends Activity {
private GoogleMap map;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
// Testing
TextView tv = (TextView) findViewById(R.id.TESTING);
DBHandler db = DBHandler.getInstance(this);
String output = db.getFullDB();
tv.setText(output);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
}
下面是main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/TESTING"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MainActivity"
/>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
附带问题:1。你的设置是什么?2.你们是如何导入GMS的 我认为你的问题是你在创建片段之前调用了它,而在连接之前调用要少得多。不要在创建时调用它。在onActivityCreated之后调用它 您可能需要一些类似于inside onActivityCreated的内容
附带问题:1。你的设置是什么?2.你们是如何导入GMS的 我认为你的问题是你在创建片段之前调用了它,而在连接之前调用要少得多。不要在创建时调用它。在onActivityCreated之后调用它 您可能需要一些类似于inside onActivityCreated的内容
我终于成功了。以下是我所做的工作,以供将来参考: 从SDK管理器下载Google play服务、Google存储库和Google支持库 转到android SDK/extras/google/google\u play\u services/libproject并复制google-play-services\u lib目录 将目录粘贴到系统的某个位置我将其粘贴到与项目根目录相同的级别 ../google-play-services_lib/ ../项目/ ../Project/.git ../Project/src 转到项目设置cmd+;然后进入模块 按中间列上方的+以添加新模块 选择导入模块 选择粘贴的google服务目录的路径 IntelliJ的一系列问题,您将在下面重播这些问题 如果IntelliJ要求您重用或覆盖.idea/.iml文件,请选择**重用* 返回到项目结构/模块并选择主模块 按依赖项存储格式上方底部的+键,然后选择模块 选择谷歌服务模块 再次按+并选择Jars。。。 在粘贴的google services目录中提供.jar的路径必须在libs下 将google-play-services_lib移到列表的顶部 最后一定是这样 您需要的所有权限都位于AndroidManifest中的上方
<permission
android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
您需要的所有应用程序设置都会进入
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="KEY-FROM-GOOGLE" />
我希望这能帮助人们……我终于成功了。以下是我所做的工作,以供将来参考: 从SDK管理器下载Google play服务、Google存储库和Google支持库 转到android SDK/extras/google/google\u play\u services/libproject并复制google-play-services\u lib目录 将目录粘贴到系统的某个位置我将其粘贴到与项目根目录相同的级别 ../google-play-services_lib/ ../项目/ ../Project/.git ../Project/src 转到项目设置cmd+;然后进入模块 按中间列上方的+以添加新模块 选择导入模块 选择粘贴的google服务目录的路径 IntelliJ的一系列问题,您将在下面重播这些问题 如果IntelliJ要求您重用或覆盖.idea/.iml文件,请选择**重用* 返回到项目结构/模块并选择主模块 按依赖项存储格式上方底部的+键,然后选择模块 选择谷歌服务模块 再次按+并选择Jars。。。 在粘贴的google services目录中提供.jar的路径必须在libs下 将google-play-services_lib移到列表的顶部 最后一定是这样 您需要的所有权限都位于AndroidManifest中的上方
<permission
android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
您需要的所有应用程序设置都会进入
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="KEY-FROM-GOOGLE" />
我希望这能帮助人们…最快解决方案:获取Android Studio:最快解决方案:获取Android Studio: