小编Som*_*ent的帖子

' - >'(箭头)在gradle的依赖图中意味着什么?

我正在尝试运行一些Android测试,但是,编译器抱怨存在多个dex文件.

Multiple dex files define Lorg/hamcrest/MatcherAssert;
Run Code Online (Sandbox Code Playgroud)

所以我试图过滤重复的依赖项: $ ./gradlew -q dependencies app:dependencies --configuration androidTestCompile

但是我得到以下输出:

------------------------------------------------------------
Project :app
------------------------------------------------------------

androidTestCompile - Classpath for compiling the androidTest sources.
+--- org.mockito:mockito-core:1.9.5
|    +--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    \--- org.objenesis:objenesis:1.0 -> 2.1
+--- com.google.dexmaker:dexmaker-mockito:1.2
|    +--- com.google.dexmaker:dexmaker:1.2
|    \--- org.mockito:mockito-core:1.9.5 (*)
+--- com.android.support.test.espresso:espresso-core:2.0
|    +--- com.squareup:javawriter:2.1.1
|    +--- org.hamcrest:hamcrest-integration:1.1
|    |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    +--- org.hamcrest:hamcrest-library:1.1
|    |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    +--- javax.inject:javax.inject:1
|    +--- com.android.support.test.espresso:espresso-idling-resource:2.0
|    +--- com.android.support.test:testing-support-lib:0.1 …
Run Code Online (Sandbox Code Playgroud)

java dependencies android gradle

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

android:isScrollContainer有什么作用?

有谁知道做什么android:isScrollCOntainer = (boolean)$(View).setScrollContainer(boolean)做什么?

起初我认为这将是在ScrollView中设置View而不是使用ScrollView滚动的答案,但似乎并非如此.

在Android开发者身上,它说,

"如果视图将用作滚动容器,则设置此项,这意味着可以调整其大小以缩小其整个窗口,以便为输入方法提供空间."

任何人都可以解释这个描述的含义吗?
在这种情况下,什么是滚动容器?
什么样的输入法可用?

android scroll view

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

在Android模拟器上安装自定义证书时,两个凭据使用选项"VPN和应用程序"与"Wifi"之间有什么区别?

我正在尝试在Android模拟器上安装Charles证书,我注意到有两个凭据使用选项:"VPN和应用程序"和"Wi-Fi".

在此输入图像描述

我试过四处寻找有关这两个选项的解释,但我发现的那个只是说"选一个适合你的用例."
这两个选项有什么区别?开发人员应该选择哪一个?

android emulation ssl-certificate

35
推荐指数
1
解决办法
5657
查看次数

ViewPropertyAnimator的translateYBy()与yBy()方法有什么区别?

ViewPropertyAnimators(http://developer.android.com/reference/android/view/ViewPropertyAnimator.html)有两种类型的方法来移动视图:

translateX()vs x(),translateY()vs y(),translateXBy()vs xBy(),最后是translateYBy()vs yBy().

有人能告诉我这些方法之间的区别吗?

animation android

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

如何在Theme.Material中使用ActionBarActivity

我创建了一个针对L预览的新项目.sdk生成的启动器活动扩展了ActionBarActivity,但是,当我尝试运行裸骨生成的活动时,它会抛出以下异常:

  Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
            at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
            at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
Run Code Online (Sandbox Code Playgroud)

我环顾四周但Theme.AppCompat.Material似乎并不存在.如何使ActionBarActivity利用新的Material主题?

我的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'
    defaultConfig {
        applicationId 'com.sdchang.example'
        minSdkVersion 'L'
        targetSdkVersion 'L'
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.+'
    compile 'com.mcxiaoke.volley:library:1.0.+@aar'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.squareup.okhttp:okhttp:2.0.+'
}
Run Code Online (Sandbox Code Playgroud)

android material-design

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

如何使用Charles Proxy设置Android Lollipop模拟器?

我一直在关注其他问题的说明,例如如何使用Charles Web Proxy和Windows上的最新Android模拟器配置SSL证书?(我虽然在MAC上)和SSL代理/查尔斯和Android的麻烦,我能够使用Charles Proxy分析Android模拟器的数据包一直到Kitkat.

现在我正在尝试为棒棒糖模拟器做同样的事情.但是,当我重复我用来成功设置Kitkat仿真器的相同步骤时,Charles没有显示任何内容!当我尝试使用模拟器的浏览器连接到Web时,它会出现以下错误: 在此输入图像描述

为了启用数据包嗅探功能,Mac OS X上的Android Lollipop仿真器是否需要特殊步骤?

提前致谢!

proxy android android-emulator android-5.0-lollipop charles-proxy

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

找不到插件“kotlin-parcelize”

Google 建议用户从 迁移kotlin-android-extensionskotlin-parcelize

但是,Gradle 同步失败并出现以下错误:

Plugin [id: 'kotlin-parcelize'] was not found in any of the following sources:

- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/6.1.1/userguide/standard_plugins.html for available core plugins)
- Plugin Repositories (plugin dependency must include a version number for this source)
Run Code Online (Sandbox Code Playgroud)

