小编pio*_*543的帖子

ButterKnife错误:找不到符号方法findRequiredViewAsType

我一直在使用ButterKnife.但我有第一次看到的错误,并没有找到解决方案.

错误:

Error:(24, 36) error: cannot find symbol method findRequiredViewAsType(Object,int,String,Class<ImageView>)
Run Code Online (Sandbox Code Playgroud)

我总是像尝试bindView一样

@BindView(R.id.menu_hamburgerIcon)ImageView menuHamburger;

还添加了gradle:

   compile 'com.jakewharton:butterknife:8.0.1'
    apt 'com.jakewharton:butterknife-compiler:8.1.0'
Run Code Online (Sandbox Code Playgroud)

但仍然在ButterKnife的基础上得到这个错误.

android gradle android-gradle-plugin butterknife

5
推荐指数
1
解决办法
1949
查看次数

AndroidTest从命令行运行时失败:app:connectedDebugAndroidTest

我正在使用android spring RestTemplate在我的应用程序上进行REST服务调用.我添加了android Instrumentation测试,其中包括模拟REST服务调用.从android studio运行时,我的所有测试运行正常,但测试无法在终端使用时加载spring mock类

   ./gradlew clean :app:connectedDebugAndroidTest
Run Code Online (Sandbox Code Playgroud)

spring.gradle上的spring测试依赖项

    androidTestCompile("org.springframework:spring-test:3.2.8.RELEASE")
Run Code Online (Sandbox Code Playgroud)

如果我改为compile而不是androidTestCompile,Android测试从终端正常运行.由于我不希望这种依赖我的生产APK任何帮助,赞赏.

这是开始测试时的日志

08-05 00:04:12.585 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.asm.commons.JSRInlinerAdapter 08-05 00:04:12.587 22274-22302/com.libin .androiduitesting E/TestLoader:找不到类:org.springframework.asm.commons.TryCatchBlockSorter 08-05 00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework. cglib.transform.AbstractProcessTask 08-05 00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.cglib.transform.AbstractTransformTask 08-05 00:04:12.603 22274- 22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter 08-05 00:04:12.610 22274-22302/com.libin.androiduitesting E/TestLoader:无法find class:org.springframework.core.io.ResourceEditor 08-05 00:04:12.611 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.spring framework.core.io.support.ResourceArrayPropertyEditor 08-05 00:04:12.617 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http.MockHttpInputMessage 08-05 00:04 :12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http.MockHttpOutputMessage 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http.client.MockClientHttpRequest 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http. client.MockClientHttpResponse 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.jndi.ExpectedLookupTemplate 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.jndi.SimpleNamingContext 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting …

android spring-test android-espresso spring-android android-instrumentation

5
推荐指数
1
解决办法
1084
查看次数

Gradle:上传app-local-debug.apk时出错:未知失败([CDS] close [0])

我正在尝试使用gradlew cAT命令与我的Android手机执行连接的Android测试.但我得到以下错误日志,它无法安装该应用程序.

  • 如果使用adb命令,则会安装App.

  • 以上命令适用于OnePlusOne手机,但不适用于联想和华硕

错误日志如下:

Unable to install /home/admin/MyApp/app/build/outputs/apk/app-local-debug.apk
com.android.ddmlib.InstallException: Failed to install all 
        at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:91)
        at com.android.ddmlib.Device.installPackages(Device.java:901)
        at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:119)
        at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:121)
        at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)

android automated-tests gradle android-gradle-plugin android-espresso

5
推荐指数
2
解决办法
7655
查看次数

无法安装GPU调试工具

我尝试从SDK管理器安装Android Studio GPU调试工具.但它显示了这个错误:

安装
- GPU调试工具(附加功能; android; gapid; 1)

准备"安装GPU调试工具".
尝试安装到C:\ Users\Ronald\AppData\Local\Android\sdk\extras\android\gapid\1 \但是包装"GPU调试工具,rev 1.0.3"已存在于C:\ Users\Ronald\AppData \本地\ Android的\ SDK \演员\机器人\ gapid.在安装到子目录之前,必须将其删除或移走.
失败的包:
- GPU调试工具(额外的; android; gapid; 1)

这是...\extras\android\gapid\目录:

 Directory of C:\Users\Ronald\AppData\Local\Android\sdk\extras\android\gapid

08/10/2016  14:55    <DIR>          .
08/10/2016  14:55    <DIR>          ..
08/10/2016  20:50    <DIR>          1
08/10/2016  20:50    <DIR>          3
27/06/2016  21:54    <DIR>          android
27/06/2016  21:58            17.518 package.xml
27/06/2016  21:54            17.187 source.properties
27/06/2016  21:54    <DIR>          windows
               2 File(s)         34.705 bytes
               6 Dir(s)  282.628.423.680 bytes free
Run Code Online (Sandbox Code Playgroud)

...\extras\android\gapid\1\目录::

 Directory of C:\Users\Ronald\AppData\Local\Android\sdk\extras\android\gapid\1

08/10/2016 …
Run Code Online (Sandbox Code Playgroud)

android android-sdk-tools android-studio android-sdk-manager

5
推荐指数
1
解决办法
1168
查看次数

Gradle - 无法创建工具 API 实现的实例

我正在尝试从 GitHub 导入一个项目并在 Android Studio 上构建/运行它。我收到以下错误:

“错误:无法使用指定的 Gradle 发行版‘ https://services.gradle.org/distributions/gradle-2.4-all.zip ’创建工具 API 实现的实例。”

我尝试了以下方法:

  1. 使缓存无效并重新启动
  2. 将 gradle-wrapper/properties 中的 distributionURL 更改为 2.5 等。
  3. 删除 build.gradle 并重新启动

