在最近更新Android Studio之后,我们在编译以前工作的项目时遇到了问题.起初我们收到以下错误:
/Users/james/Development/AndroidProjects/myapp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/res/values-v23/values-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Run Code Online (Sandbox Code Playgroud)
我将gradle文件中的sdk构建目标更新为23,这使得这个特定问题消失了,但它给我们留下了大量的apache.http包错误(具体来说,我们用于http内容的大量apache包现在已经不见了在sdk 23).
我想要做的是解决奇怪的资源错误,但没有更新到sdk 23.我现在没有时间重新编写我们的工具库来使用已发布的apache http组件的任何新实现.有没有人有任何想法?
我在Android Studio中为服务创建单元测试时遇到问题.我已经设置了我的项目来执行单元测试,并成功地为不同的(非服务)类设置了测试.我可以运行这些测试并让它们通过.
这是我的ServiceTestCase的代码:
package com.roche.parkinsons.service;
import android.content.Intent;
import android.test.ServiceTestCase;
import android.util.Log;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class GeneralServiceTest extends ServiceTestCase<GeneralService> {
/** Tag for logging */
private final static String TAG = GeneralServiceTest.class.getName();
public GeneralServiceTest() {
super(GeneralService.class);
}
//
@Before
public void setUp() throws Exception {
super.setUp();
Log.d(TAG, "Setup complete");
}
@After
public void tearDown() throws Exception {
Log.d(TAG, "Teardown complete");
super.tearDown();
}
@Test
public void testOnCreate() throws Exception {
Intent intent = new Intent(getSystemContext(), GeneralService.class);
startService(intent);
assertNotNull(getService()); …Run Code Online (Sandbox Code Playgroud) java android unit-testing android-service android-instrumentation
我遇到一个问题,尝试通过 DateFromatter 将字符串转换为日期时只产生了“nil”,而且我不知道哪里出错了。代码非常简单:
let testDate = "2021"
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy"
formatter.timeZone = TimeZone(secondsFromGMT: 0)
let date = formatter.date(from: testDate)
Run Code Online (Sandbox Code Playgroud)
请注意,这比原来简单得多,我尝试格式化的日期实际上是:
"2021-05-01T01:00:00Z"
Run Code Online (Sandbox Code Playgroud)
但我已经将其剥离以缩小问题所在。
正如您从上面看到的,我已经精简到一年,使用 en_US_POSIX 配置 DateFormatter 并仅使用“yyyy”作为格式。这在 Playgrounds 中有效,但在我的 Xcode 模拟器(位于美国区域设置)或我自己的物理 iPhone(设置为英国区域设置)中不起作用。话虽这么说,我不知道为什么区域设置很重要,因为有问题的字符串只是一年 - 它甚至没有得到错误的年份,只是零。
我不确定我哪里错了。