- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用这段代码:
package com.example.newsapp;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {
private Button mTrueButton;
private Button mFalseButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTrueButton = (Button)findViewById(R.id.true_button);
mTrueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,
R.string.correct_toast,
Toast.LENGTH_SHORT).show();
}
});
mFalseButton = (Button)findViewById(R.id.true_button);
mFalseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,
R.string.incorret_toast,
Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
还有这个 XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newsapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我收到以下错误:
12-28 16:10:43.777: I/dalvikvm(13310): Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
12-28 16:10:43.777: W/dalvikvm(13310): VFY: unable to resolve virtual method 11426: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
12-28 16:10:43.777: D/dalvikvm(13310): VFY: replacing opcode 0x6f at 0x0000
12-28 16:10:43.777: I/dalvikvm(13310): Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
12-28 16:10:43.777: W/dalvikvm(13310): VFY: unable to resolve virtual method 11432: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
12-28 16:10:43.777: D/dalvikvm(13310): VFY: replacing opcode 0x6f at 0x0000
12-28 16:10:43.777: I/dalvikvm(13310): Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
12-28 16:10:43.777: W/dalvikvm(13310): VFY: unable to resolve virtual method 9005: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
12-28 16:10:43.777: D/dalvikvm(13310): VFY: replacing opcode 0x6e at 0x000e
12-28 16:10:43.787: D/dalvikvm(13310): DexOpt: couldn't find static field Landroid/support/v7/appcompat/R$styleable;.Toolbar_buttonGravity
12-28 16:10:43.787: W/dalvikvm(13310): VFY: unable to resolve static field 3142 (Toolbar_buttonGravity) in Landroid/support/v7/appcompat/R$styleable;
12-28 16:10:43.787: D/dalvikvm(13310): VFY: replacing opcode 0x60 at 0x00aa
12-28 16:10:43.817: I/dalvikvm(13310): Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
12-28 16:10:43.817: W/dalvikvm(13310): VFY: unable to resolve virtual method 364: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
12-28 16:10:43.817: D/dalvikvm(13310): VFY: replacing opcode 0x6e at 0x0002
12-28 16:10:43.817: I/dalvikvm(13310): Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
12-28 16:10:43.817: W/dalvikvm(13310): VFY: unable to resolve virtual method 386: Landroid/content/res/TypedArray;.getType (I)I
12-28 16:10:43.817: D/dalvikvm(13310): VFY: replacing opcode 0x6e at 0x0002
12-28 16:10:43.827: D/AndroidRuntime(13310): Shutting down VM
12-28 16:10:43.827: W/dalvikvm(13310): threadid=1: thread exiting with uncaught exception (group=0x418eeda0)
12-28 16:10:43.827: E/AndroidRuntime(13310): FATAL EXCEPTION: main
12-28 16:10:43.827: E/AndroidRuntime(13310): Process: com.example.newsapp, PID: 13310
12-28 16:10:43.827: E/AndroidRuntime(13310): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newsapp/com.example.newsapp.MainActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.ActivityThread.access$900(ActivityThread.java:161)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.os.Handler.dispatchMessage(Handler.java:102)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.os.Looper.loop(Looper.java:157)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.ActivityThread.main(ActivityThread.java:5356)
12-28 16:10:43.827: E/AndroidRuntime(13310): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 16:10:43.827: E/AndroidRuntime(13310): at java.lang.reflect.Method.invoke(Method.java:515)
12-28 16:10:43.827: E/AndroidRuntime(13310): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
12-28 16:10:43.827: E/AndroidRuntime(13310): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
12-28 16:10:43.827: E/AndroidRuntime(13310): at dalvik.system.NativeStart.main(Native Method)
12-28 16:10:43.827: E/AndroidRuntime(13310): Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:273)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:225)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
12-28 16:10:43.827: E/AndroidRuntime(13310): at com.example.newsapp.MainActivity.onCreate(MainActivity.java:18)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.Activity.performCreate(Activity.java:5426)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
12-28 16:10:43.827: E/AndroidRuntime(13310): ... 11 more
12-28 16:10:43.827: E/AndroidRuntime(13310): Caused by: java.lang.reflect.InvocationTargetException
12-28 16:10:43.827: E/AndroidRuntime(13310): at java.lang.reflect.Constructor.constructNative(Native Method)
12-28 16:10:43.827: E/AndroidRuntime(13310): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
12-28 16:10:43.827: E/AndroidRuntime(13310): ... 24 more
12-28 16:10:43.827: E/AndroidRuntime(13310): Caused by: java.lang.NoSuchFieldError: android.support.v7.appcompat.R$styleable.Toolbar_buttonGravity
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.support.v7.widget.Toolbar.<init>(Toolbar.java:203)
12-28 16:10:43.827: E/AndroidRuntime(13310): at android.support.v7.widget.Toolbar.<init>(Toolbar.java:190)
12-28 16:10:43.827: E/AndroidRuntime(13310): ... 27 more
我在网上搜索并找到了不同的“解决方案”,但没有一个对我有用。有什么建议么?对此日志的一些见解将不胜感激,当我尝试启动它时它就崩溃了
最佳答案
<强>1。将依赖项导入 Maven 仓库
如果您使用的是 Maven 和默认存储库,则 appcompat 库已过时。将库从您的 Android SDK 手动导入到您的本地存储库中,然后重试。 (旧的appcompat是508KB,Android SDK的是497KB)
要导入 jar(指定 Android SDK 的正确路径):
mvn install:install-file -Dfile=/path/to/sdk/extras/android/compatibility/v7/appcompat/libs/android-support-v7-appcompat.jar -DgroupId=com.google.android -DartifactId=support-v7-appcompat -Dversion=r21 -Dpackaging=jar
然后在您的 pom 文件中添加依赖项:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v7-appcompat</artifactId>
<version>r21</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<强>2。或者查看使用 Maven Android SDK 部署程序: https://github.com/simpligility/maven-android-sdk-deployer
关于java - 由 : java. lang.NoSuchFieldError : android. support.v7.appcompat 引起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27677245/
我收到多行错误,指出它有重复的类 Duplicate class android.support.v4.accessibilityservice.AccessibilityServiceInfoCom
我的项目昨天运行良好,今天却出现以下错误。请帮忙。 出了什么问题:无法解析配置“:app:debugCompileClasspath”的所有文件。 Could not find support-v4.
错误:配置项目“:app”时出现问题。 Could not find support-v4.jar (com.android.support:support-v4:24.0.0). Searched
我正在使用 react-native-webrtc 运行示例应用程序模块。我正在尝试在 android 中运行该应用程序,但出现这样的错误... * What went wrong: A probl
错误:配置项目“:app”时出现问题。 Could not find support-v4.jar (com.android.support:support-v4:24.0.0). Searched
我克隆了我的项目并使用 Android studio 打开,但构建失败并出现以下错误并且同一个项目在其他项目上运行良好。 出了什么问题:无法解析配置“:app:flavorUnsignedReleas
我正在运行示例应用程序......我正在使用 this模块.....但是我收到这样的错误... FAILURE: Build failed with an exception. * What went
我有一个 Ionic 项目,在升级到 OSx Mojave 后,出于某种原因不再构建。 该项目基于 Ionic 3 构建。 我有 Cordova CLI 7.0.0 当我运行时 ionic cordo
我有一个 Ionic 项目,在升级到 OSx Mojave 后,出于某种原因不再构建。 该项目基于 Ionic 3 构建。 我有 Cordova CLI 7.0.0 当我运行时 ionic cordo
添加 Android 平台(ionic cordova platform add android)后,我构建了我的 Ionic 项目(ionic cordova build android),但出现错
这个问题在这里已经有了答案: Manifest merger failed : Attribute application@appComponentFactory - Androidx (14 个答
关于我的 Gradle 文件中的以下“complie”: dependencies { compile 'com.android.support:support-v4:25.3.1' }
有些困惑。 我想更频繁地使用@supports 但是...我不关心浏览器如何看待它。希望您能说清楚,如果可以的话谢谢您。 如果浏览器本身不理解@supports,它如何计算@support 'not'
我刚刚升级到 Dart 2 和最新版本的 Flutter,现在我无法构建我的应用程序。我在互联网上环顾四周,但仍然不明白为什么会发生这种情况。 我得到的错误是: FAILURE: Build fail
我正在学习 Firebase,但由于以下错误而陷入困境: Error:Failed to resolve: com.android.support:customtabs:25.4.0 Error:Fa
我在构建本周时出于某种原因尝试使用Cordova进行项目时遇到问题: cordova build android gradle获取com.android.support:support alpha而不
对应的androidx是什么com.android.support:support-compat 的图书馆实现push notifications ? 他们说here它是 androidx 的一部分,
我正在尝试为我的应用设置插桩单元测试。并且我已根据以下开发者站点链接添加了依赖项。 https://developer.android.com/training/testing/unit-testin
当我想使用 Proguard 规则生成签名的 APK(发布)时,我收到了以下错误消息: Cannot find a version of 'com.android.support:support-an
这个问题在这里已经有了答案: Failed to resolve: com.android.support:appcompat-v7:26.0.0 (14 个答案) Failed to resolv
我是一名优秀的程序员,十分优秀!