【发布时间】:2017-05-28 10:31:18
【问题描述】:
我看到其他有关 Error inflating class android.support.v7.widget.Toolbar 的问题并尝试了一些解决方案,例如,项目清理和重建、无效缓存和重新启动以及 appcompat 库版本下降,但没有任何效果。
-
gradle(我用的是Cordova,并不是所有代码都来自gradle)
buildscript { repositories { mavenCentral() jcenter() maven { url 'https://dl.bintray.com/tonylee/maven/' } } // Switch the Android Gradle plugin version requirement depending on the // installed version of Gradle. This dependency is documented at // http://tools.android.com/tech-docs/new-build-system/version-compatibility // and https://issues.apache.org/jira/browse/CB-8143 dependencies { classpath 'com.android.tools.build:gradle:2.2.3' } } dependencies { compile fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START debugCompile(project(path: "CordovaLib", configuration: "debug")) releaseCompile(project(path: "CordovaLib", configuration: "release")) // SUB-PROJECT DEPENDENCIES END provided 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:recyclerview-v7:21.0.3' compile 'com.fpang:adsync2:5.2.2' } -
广告.java
setContentView(R.layout.activity_main); activity_main.xml 中的工具栏
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<TextView
android:id="@+id/as2_sdk_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="21sp"
android:textColor="#ffffff"
android:textStyle="bold"
android:text="@string/app_name"/>
</android.support.v7.widget.Toolbar>
-styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
谁知道这个错误请帮助我。
【问题讨论】:
-
请从 logcat 发布您的错误堆栈。这是你完整的activity_main.xml 吗?因为它没有容器布局。
-
xml 中的工具栏在哪里
-
不知道为什么没有附上所有的代码。我现在编辑。
-
也发布你的 gradle..
标签: android