如果我从命令行运行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 项目中遇到了这个构建错误:
unexpected element <queries> found in <manifest>
Run Code Online (Sandbox Code Playgroud)
我如何解决它?
android manifest android-manifest android-gradle-plugin flutter
TL; DR:我正在寻找一个完整的工作样本,我将其称为"Gmail三片段动画"场景.具体来说,我们想从两个片段开始,如下所示:

在一些UI事件(例如,点击片段B中的某些内容)时,我们希望:
并且,在按下BACK按钮时,我们希望反转这组操作.
现在,我已经看到了很多部分实现; 我将在下面回顾其中的四个.除了不完整之外,他们都有自己的问题.
@Reto迈尔促成这种普遍的回答相同的基本问题,表明你会使用setCustomAnimations()一个FragmentTransaction.对于双片段场景(例如,您最初只看到片段A,并希望使用动画效果将其替换为新的片段B),我完全同意.然而:
<objectAnimator>他的代码示例使用像素的硬连线的位置,这似乎是不切实际给出不同的屏幕尺寸,但setCustomAnimations()需要动画资源,排除在Java中定义这些事情的可能性android:layout_weight在LinearLayout为按百分比分配空间GONE?android:layout_weight的0?预动画为0?别的一个规模?)@Roman Nurik指出,您可以动画任何属性,包括您自己定义的属性.这可以帮助解决硬连线位置的问题,代价是发明自己的自定义布局管理器子类.这有些帮助,但我仍然对Reto的其余解决方案感到困惑.
这个pastebin条目的作者显示了一些诱人的伪代码,基本上说所有三个片段最初都会驻留在容器中,片段C通过hide()事务操作在开始时隐藏.当UI事件发生时,我们接着是show()C和hide()A. 但是,我没有看到它如何处理B改变大小的事实.它还依赖于你显然可以在同一个容器中添加多个片段的事实,我不确定这是否是长期可靠的行为(更不用说它应该打破findFragmentById(),尽管我可以忍受它).
此博客文章的作者表示Gmail根本不使用setCustomAnimations(),而是直接使用对象动画师("您只需更改根视图的左边距+更改右视图的宽度").然而,这仍然是一个双片段解决方案AFAICT,并且再次显示的实现硬连线尺寸以像素为单位.
我将继续关注此问题,所以有一天我可能会自己回答这个问题,但我真的希望有人为这个动画场景制定了三片段解决方案,并且可以发布代码(或链接).Android中的动画让我想要脱掉头发,而那些见过我的人知道这是一个毫无结果的努力.
在Android开发者博客文章介绍GridLayout节目的跨度如何影响自动索引分配这个图:

我试图用a实际实现它GridLayout.这是我到目前为止:
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.commonsware.android.gridlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:orientation="horizontal"
app:columnCount="8">
<Button
app:layout_columnSpan="2"
app:layout_rowSpan="2"
android:layout_gravity="fill_horizontal"
android:text="@string/string_1"/>
<Button
app:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:text="@string/string_2"/>
<Button
app:layout_rowSpan="4"
android:text="@string/string_3"/>
<Button
app:layout_columnSpan="3"
app:layout_rowSpan="2"
android:layout_gravity="fill_horizontal"
android:text="@string/string_4"/>
<Button
app:layout_columnSpan="3"
android:layout_gravity="fill_horizontal"
android:text="@string/string_5"/>
<Button
app:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:text="@string/string_6"/>
<android.support.v7.widget.Space
app:layout_column="0"
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
<android.support.v7.widget.Space
android:layout_width="36dp"
/>
</android.support.v7.widget.GridLayout>
Run Code Online (Sandbox Code Playgroud)
我必须引入<Space>元素以确保每列具有最小宽度,否则,我会有一堆零宽度列.
然而,即使有他们,我得到这个:

值得注意的是:
尽管如此android:layout_gravity="fill_horizontal",我的带有列跨度的小部件并没有填充跨越的列
尽管有这些android:layout_rowSpan值,但没有任何东西跨越行
任何人都可以使用博客文章从博客文章中复制图表GridLayout吗?
谢谢!
如果您使用Android Studio 1.5.0中的矢量资源向导,则使用该向导导入的任何矢量可绘制XML都会进入res/drawable/.
但是,build/目录和生成的APK显示这些XML文件被移动到res/drawable-anydpi-v21/资源目录中.该-v21部分是有意义的,因为VectorDrawable仅在API Level 21+上支持.但是,-anydpi似乎没有证件.我-nodpi原本期望,无论是原始导入目的地还是构建系统选择移动它的地方.
有没有人看到关于什么-anydpi方式的正式声明,以及它与它的关系是-nodpi什么?我正在寻找实际效果,而不仅仅是一些代码评论暗示的内容.
新的Android Studio可以通过更好的工具实现更好的Android开发.我看到了一些关于如何将eclipse项目转移到android studio的问题但是另一种方式呢?
如果您在Android Studio中制作Android应用程序,是否可以将其带回Eclipse?如果是这样,怎么样?
对于特定的eclipse插件,例如Blackberry Android插件,这将是必需的.
谢谢.
当我在Android M Preview 3上有一个23的目标API时,我似乎无法获得Manifest.permission.WRITE_SETTTINGS权限.
requestPermissions(new String[]{Manifest.permission.WRITE_SETTINGS},
101);
Run Code Online (Sandbox Code Playgroud)
请求权限不会显示我期望的对话框,但如果我未经此许可进行以下调用,
RingtoneManager.setActualDefaultRingtoneUri(activity, RingtoneManager.TYPE_RINGTONE, ringUri);
Run Code Online (Sandbox Code Playgroud)
电话会议除外,因为我没有这个权限.
我不知道从哪里开始.23有新的铃声API吗?或者这个权限更改只是让任何非系统应用程序无法更改铃声?
在Android 3.0中,"已检查"的概念可以使用"激活"背景进行渲染.这为您提供了在点击列表片段时看到的持久性栏,为列表右侧提供片段的上下文(例如,点击Gmail中的文件夹突出显示该文件夹并打开另一个列表片段以显示该文件夹中的对话).
例如,片段样本显示如下内容:
setListAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_activated_1, Shakespeare.TITLES));
Run Code Online (Sandbox Code Playgroud)
该资源(android.R.layout.simple_list_item_activated_1)是Android 3.0的新功能.它被"激活"的原因是:
android:background="?android:attr/activatedBackgroundIndicator"
Run Code Online (Sandbox Code Playgroud)
该属性值是Android 3.0的新功能,如果您尝试在早期版本的Android上使用它,将导致您崩溃,据我所知.我想为3.0/large/landscape组合设置背景为这个魔术值,否则将跳过它.
我可以通过布局的两个单独版本来实现这一点,一个在-v11资源集中,一个在常规资源集中.但是,这比我想要的要少一些,因为大部分布局是相同的,只有这一个属性被包含或被跳过.
我试图使用可绘制的资源别名,所以android:background可以引用别名,别名将处理-v11差异,但<bitmap>drawable似乎不喜欢android:src="@null".
我怀疑这个问题有一种样式和主题的方法,但由于我从来没有完全围绕那些(我的一个更令人尴尬的Android知识差距),我不完全确定该怎么做.
有没有人制定过在3.0上使用"激活"并在3.0之前跳过它的模式,超出了单独的布局?
谢谢!
曾几何时,特别是在Eclipse-land中,Lint会在每次构建时运行,因此如果你没有Lint检查,你会立即发现.使用Android Studio(在1.3上测试),Lint默认情况下不会在构建上运行.新人可能会犯下Lint会检查的错误,但由于Lint实际上没有运行,新人并没有发现它们.
(IOW,如果Lint测试没有在森林中运行,那么真的有Lint测试吗?)
对这篇博客文章的评论显示了如何将Lint作为构建的一部分运行:
lint为您的模块命名的"运行Gradle任务"添加一个步骤但是,这会运行命令行Lint,从而将报告以XML和HTML格式写入硬盘驱动器.这样可行,但让Android Studio运行其in-IDE Lint检查会更清晰,因此结果显示在IDE面板中.
有没有办法设置项目构建来执行in-IDE Lint检查?
奖励积分如果可以设置为仅运行Lint,而不是分析>检查代码完成的分析.虽然完整的分析偶尔会有用,但Lint足够慢,更不用说Android Studio执行的其他可疑的分析(例如,拼写检查).
虽然设置它对于所有项目来说都不是一个好的计划(Lint扫描速度很慢),但对于Android新手来说,这可能是一个合适的举措.
在SDK Manager的Android 5.0示例中,有ElevationBasic示例.它显示了两个View对象:圆形和方形.圆圈android:elevation设置为30dp:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF …Run Code Online (Sandbox Code Playgroud)