尝试在我的项目中使用最新的appcompat-v7支持库时,出现以下错误:
/Users/greg/dev/mobile/android_project/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v11/values.xml
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
android gradle xamarin.android android-support-library android-5.0-lollipop
我正在尝试使用android-support-v7:21库创建简单的应用程序.
代码片段:
MainActivity.java
public class MainActivity extends ActionBarActivity {
Toolbar mActionBarToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
mActionBarToolbar.setTitle("My title");
setSupportActionBar(mActionBarToolbar);
}
Run Code Online (Sandbox Code Playgroud)
activity_main.xml中
<LinearLayout
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"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_actionbar"
android:background="@null"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:fitsSystemWindows="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但是,不显示工具栏上的"我的标题",而是显示应用程序名称%.
似乎setTitle方法没有效果.
我想展示"我的头衔".
UPD:
之前,styles.xml是:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
所以,我认为没有使用动作栏.我添加NoActionBar到样式父级:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但问题没有解决.
我正在处理碎片并遇到两件事情Activity,FragmentActivity并且已经使用了好几次.我想知道这两者之间有什么区别,因为当我改变Activity时FragmentActivity,它对应用程序没有任何影响.
android android-fragments android-fragmentactivity android-support-library
我在更新到最新的支持库版本26.0.0时遇到此问题(https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0):
错误:(18,21)找不到与给定名称匹配的资源:attr'android:keyboardNavigationCluster'.
/.../app/build/intermediates/res/merged/beta/debug/values-v26/values-v26.xml
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:Execution failed for task ':app:processBetaDebugResources'.
Run Code Online (Sandbox Code Playgroud)
com.android.ide.common.process.ProcessException:无法执行aapt
该文件来自支持库:
<style name="Base.V26.Widget.AppCompat.Toolbar" parent="Base.V7.Widget.AppCompat.Toolbar">
<item name="android:touchscreenBlocksFocus">true</item>
<item name="android:keyboardNavigationCluster">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我们使用以下版本:
ext.COMPILE_SDK_VERSION = 26
ext.BUILD_TOOLS_VERSION = "26.0.1"
ext.MIN_SDK_VERSION = 17
ext.TARGET_SDK_VERSION = …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-support-library android-gradle-plugin
如果我从命令行运行gradle assembleDebug,我突然收到此错误:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:186)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300)
at com.android.dx.command.dexer.Main.run(Main.java:232)
at com.android.dx.command.dexer.Main.main(Main.java:174)
at com.android.dx.command.Main.main(Main.java:91)
Run Code Online (Sandbox Code Playgroud)
如果我grep for v4,我会在build文件夹中看到两个文件.
Binary file build/pre-dexed/debug/support-v4-19.0.0-2ba5fdd60a6c3836b3104a863fe42897da1fa9d1.jar matches
Binary file build/pre-dexed/debug/support-v4-r7-227d905d79b23b20866531d4f700446c040a2ccb.jar matches
Run Code Online (Sandbox Code Playgroud)
我的gradle文件仅包含此支持库:
compile 'com.android.support:support-v13:19.0.0'
Run Code Online (Sandbox Code Playgroud)
关于如何以某种方式包含r7库,我很难过.我跑了gradle clean,当我重新运行assembleDebug时它总是出现在那里.
如果我在构建目录中grep r7,我在文件中看到它:
Binary file build/exploded-bundles/ComGoogleAndroidGmsPlayServices4030.aar/classes.jar matches
Run Code Online (Sandbox Code Playgroud)
如果我不包含v13,那么其他东西不会编译.
但v13是否包含v4支持库?
这是Play服务AAR包和v13库之间的不兼容吗?
我从gradleplease.appspot.com抓起了gradle文件.
删除播放服务并不能解决问题; 同样的错误.
我在build.gradle中的依赖项:
dependencies {
// Google Play Services
//compile 'com.google.android.gms:play-services:4.0.30'
// Support Libraries
//compile 'com.android.support:support-v4:19.0.0'
///compile 'com.android.support:appcompat-v7:19.0.0'
//compile 'com.android.support:gridlayout-v7:19.0.0'
compile …Run Code Online (Sandbox Code Playgroud) android gradle android-support-library android-gradle-plugin
我刚刚尝试使用Android Studio.我创建了空白项目并试图创建Activity扩展AppCompatActivity.不幸的Android Studio"说"它
无法解析符号'AppCompatActivity'
我有 compile "com.android.support:appcompat-v7:22.0.+"我的"app"模块的依赖列表和重建项目几次.但是我只能使用ActionBarActivity.我究竟做错了什么?
android android-appcompat gradle android-support-library android-studio
我有一个关于Android支持库,片段的问题,并且作为一个具体的例子,ViewPager该类.我的目的是创建一个与Android Developer网站上提供的示例功能类似的应用程序(http://developer.android.com/training/animation/screen-slide.html或http://developer.android.com/ training/implementation-navigation/lateral.html).查看他们的代码,我注意到他们使用了android.support.v4.app库,我的研究是访问ViewPager该类的唯一方法.
在我的情况下,我对向后兼容性没兴趣.最低API级别为14(Ice Cream Sandwich),构建目标为4.2 Jelly Bean.在它最简单的形式中,我的应用程序与我在Android开发网站上链接的第二个演示完全一样 - 只需在三个选项卡之间滑动,每个选项卡中包含内容.
我读过的所有文章/帖子/答案似乎都非常支持v4支持库.现在,对于我,尽管是冗长的问题:
构建我的应用程序的最佳方法是什么 - 使用android.support.v4.app,从而使用SupportFragments,或使用提供的片段android.app- 以及为什么?
如果碎片来自android.app何方,最佳接近方式是ViewPagers什么?
如果SupportFragments最适合这项任务,我估计它们具有与另一项相同的功能 - 那么在内部拥有它们的目的是什么android.app?
希望有更清楚理解的人可以给我一些澄清,因为我很难过......
android android-fragments android-viewpager android-support-library
升级到API 22并支持lib版本22后,我收到以下警告:
警告:与依赖项"com.android.support:support-annotations"冲突.app(22.0.0)和测试app(21.0.3)的已解决版本有所不同.
Gradle本身更宽容,但Android Studio并没有那么多.
我没有使用21.0.3声明的依赖项...是使用21.0.3的依赖库之一而谷歌忘了用批处理的其余部分更新它?
我build.gradle的附加功能被删除了
android {
compileSdkVersion 22
buildToolsVersion '22'
defaultConfig {
applicationId "com.REDACTED.android"
minSdkVersion 14
targetSdkVersion 22
renderscriptSupportModeEnabled true
versionName '1.0.0'
versionCode 100
}
buildTypes {
release {
minifyEnabled true
zipAlignEnabled true
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
zipAlignEnabled true
signingConfig signingConfigs.debug
}
}
dependencies {
provided 'org.projectlombok:lombok:1.16.2'
googleCompile 'com.google.android.gms:play-services-base:6.5.87'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v13:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.android.support:palette-v7:22.0.0'
compile 'com.android.support:support-annotations:22.0.0'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.10'
compile 'com.jakewharton:butterknife:6.1.0'
compile …Run Code Online (Sandbox Code Playgroud) 通过Android Studio 2.2的预览1,Google在其支持库中发布了一个新的布局:ConstraintLayout.使用ConstraintLayout,在Android Studio中使用设计工具更容易,但我没有找到一种方法来使用相对大小(像LinearLayout中的百分比或'权重').有没有办法根据百分比定义约束?例如,使视图占据屏幕的40%,在视图之间创建20%的边距,将视图的宽度设置为另一个视图宽度的50%?
我有一个应用程序来管理书籍集(如播放列表).
我想显示一个带有垂直RecyclerView的集合列表,并在每行内部显示一个水平RecyclerView中的书籍列表.
当我将内部水平RecyclerView的layout_height设置为300dp时,它会正确显示,但是当我将其设置为wrap_content时,它不会显示任何内容. 我需要使用wrap_content,因为我希望能够以编程方式更改布局管理器以在垂直和水平显示之间切换.

你知道我做错了什么吗?
我的片段布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<com.twibit.ui.view.CustomSwipeToRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/shelf_collection_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"/>
</LinearLayout>
</com.twibit.ui.view.CustomSwipeToRefreshLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
集合元素布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF">
<!-- Simple Header -->
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty_collection"
android:id="@+id/empty_collection_tv"
android:visibility="gone"
android:gravity="center"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/collection_book_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/> <!-- android:layout_height="300dp" -->
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
书目项目:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="220dp"
android:layout_gravity="center">
<ImageView
android:id="@+id/shelf_item_cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxWidth="150dp"
android:maxHeight="200dp"
android:src="@drawable/placeholder"
android:contentDescription="@string/cover"
android:adjustViewBounds="true"
android:background="@android:drawable/dialog_holo_light_frame"/> …Run Code Online (Sandbox Code Playgroud) android android-layout android-support-library android-studio android-recyclerview