我有以下错误:
java.lang.RuntimeException: Unable to start activity \
ComponentInfo{app.cookingplace/app.cookingplace.MapsActivity}: \
android.view.InflateException: Binary XML file line #8: \
Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: \
Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
at android.app.Activity.setContentView(Activity.java:1657)
at app.cookingplace.MapsActivity.onCreate(MapsActivity.java:12)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 11 more
Caused by: android.support.v4.app.Fragment$InstantiationException: \
Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: \
make sure class name exists, is public, and has an empty constructor that is public
at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
... 20 more
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment in loader \
dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:\
/data/app/app.cookingplace-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
... 23 more
我的代码:
package app.cookingplace;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class LoginActivity extends Activity implements OnClickListener {
// All static variables
static final String baseURL = "http://sfsuswe.com/~f12g22/web/php/Login.php?";
String URL = "";
// XML node keys
static final String KEY_SESSION = "session"; // parent node
static final String KEY_ACTIVATED = "activate";
String activated = "";
static final String KEY_REGISTERED = "registered";
String registered = "";
static final String KEY_USERID = "userId";
String userId = "";
static final String KEY_LOGONNAME = "logonName";
String logonName = "";
private Button login_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
login_button = (Button) findViewById(R.id.login_button);
login_button.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_login, menu);
return true;
}
@Override
public void onClick(View arg0) {
EditText nameLogin = (EditText) findViewById(R.id.user_logon_id);
String loginName = nameLogin.getText().toString();
EditText passwordLogin = (EditText) findViewById(R.id.password_logon_id);
String password = passwordLogin.getText().toString();
String parameters = "logon=" + loginName + "&password=" + password;
URL = baseURL + parameters;
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); // getting XML
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_SESSION);
Element e = (Element) nl.item(0);
// adding each child node to HashMap key => value
activated = parser.getValue(e, KEY_ACTIVATED);
registered = parser.getValue(e, KEY_REGISTERED);
userId = parser.getValue(e, KEY_USERID);
logonName = parser.getValue(e, KEY_LOGONNAME);
if (registered.equals("1")) {
Intent nextScreen = new Intent(LoginActivity.this,
MapsActivity.class);
startActivityForResult(nextScreen, 0);
}
}
}
MapsActivity.java
package app.cookingplace;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MapsActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_maps, menu);
return true;
}
}
activity_login.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity" >
<EditText
android:id="@+id/user_logon_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10"
android:inputType="textPersonName"
android:text="@string/user_login" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/password_logon_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/user_logon_id"
android:ems="10"
android:inputType="textPassword"
android:text="@string/password_login" />
<Button
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/password_logon_id"
android:text="@string/button_login" />
activity_maps.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" >
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.cookingplace"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="app.cookingplace.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="app.cookingplace.permission.MAPS_RECEIVE" />
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- End of copy. -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="-My key tested and works fine-" />
<activity
android:name="app.cookingplace.LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="app.cookingplace.MapActivity"
android:label="@string/title_activity_map" >
</activity>
<activity
android:name="app.cookingplace.TestActivity"
android:label="@string/title_activity_test" >
</activity>
<activity
android:name="app.cookingplace.MapsActivity"
android:label="@string/title_activity_maps" >
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
public class MapsActivity extends Activity
public class MapsActivity extends FragmentActivity
问题内容: 我正在尝试使用行高和单元格的自动布局来制作可扩展单元格。为了使事情变得简单,我从下面的简单代码开始,我希望它们能正常工作: 现在这似乎可行,但是,我仍然收到以下消息警告: 估计(或当前)行高似乎与我提供的自动布局约束相冲突。尽管如此,使用以下代码刷新tableView仍将按预期显示它: 如何删除警告? 我知道将高度限制的优先级简单地更改为999即可删除警告,但在我看来,删除警告是一种h
问题内容: 输出: 但是当我执行以下操作时: 输出: 为什么扩展列表引用而不是列表扩展? 我发现这是因为我在尝试将listC扩展到listB时试图将listB附加到listA。 假设列表不能直接附加/扩展。解决该问题最常用的表格形式是什么? 问题答案: 修改到位列表,不返回任何内容,从而导致。在第二种情况下,这是一个正在扩展的临时列表,该列表在该行后立即消失,而在第一种情况下,可以通过引用。 在尝
问题内容: 我试图在所有符合协议的UIViewControllers中添加点按功能。 以下是我的做法: 点击屏幕时,结果如下: 我了解此错误,但不知道如何解决。谁能建议如何做到这一点? 问题答案: 问题在于,Objective-C不了解协议扩展。因此,您不能使用协议扩展将方法注入到类中,而Objective- C的消息传递机制可以看到该方法。您需要在视图控制器类 本身中 声明。 (我意识到这正是您
我从单元测试开始。我对一个类做了更改,在这个类中我不注入SessionContext,这样我就可以在需要时进行查找。 现在,在我的测试中,我想注入它,这样我就可以模拟查找方法: 我觉得很奇怪,因为我拥有所需的所有依赖项(这段代码在真实的应用程序中工作)。 如何使用mockito模拟和注入SessionContext?(我无法改变嘲讽框架)。
以下操作会在运行时导致异常: java.lang.VerifyError:操作数堆栈上的类型错误异常详细信息:location:com/sun/net/httpserver/spi/httpserverprovider$1.run()ljava/lang/object;@27:invokestatic原因:类型“sun/net/httpserver/defaulthttpserverprovide
Puppeteer 可以用来测试 Chrome 扩展 注意 Chrome / Chromium 扩展当前只能在非无头模式下使用。 下面的代码用来处理扩展的 background page,该扩展的代码在 ./my-extension: const puppeteer = require('puppeteer'); (async () => { const pathToExtension =