插件在哪里?

android gradle kotlin

16
推荐指数
3
解决办法
8734
查看次数

是否可以使用相同的端口启用tcp,http和websocket?

我试图在同一端口上启用tcp,httpwebsocket.io通信.我开始使用tcp服务器(部分////行以上),它工作正常.然后我运行了websocket.io上echo服务器示例(部分在////行下面),它也有效.但是当我尝试将它们合并在一起时,tcp不再起作用了.

那么,是否可以使用相同的端口启用tcp,http和websockets?或者我是否必须在另一个端口上侦听tcp连接?

var net = require('net');
var http = require('http');
var wsio = require('websocket.io');

var conn = [];

var server = net.createServer(function(client) {//'connection' listener
    var info = {
        remote : client.remoteAddress + ':' + client.remotePort
    };
    var i = conn.push(info) - 1;
    console.log('[conn] ' + conn[i].remote);

    client.on('end', function() {
        console.log('[disc] ' + conn[i].remote);
    });

    client.on('data', function(msg) {
        console.log('[data] ' + conn[i].remote + ' ' + msg.toString());
    });

    client.write('hello\r\n');
});

server.listen(8080); …
Run Code Online (Sandbox Code Playgroud)

sockets websocket node.js socket.io

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

使用AndroidJUnitRunner运行时,ActivityUnitTestCase会抛出RuntimeException

我正在尝试将Espresso 2.0的AndoridJUnitRunner与ActivityUnitTestCase 集成.但是,当startActivity()尝试初始化mMockParent = new MockParent()时,我的测试会崩溃.

这是我做的:

使用Intellij 14 CE创建一个新项目并对build.gradle进行一些更改.

android{
    defaultConfig {
        applicationId "com.noob.testing"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.+'

    androidTestCompile('org.mockito:mockito-core:1.9.5')
    androidTestCompile('com.google.dexmaker:dexmaker:1.2')
    androidTestCompile('com.google.dexmaker:dexmaker-mockito:1.2')

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.0')
    androidTestCompile('com.android.support.test:testing-support-lib:0.1')
}
Run Code Online (Sandbox Code Playgroud)

编写JUnit4风格的单元测试.

@RunWith(AndroidJUnit4.class)
public class MainActivityJUnit4Test extends ActivityUnitTestCase<MainActivity> {
    public MainActivityJUnit4Test() {
        super(MainActivity.class);
    }

    MainActivity activity;

    @Before
    public void setup() throws Exception {
        injectInstrumentation(InstrumentationRegistry.getInstrumentation());
        super.setUp();
        ContextThemeWrapper context = …
Run Code Online (Sandbox Code Playgroud)

junit android unit-testing activityunittestcase android-espresso

12
推荐指数
1
解决办法
5415
查看次数

如何将可搜索的活动与Ok Google语音搜索集成?

我正在尝试实施Ok Google Voice Search集成.但是,当我说"在app_name上搜索Android"时,我无法深入链接到我的应用.相反,它只是搜索网络上的术语.

这是我做的:

  1. 创建/res/xml/searchable.xml

    <?xml version="1.0" encoding="utf-8"?>
    <searchable xmlns:android="http://schemas.android.com/apk/res/android"
        android:label="@string/app_name"
        android:hint="@string/search_hint">
    </searchable>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 创建一个新活动

    public class ExposedSearchActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            String search = getIntent().getStringExtra(SearchManager.QUERY);
            Log.wtf("", "q=" + search);
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)
  3. 将意图过滤器附加到可搜索的活动

    <activity
        android:name=".search.ExposedSearchActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="fullSensor">
        <!--Deeplink from google now-->
        <intent-filter>
            <action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
        <!--Making it searchable-->
        <intent-filter>
            <action android:name="android.intent.action.SEARCH"/>
        </intent-filter>
        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable"/>
    </activity>
    
    Run Code Online (Sandbox Code Playgroud)
  4. 我的测试设备是运行Lollipop LPX13D的Nexus 5,带有谷歌搜索4.0.26.1499465.arm

我可能忘记了哪些其他步骤?提前致谢.

search android

11
推荐指数
1
解决办法
4396
查看次数