这些是我从 stackoverflow 上的其他几篇文章中得到的想法,所以我无法解释我为什么尝试这些。(我对 Android Studio 非常陌生)。

我的build.gradle文件看起来像这样:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    } }

allprojects { …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin gradle-tooling-api

4
推荐指数
1
解决办法
2万
查看次数

Android Studio 无法在 Windows 10 上启动

所以我已经安装了android studio,也成功下载了JRE和JDK;甚至通过命令提示符对其进行了测试。我什至制作了环境变量,告诉我将 JDK 的路径粘贴到 JAVA_HOME 并将 bin 路径粘贴到 PATH。但仍然每当我启动 Android studio 它几乎在这个屏幕上加载 ie 后卡住了

在此处输入图片说明

请帮忙; 我什至尝试从头开始重新安装所有内容,但我仍然卡住了。甚至每次都重新启动我的电脑以确保它正确完成。

PS:当我通过任务管理器监控这个过程时,它消耗了磁盘和内存,直到它在磁盘使用率变为 0 并且内存保持不变后出现在屏幕截图中。我知道它应该是什么,但只是提到

提前致谢

android android-studio

4
推荐指数
2
解决办法
3204
查看次数

Espresso - 匹配类的实例

我现在正试图通过它的类及其文本来使Espresso与UIElement匹配,因为它目前没有资源ID(我知道,我知道......).我不确定这个的正确语法是什么,因为Espresso文档很模糊(我对此非常陌生并且编程一般,所以我确定我错过了一些东西).这是我到目前为止所拥有的:

onView(allOf(instanceOf(android.widget.CheckBox)), withText("S"))).
                perform(scrollTo()).
                check(matches(isChecked()));
Run Code Online (Sandbox Code Playgroud)

我尝试只输入"文本框",但在这两种情况下我都会收到"表达式预期"错误.截至目前,这是识别此元素的唯一方法,因此任何指针都会有所帮助.谢谢!

android hamcrest android-testing android-espresso

4
推荐指数
1
解决办法
3948
查看次数

在Android Espresso中按“概述”按钮

我想为我的Android应用创建测试。每当它失去焦点时,就应该采取措施。

因此,我想通过按2次“概述”按钮(“主页”按钮旁边的按钮)进行测试。但是,我该如何使用Espresso?我尝试了一些按键代码,但没有一个起作用(不幸的是,KEY_OVERVIEW表中没有)。

那么我该如何测试呢?

谢谢,

尼克拉斯

android kotlin android-testing android-espresso

4
推荐指数
1
解决办法
731
查看次数

通知 - 在Lollipop Android版本上设置大图标

我一直在使用雪崩消息通知处理应用程序,并且我遇到了比Lollipop Android版驱动设备更早的通知大图标大小的问题.

在Lollipop和Marshmallow设备上它看起来很好:

但是当我在Android 4.4模拟器上打开一个应用程序时,我发现了这个:

图像没有缩放,适合,只是在中间裁剪.它看起来不太好.

注意:要明确说明,此大型通知图标将与消息日期和内容一起从服务器下载.它看起来像这样:

我的解决方案

在我的雪崩通知课程中经过几个小时的工作后,我添加了两种方法,只有在检测到Android pre-lollipop版本时才会运行:

  • 第一个将图标形状从矩形更改为方形,并添加白色背景
  • 第二个将图标尺寸更改为96x96

更改后,我在同一Kitkat模拟器(Moto X 2013)上的通知图标看起来好多了:

你能否告诉我是否有更简单的方法来解决这个问题?如果没有,除了96x96之外,我需要支持哪些图标尺寸?

提前致谢

notifications android android-layout android-notifications

3
推荐指数
1
解决办法
2330
查看次数

浓缩咖啡找不到视图:NoMatchingViewException

在我的应用程序中,我在一个活动中附加了两个片段。每个片段包含不同的视图。

第一个具有两个编辑文本字段和两个按钮,用户可以在其中登录或注册。所以现在我想进行一些Espresso测试。

@RunWith(AndroidJUnit4.class)
public class LoginTest {
@Rule
public final ActivityRule<MainActivity> main = new ActivityRule<>   
(MainActivity.class);

@Test
public void shouldBeAbleToFindViewsOfLoginScreen(){
    onView(withText(R.id.user_name)).perform(click());
   }

 }
Run Code Online (Sandbox Code Playgroud)

但是,测试抱怨它找不到ID为R.id.user_name的视图。

android.support.test.espresso.NoMatchingViewException: No views in hierarchy    
found matching: with string from resource id: <2131493050>[user_name] value:    
false
Run Code Online (Sandbox Code Playgroud)

我也使用了从uiautomatorviewer检查的相应ID。

该片段的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"
android:id="@+id/fragmentLogin"
tools:context="team.football.ael.MainActivity"
android:background="@drawable/background">
<include

    android:id="@+id/toolbar"
    layout="@layout/tool_lay"

    />

<LinearLayout
    android:padding="20dp"
    android:background="@drawable/roundedlayout"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_width="wrap_content"
    android:orientation="vertical"
    android:layout_height="wrap_content">
    <ImageView
        android:src="@mipmap/ael_logo"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_gravity="center_horizontal" />
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">
    <EditText
        android:id="@+id/user_name"
        android:hint="@string/login_username"
        android:textColor="#fff"
        android:textColorHint="#fff"
        android:layout_width="250dp" …
Run Code Online (Sandbox Code Playgroud)

android ui-testing android-testing android-espresso

3
推荐指数
1
解决办法
6983
查看次数